fluttercandies / flutter_ali_auth

Flutter Ali Auth Plugin 阿里云一键登录Flutter插件
https://pub.flutter-io.cn/packages/flutter_ali_auth
MIT License
48 stars 16 forks source link

[Bug report] 登录回调问题 #17

Closed HealingW closed 1 year ago

HealingW commented 1 year ago

Version

0.6.2

Platforms

Android

Device Model

HUAWEI P40 PRO 鸿蒙 3.0 中国移动

flutter info

[✓] Flutter (Channel stable, 3.3.5, on macOS 13.3.1 22E261 darwin-arm, locale zh-Hans-CN)
    • Flutter version 3.3.5 on channel stable at /Users/yuhao/software/flutter/flutter_3.3.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d9111f6402 (8 months ago), 2022-10-19 12:27:13 -0700
    • Engine revision 3ad69d7be3
    • Dart version 2.18.2
    • DevTools version 2.15.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/yuhao/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 73.1.1
    • Dart plugin version 231.9065

[✓] Connected device (4 available)
    • ELS AN00 (mobile) • UQG0220807002237          • android-arm64  • Android 12 (API 31)
    • later (mobile)    • 00008101-00120C110E9A001E • ios            • iOS 16.3 20D47
    • macOS (desktop)   • macos                     • darwin-arm64   • macOS 13.3.1 22E261 darwin-arm
    • Chrome (web)      • chrome                    • web-javascript • Google Chrome 113.0.5672.126

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

How to reproduce?

1,关闭移动数据网络 2,重新打开 app,一键登录插件初始化,此时 AliAuthClient.handleEvent(onEvent: authEvent) 正常回调 3,调用 AliAuthClient.login(); 此时进入 catch 方法 4,打开移动数据网络 5,调用 AliAuthClient.login(); 依旧进入 catch 方法,没有正常回调

:IOS 在此步骤下可以正常回调,只是在弹出登录框时很慢 :Android 第一步打开移动数据网络的情况下无此问题,不论期间开启/关闭移动数据都能正常回调

Logs

1,2步 log 正常,之后的步骤因为进入 catch 无日志

Example code (optional)

初始化:

await initAuth();
AliAuthClient.handleEvent(onEvent: authEvent);

回调方法:
authEvent(AuthResponseModel responseModel) async {
      if (responseModel.resultCode == '600000' && responseModel.token != null) {
        .......
        } else {
          CommonWidgetsBuilder.showToast('当前环境不支持一键登录,请使用其它方式登录');
        }
      } else if (responseModel.resultCode == '600008' && agreeProtocol.value) {
        CommonWidgetsBuilder.showToast(responseModel.msg ?? '请打开移动数据后重试');
      }
    }

登录按钮:
CustomCupertinoButton(
            width: 250.w,
            onPressed: () async {
              if (!agreeProtocol.value) {
                return CommonWidgetsBuilder.showToast('请同意相关协议');
              }
              try {
                await AliAuthClient.login();
              } catch (e) {
                // PlatformException(600025, 初始化失败或未初始化, null, null)
                CommonWidgetsBuilder.showToast('当前环境不支持一键登录,请开启移动网络或使用其它方式登录');
              }
            },
            text: '本机号码一键登录',
          ),

Contact

shangxindeshizi@outlook.com

HugPony commented 1 year ago

我也遇到了这个问题 请问解决了吗