fix: 首次初始化失败率比较高的问题

This commit is contained in:
liuyanfeng 2025-07-29 16:58:58 +08:00
parent 76ba875d55
commit 23eb97be4a
2 changed files with 33 additions and 30 deletions

View File

@ -199,14 +199,16 @@ class StarLockLoginLogic extends BaseGetXController {
if (entity.data!.abbreviation?.toLowerCase() == 'cn' &&
currentLanguage == 'zh_CN') {
//
JverifyOneClickLoginManage.instance.initSDK().then((value) async {
JverifyOneClickLoginManage.instance.initSDK(onSuccess: () async {
final bool isCheckVerifyEnable =
await JverifyOneClickLoginManage.instance.checkVerifyEnable();
state.isCheckVerifyEnable.value = isCheckVerifyEnable;
state.isCheckVerifyEnable.trigger(isCheckVerifyEnable);
AppLog.log('一键登录初始化认证结果:${state.isCheckVerifyEnable.value}');
if (isCheckVerifyEnable) {
oneClickLoginAction(Get.context!);
}
}, onFailure: () {
print('jpush sdk init failed');
});
}
});

View File

@ -38,9 +38,36 @@ class JverifyOneClickLoginManage {
///
String f_opr_key = 'operator';
Future<void> initSDK() async {
Future<void> initSDK({Function? onSuccess, Function? onFailure}) async {
try {
await initPlatformState();
// SDK
jverify.addSDKSetupCallBackListener((JVSDKSetupEvent event) {
print('receive sdk setup call back event :${event.toMap()}');
if (event.code == 8000) {
onSuccess?.call();
} else {
onFailure?.call();
}
});
jverify.setDebugMode(true); //
jverify.setCollectionAuth(true);
String appKey;
if (F.isSKY) {
appKey = '7ff37d174c1a568a89e98dad';
AppLog.log('appKey:7ff37d174c1a568a89e98dad');
} else {
appKey = '251fc8074820d122b6de58d2';
AppLog.log('appKey:251fc8074820d122b6de58d2');
}
jverify.setup(
appKey: appKey, //"你自己应用的 AppKey",
channel: 'devloper');
///
jverify.addAuthPageEventListener((JVAuthPageEvent event) {
print('receive auth page event :${event.toMap()}');
});
// isInitSuccess();
@ -52,32 +79,6 @@ class JverifyOneClickLoginManage {
}
}
Future<void> initPlatformState() async {
// SDK
jverify.addSDKSetupCallBackListener((JVSDKSetupEvent event) {
print('receive sdk setup call back event :${event.toMap()}');
});
jverify.setDebugMode(true); //
jverify.setCollectionAuth(true);
String appKey;
if (F.isSKY) {
appKey = '7ff37d174c1a568a89e98dad';
AppLog.log('appKey:7ff37d174c1a568a89e98dad');
} else {
appKey = '251fc8074820d122b6de58d2';
AppLog.log('appKey:251fc8074820d122b6de58d2');
}
jverify.setup(
appKey: appKey, //"你自己应用的 AppKey",
channel: 'devloper');
///
jverify.addAuthPageEventListener((JVAuthPageEvent event) {
print('receive auth page event :${event.toMap()}');
});
}
/// sdk
Future<bool> isInitSuccess() async {
final Map<dynamic, dynamic> map = await jverify.isInitSuccess();