From 23eb97be4a7465b53d69116af02b2bf3907681f9 Mon Sep 17 00:00:00 2001 From: liuyanfeng Date: Tue, 29 Jul 2025 16:58:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E6=AC=A1=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=A4=B1=E8=B4=A5=E7=8E=87=E6=AF=94=E8=BE=83=E9=AB=98?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/login/login/starLock_login_logic.dart | 6 ++- lib/tools/jverify_one_click_login.dart | 57 ++++++++++++----------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index 75f919fa..37da4b61 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -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'); }); } }); diff --git a/lib/tools/jverify_one_click_login.dart b/lib/tools/jverify_one_click_login.dart index e21b39fe..b9705bbe 100644 --- a/lib/tools/jverify_one_click_login.dart +++ b/lib/tools/jverify_one_click_login.dart @@ -38,9 +38,36 @@ class JverifyOneClickLoginManage { /// 运营商信息 String f_opr_key = 'operator'; - Future initSDK() async { + Future 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 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 isInitSuccess() async { final Map map = await jverify.isInitSuccess();