增加切换用户接口

master
gaoyunfei 2022-05-22 17:37:26 +08:00
parent 3fa610fdc4
commit 6e75fe48e7
3 changed files with 25 additions and 3 deletions

View File

@ -30,7 +30,7 @@ public class AppletModule extends BaseApi {
@Override @Override
public String[] apis() { public String[] apis() {
return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet"}; return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet", "changeUserId"};
} }
@Override @Override
@ -41,6 +41,8 @@ public class AppletModule extends BaseApi {
scanOpenApplet(param, callback); scanOpenApplet(param, callback);
} else if ("qrcodeOpenApplet".equals(event)){ } else if ("qrcodeOpenApplet".equals(event)){
qrcodeOpenApplet(param,callback); qrcodeOpenApplet(param,callback);
} else if ("changeUserId".equals(event)) {
changeUserId(param, callback);
} }
} }
@ -138,4 +140,18 @@ public class AppletModule extends BaseApi {
} }
}); });
} }
private void changeUserId(Map param, ICallback callback) {
String userId = String.valueOf(param.get("userId"));
if (FinAppClient.INSTANCE.getFinAppConfig() != null) {
FinAppClient.INSTANCE.getFinAppConfig().setUserId(userId);
callback.onSuccess(new HashMap());
} else {
callback.onFail(new HashMap(){
{
put("info", "sdk not initilized");
}
});
}
}
} }

View File

@ -121,8 +121,8 @@ public class BaseModule extends BaseApi {
.setUserId(userId) .setUserId(userId)
.setDebugMode(debug) .setDebugMode(debug)
.setDisableRequestPermissions(disablePermission) .setDisableRequestPermissions(disablePermission)
.setBindAppletWithMainProcess(bindAppletWithMainProcess) .setBindAppletWithMainProcess(bindAppletWithMainProcess);
.setPageCountLimit(pageCountLimit); // .setPageCountLimit(pageCountLimit);
if (customWebViewUserAgent != null) if (customWebViewUserAgent != null)
builder.setCustomWebViewUserAgent(customWebViewUserAgent); builder.setCustomWebViewUserAgent(customWebViewUserAgent);

View File

@ -387,6 +387,12 @@ class Mop {
return Map<String, dynamic>.from(ret!); return Map<String, dynamic>.from(ret!);
} }
Future<Map<String, dynamic>> changeUserId(String userId) async {
Map<String, Object> params = {'userId': userId};
final ret = await _channel.invokeMapMethod("changeUserId", params);
return Map<String, dynamic>.from(ret!);
}
/// ///
/// close all running applets /// close all running applets
/// ///