├── .github └── workflows │ ├── publish.yml │ ├── publishable.yml │ └── runnable.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── CODEOWNERS ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── build.gradle ├── libs │ ├── auth_number_product-2.12.15-log-online-standard-release.aar │ ├── crashshield-2.1.4-release.aar │ ├── logger-2.1.8-release.aar │ └── main-2.1.8-release.aar ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── fluttercandies │ │ └── flutter_ali_auth │ │ ├── AuthClient.java │ │ ├── FlutterAliAuthPlugin.java │ │ ├── config │ │ ├── BaseUIConfig.java │ │ ├── CustomAuthUIControlClickListener.java │ │ ├── DialogBackgroundDrawable.java │ │ ├── DialogBottomConfig.java │ │ ├── DialogPortConfig.java │ │ ├── FullPortConfig.java │ │ └── FullPortPrivacyConfig.java │ │ ├── mask │ │ └── DecoyMaskActivity.java │ │ ├── model │ │ ├── AuthModel.java │ │ ├── AuthResponseModel.java │ │ ├── AuthUIModel.java │ │ └── CustomViewBlock.java │ │ └── utils │ │ ├── AppUtils.java │ │ └── Constant.java │ └── res │ ├── anim │ ├── slide_down.xml │ ├── slide_up.xml │ ├── stay_animation.xml │ ├── zoom_in.xml │ └── zoom_out.xml │ ├── color │ ├── privacy_alert_btn_color.xml │ └── selector_bottom_item_color.xml │ ├── drawable-xxhdpi │ ├── a.png │ ├── b.png │ ├── ic_launcher.png │ ├── icon_check.png │ ├── icon_close.png │ ├── icon_notification.png │ ├── icon_return.png │ ├── icon_uncheck.png │ ├── login_btn_normal.png │ ├── login_btn_press.png │ └── login_btn_unable.png │ ├── drawable │ ├── dialog_page_background.xml │ ├── login_btn_bg.xml │ ├── mytel_app_launcher.png │ ├── phone.png │ ├── rectangle.xml │ ├── right.xml │ ├── selector_btn.xml │ ├── shap_btn_normal.xml │ └── shap_btn_press.xml │ ├── layout │ ├── activity_custom_web.xml │ ├── custom_port_dialog_action_bar.xml │ ├── custom_switch_other.xml │ └── dialog_action_bar.xml │ ├── raw │ └── keep.xml │ ├── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ └── network_security_config.xml ├── build.yaml ├── example ├── .gitignore ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── fluttercandies │ │ │ │ │ └── flutter_ali_auth_example │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ ├── values │ │ │ │ └── styles.xml │ │ │ │ └── xml │ │ │ │ └── network_security_config.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── images │ ├── app_bg.png │ ├── check_icon.png │ ├── flutter_candies_logo.png │ ├── icon_close_gray.png │ ├── icon_flutter.png │ ├── login_btn_normal.png │ ├── login_btn_press.png │ ├── login_btn_unable.png │ ├── tb.png │ ├── uncheck_icon.png │ ├── wb.png │ └── wx.png ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ ├── main.dart │ └── pages │ │ ├── debug_page.dart │ │ └── release_page.dart ├── pubspec.lock └── pubspec.yaml ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── AuthUIBuilder │ │ ├── AuthUIBuilder.swift │ │ ├── BuildAlertModel.swift │ │ ├── BuildBottomSheetModel.swift │ │ └── BuildFullScreenModel.swift │ ├── FlutterAliAuthPlugin.h │ ├── FlutterAliAuthPlugin.m │ ├── Model │ │ ├── AuthConfig.swift │ │ └── ResponseModel.swift │ ├── SwiftFlutterAliAuthPlugin.swift │ └── Utils │ │ ├── ColorExtension.swift │ │ ├── Constants.swift │ │ └── WindowUtils.swift ├── flutter_ali_auth.podspec └── frameworks │ ├── ATAuthSDK.framework │ ├── ATAuthSDK │ ├── ATAuthSDK.bundle │ │ ├── icon_check@2x.png │ │ ├── icon_check@3x.png │ │ ├── icon_close_gray@2x.png │ │ ├── icon_close_gray@3x.png │ │ ├── icon_nav_back_gray@2x.png │ │ ├── icon_nav_back_gray@3x.png │ │ ├── icon_nav_back_light@2x.png │ │ ├── icon_nav_back_light@3x.png │ │ ├── icon_uncheck@2x.png │ │ └── icon_uncheck@3x.png │ ├── Headers │ │ ├── ATAuthSDK.h │ │ ├── PNSReporter.h │ │ ├── PNSReturnCode.h │ │ ├── TXCommonHandler.h │ │ ├── TXCommonUtils.h │ │ └── TXCustomModel.h │ ├── Info.plist │ └── Modules │ │ └── module.modulemap │ ├── YTXMonitor.framework │ ├── Headers │ │ ├── ACMLogger.h │ │ ├── ACMManager.h │ │ ├── ACMMonitor.h │ │ ├── ACMProtocol.h │ │ └── YTXMonitor.h │ ├── Info.plist │ ├── Modules │ │ └── module.modulemap │ └── YTXMonitor │ └── YTXOperators.framework │ ├── Headers │ ├── YTXNetUtils.h │ ├── YTXOperators.h │ └── YTXVendorService.h │ ├── Info.plist │ ├── Modules │ └── module.modulemap │ └── YTXOperators ├── lib ├── flutter_ali_auth.dart └── src │ ├── auth_config │ ├── alert_ui_config.dart │ ├── alert_ui_config.g.dart │ ├── auth_config.dart │ ├── auth_config.g.dart │ ├── auth_ui_config.dart │ ├── full_screen_ui_config.dart │ ├── full_screen_ui_config.g.dart │ ├── part_ui_config.dart │ └── part_ui_config.g.dart │ ├── auth_response_model │ ├── auth_response_model.dart │ ├── auth_response_model.g.dart │ └── auth_result_code.dart │ └── internal │ ├── ali_auth_client.dart │ ├── flutter_ali_auth_method_channel.dart │ └── flutter_ali_auth_platform_interface.dart └── pubspec.yaml /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [ published ] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repo 13 | uses: actions/checkout@v3 14 | - name: Publish 15 | uses: k-paxian/dart-package-publisher@master 16 | with: 17 | credentialJson: ${{ secrets.CREDENTIAL_JSON }} 18 | flutter: true 19 | skipTests: true 20 | -------------------------------------------------------------------------------- /.github/workflows/publishable.yml: -------------------------------------------------------------------------------- 1 | name: Publishable 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | dry_run: 13 | name: Dry run publish on ${{ matrix.os }} 14 | if: github.repository == 'fluttercandies/flutter_ali_auth' 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | os: [ ubuntu-latest ] 19 | steps: 20 | - uses: actions/checkout@v3 21 | - uses: k-paxian/dart-package-publisher@master 22 | with: 23 | credentialJson: ${{ secrets.CREDENTIAL_JSON }} 24 | flutter: true 25 | dryRunOnly: true 26 | -------------------------------------------------------------------------------- /.github/workflows/runnable.yml: -------------------------------------------------------------------------------- 1 | name: Runnable (stable) 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze on ${{ matrix.os }} 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | os: [ ubuntu-latest ] 18 | steps: 19 | - uses: actions/checkout@v3 20 | - uses: actions/setup-java@v3 21 | with: 22 | distribution: 'adopt' 23 | java-version: '11.x' 24 | - uses: subosito/flutter-action@v2 25 | with: 26 | channel: 'stable' 27 | - name: Log Dart/Flutter versions 28 | run: | 29 | dart --version 30 | flutter --version 31 | - name: Prepare dependencies 32 | run: flutter pub get 33 | - name: Analyse the repo 34 | run: flutter analyze lib example/lib 35 | 36 | test_iOS: 37 | needs: analyze 38 | name: Test iOS on ${{ matrix.os }} 39 | runs-on: ${{ matrix.os }} 40 | strategy: 41 | matrix: 42 | os: [ macos-latest ] 43 | steps: 44 | - uses: actions/checkout@v3 45 | - uses: actions/setup-java@v3 46 | with: 47 | distribution: 'adopt' 48 | java-version: '11.x' 49 | - uses: subosito/flutter-action@v2 50 | with: 51 | architecture: x64 52 | channel: 'stable' 53 | - run: dart --version 54 | - run: flutter --version 55 | - run: flutter pub get 56 | - run: cd example; flutter build ios --no-codesign 57 | 58 | test_android: 59 | needs: analyze 60 | name: Test Android on ${{ matrix.os }} 61 | runs-on: ${{ matrix.os }} 62 | strategy: 63 | matrix: 64 | os: [ ubuntu-latest ] 65 | steps: 66 | - uses: actions/checkout@v3 67 | - uses: actions/setup-java@v3 68 | with: 69 | distribution: 'adopt' 70 | java-version: '11.x' 71 | - uses: subosito/flutter-action@v2 72 | with: 73 | channel: 'stable' 74 | - run: dart --version 75 | - run: flutter --version 76 | - run: flutter pub get 77 | - run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;21.4.7075529" 78 | - run: cd example; flutter build apk --debug 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | example/lib/pages/config.dart 32 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 8 | channel: stable 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 17 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 18 | - platform: android 19 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 20 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 21 | - platform: ios 22 | create_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 23 | base_revision: ffccd96b62ee8cec7740dab303538c5fc26ac543 24 | 25 | # User provided section 26 | 27 | # List of Local paths (relative to this file) that should be 28 | # ignored by the migrate tool. 29 | # 30 | # Files that are not part of the templates will be ignored by default. 31 | unmanaged_files: 32 | - 'lib/main.dart' 33 | - 'ios/Runner.xcodeproj/project.pbxproj' 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | # Changelog 6 | 7 | ## 0.7.0 8 | ### 🚀 Update sdk to v2.12-1.15 9 | 10 | ## 0.6.2 11 | ### 😅 Fixed Android unexpected error 12 | 13 | * 😅 Fixed Android unexpected error 14 | 15 | ## 0.6.1 16 | ### 🦖 Added missing Android judgment 17 | 18 | * 🦖️️ Added missing Android judgment 19 | 20 | ## 0.6.0 21 | ### 🔨 Fix android timeout issue 22 | 23 | * 🙇🏻‍♂️️ loginWithConfig with timeout 24 | 25 | ## 0.5.0 26 | ### 💥 Improve code 27 | 28 | * 🙇🏻‍♂️️ loginWithConfig with timeout 29 | 30 | ## 0.4.1 31 | ### 🔨 Enhance Android. 32 | 33 | * ✂️ enhance android 34 | * 🧩 add removeHandler method 35 | 36 | ## 0.4.0+1 37 | ### 🔨 Fix unexpected bugs on Android. 38 | 39 | * 🤖 Fix unexpected bugs on Android. 40 | 41 | ## 0.4.0 42 | ### 💥 Break Change 43 | 44 | * ✂️ remove checkVerifyEnable,accelerateLoginPage 45 | * 🌓 enable dark mode support 46 | * 🧩 update Aliyun sdk Sync with official 47 | 48 | ## 0.3.1 49 | ### 🤖️fixed android token handle 50 | 51 | * 🧸 ️fixed android token handle 52 | 53 | ## 0.3.0 54 | ### 🤖️Enhance android format 55 | 56 | * 🧸 use new json format 57 | 58 | ## 0.2.0 59 | ### 🔮Improve code 60 | 61 | * ⚡️ add removeListener 62 | * 🔫 provide the original sdk method,such as hideLoading,quitLoginPage 63 | * 🔖 update example and readme 64 | 65 | **Full Changelog**: https://github.com/fluttercandies/flutter_ali_auth/commits/Releases 66 | 67 | 68 | ## 0.1.0 69 | ### :seedling: First Release 70 | >flutter_ali_auth's development is based on ali auth native access,which are quick to configure and easy to use. 71 | - Specify the configuration. 72 | - Start to listen the native event and initialized. 73 | 74 | 75 | - Initial release. 76 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @ManInTheWind 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Kangkang 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | analyzer: 4 | exclude: 5 | - lib/**/**.g.dart 6 | linter: 7 | rules: 8 | - require_trailing_commas 9 | - sort_constructors_first 10 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .cxx 10 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.fluttercandies.flutter_ali_auth' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:7.1.2' 12 | } 13 | } 14 | 15 | rootProject.allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | // 阿里云一键登录依赖 20 | flatDir{ 21 | dirs project(":flutter_ali_auth").file("libs") 22 | } 23 | } 24 | } 25 | 26 | apply plugin: 'com.android.library' 27 | 28 | android { 29 | compileSdkVersion 31 30 | 31 | aaptOptions { 32 | noCompress "mov" //表示不让aapt压缩的文件后缀 33 | } 34 | 35 | compileOptions { 36 | sourceCompatibility JavaVersion.VERSION_1_8 37 | targetCompatibility JavaVersion.VERSION_1_8 38 | } 39 | 40 | defaultConfig { 41 | minSdkVersion 16 42 | } 43 | 44 | buildTypes { 45 | 46 | release { 47 | debuggable false 48 | // minifyEnabled true 49 | zipAlignEnabled false 50 | multiDexEnabled true 51 | 52 | } 53 | 54 | debug { 55 | // minifyEnabled false 56 | zipAlignEnabled false 57 | multiDexEnabled true 58 | } 59 | } 60 | } 61 | 62 | dependencies{ 63 | implementation "androidx.appcompat:appcompat:1.4.1" 64 | 65 | implementation "androidx.constraintlayout:constraintlayout:2.1.0" 66 | 67 | // implementation 'com.alibaba.fastjson2:fastjson2:2.0.14.android' 68 | // https://mvnrepository.com/artifact/com.google.code.gson/gson 69 | implementation 'com.google.code.gson:gson:2.9.0' 70 | implementation(name:'auth_number_product-2.12.15-log-online-standard-release', ext:'aar') 71 | implementation(name:'crashshield-2.1.4-release', ext:'aar') 72 | implementation(name:'main-2.1.8-release', ext:'aar') 73 | implementation(name:'logger-2.1.8-release', ext:'aar') 74 | 75 | } 76 | -------------------------------------------------------------------------------- /android/libs/auth_number_product-2.12.15-log-online-standard-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/libs/auth_number_product-2.12.15-log-online-standard-release.aar -------------------------------------------------------------------------------- /android/libs/crashshield-2.1.4-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/libs/crashshield-2.1.4-release.aar -------------------------------------------------------------------------------- /android/libs/logger-2.1.8-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/libs/logger-2.1.8-release.aar -------------------------------------------------------------------------------- /android/libs/main-2.1.8-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/libs/main-2.1.8-release.aar -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_ali_auth' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 24 | 31 | 32 | 39 | 40 | 46 | 47 | 48 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/FlutterAliAuthPlugin.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth; 2 | 3 | import static com.fluttercandies.flutter_ali_auth.model.AuthResponseModel.failedListeningMsg; 4 | 5 | import android.app.Activity; 6 | import android.content.res.AssetManager; 7 | import android.util.Log; 8 | 9 | import androidx.annotation.NonNull; 10 | 11 | import com.fluttercandies.flutter_ali_auth.model.AuthResponseModel; 12 | import com.fluttercandies.flutter_ali_auth.utils.AppUtils; 13 | import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper; 14 | 15 | import java.lang.ref.WeakReference; 16 | import java.util.Objects; 17 | 18 | import io.flutter.embedding.engine.plugins.FlutterPlugin; 19 | import io.flutter.embedding.engine.plugins.activity.ActivityAware; 20 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; 21 | import io.flutter.plugin.common.EventChannel; 22 | import io.flutter.plugin.common.MethodCall; 23 | import io.flutter.plugin.common.MethodChannel; 24 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 25 | import io.flutter.plugin.common.MethodChannel.Result; 26 | 27 | /** 28 | * FlutterAliAuthPlugin 29 | */ 30 | public class FlutterAliAuthPlugin implements FlutterPlugin, 31 | MethodCallHandler, ActivityAware { 32 | 33 | public static final String TAG = FlutterAliAuthPlugin.class.getSimpleName(); 34 | 35 | 36 | private AuthClient authClient; 37 | 38 | /// The MethodChannel that will the communication between Flutter and native Android 39 | /// 40 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 41 | /// when the Flutter Engine is detached from the Activity 42 | 43 | 44 | @Override 45 | public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { 46 | MethodChannel methodChannel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "flutter_ali_auth"); 47 | authClient = AuthClient.getInstance(); 48 | authClient.setChannel(methodChannel); 49 | methodChannel.setMethodCallHandler(this); 50 | authClient.setFlutterPluginBinding(flutterPluginBinding); 51 | } 52 | 53 | 54 | @Override 55 | public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { 56 | switch (call.method) { 57 | case "getPlatformVersion": 58 | result.success("Android " + android.os.Build.VERSION.RELEASE); 59 | break; 60 | case "getAliAuthVersion": 61 | getAliAuthVersion(result); 62 | break; 63 | case "init": 64 | authClient.initSdk(call.arguments, result); 65 | break; 66 | case "login": 67 | authClient.getLoginToken(call.arguments, result); 68 | break; 69 | case "loginWithConfig": 70 | authClient.getLoginTokenWithConfig(call.arguments, result); 71 | break; 72 | case "hideLoginLoading": 73 | authClient.hideLoginLoading(); 74 | result.success(null); 75 | break; 76 | case "quitLoginPage": 77 | authClient.quitLoginPage(); 78 | result.success(null); 79 | break; 80 | default: 81 | result.notImplemented(); 82 | } 83 | } 84 | 85 | private void getAliAuthVersion(@NonNull Result result) { 86 | String version = PhoneNumberAuthHelper.getVersion(); 87 | result.success("阿里云一键登录版本:" + version); 88 | } 89 | 90 | @Override 91 | public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { 92 | authClient.setFlutterPluginBinding(null); 93 | authClient.getChannel().setMethodCallHandler(null); 94 | } 95 | 96 | @Override 97 | public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { 98 | WeakReference activityWeakReference = new WeakReference<>(binding.getActivity()); 99 | authClient.setActivity(activityWeakReference); 100 | } 101 | 102 | @Override 103 | public void onDetachedFromActivityForConfigChanges() { 104 | } 105 | 106 | @Override 107 | public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { 108 | } 109 | 110 | @Override 111 | public void onDetachedFromActivity() { 112 | authClient.setFlutterPluginBinding(null); 113 | authClient.getChannel().setMethodCallHandler(null); 114 | authClient.setActivity(null); 115 | } 116 | 117 | 118 | 119 | // @Override 120 | // public void onListen(Object arguments, EventChannel.EventSink events) { 121 | // if (authClient.getEventSink() != null) { 122 | // authClient.getEventSink().endOfStream(); 123 | // authClient.setEventSink(null); 124 | // } 125 | // authClient.setEventSink(events); 126 | // } 127 | // 128 | // @Override 129 | // public void onCancel(Object arguments) { 130 | // if (Objects.nonNull(authClient.getEventSink())) { 131 | // authClient.setEventSink(null); 132 | // } 133 | // Log.i(FlutterAliAuthPlugin.TAG, "取消监听" + authClient.getEventSink()); 134 | // } 135 | } 136 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/config/CustomAuthUIControlClickListener.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.config; 2 | 3 | import android.content.Context; 4 | import android.text.TextUtils; 5 | import android.util.Log; 6 | import android.widget.Toast; 7 | 8 | import com.fluttercandies.flutter_ali_auth.AuthClient; 9 | import com.fluttercandies.flutter_ali_auth.R; 10 | import com.fluttercandies.flutter_ali_auth.model.AuthResponseModel; 11 | import com.mobile.auth.gatewayauth.AuthUIControlClickListener; 12 | import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper; 13 | import com.mobile.auth.gatewayauth.ResultCode; 14 | 15 | import org.json.JSONException; 16 | import org.json.JSONObject; 17 | 18 | import io.flutter.plugin.common.EventChannel; 19 | import io.flutter.plugin.common.MethodChannel; 20 | 21 | public class CustomAuthUIControlClickListener implements AuthUIControlClickListener { 22 | private PhoneNumberAuthHelper mAuthHelper; 23 | private Context mContext; 24 | private MethodChannel mChannel; 25 | public CustomAuthUIControlClickListener(PhoneNumberAuthHelper phoneNumberAuthHelper, 26 | Context context, MethodChannel methodChannel){ 27 | mAuthHelper = phoneNumberAuthHelper; 28 | mContext = context; 29 | mChannel = methodChannel; 30 | } 31 | @Override 32 | public void onClick(String code, Context context, String jsonString) { 33 | JSONObject jsonObj = null; 34 | AuthResponseModel responseModel = null; 35 | try { 36 | if(!TextUtils.isEmpty(jsonString)) { 37 | jsonObj = new JSONObject(jsonString); 38 | } 39 | } catch (JSONException e) { 40 | jsonObj = new JSONObject(); 41 | } 42 | Log.i("点击回调-","jsonObj:"+jsonObj); 43 | switch (code) { 44 | //点击授权页默认样式的返回按钮 45 | case ResultCode.CODE_ERROR_USER_CANCEL: 46 | responseModel = new AuthResponseModel(); 47 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 48 | responseModel.setResultCode(ResultCode.CODE_ERROR_USER_CANCEL); 49 | responseModel.setMsg("点击了授权页默认返回按钮"); 50 | // fEventSink.success(responseModel.toJson()); 51 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 52 | mAuthHelper.quitLoginPage(); 53 | // mActivity.finish(); 54 | break; 55 | //点击授权页默认样式的切换其他登录方式 会关闭授权页 56 | //如果不希望关闭授权页那就setSwitchAccHidden(true)隐藏默认的 通过自定义view添加自己的 57 | case ResultCode.CODE_ERROR_USER_SWITCH: 58 | responseModel = new AuthResponseModel(); 59 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 60 | 61 | responseModel.setResultCode(ResultCode.CODE_ERROR_USER_SWITCH); 62 | responseModel.setMsg("用户切换其他登录方式"); 63 | // fEventSink.success(responseModel.toJson()); 64 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 65 | break; 66 | //点击一键登录按钮会发出此回调 67 | //当协议栏没有勾选时 点击按钮会有默认toast 如果不需要或者希望自定义内容 setLogBtnToastHidden(true)隐藏默认Toast 68 | //通过此回调自己设置toast 69 | case ResultCode.CODE_ERROR_USER_LOGIN_BTN: 70 | if (!jsonObj.optBoolean("isChecked")) { 71 | Toast.makeText(mContext, R.string.custom_toast, Toast.LENGTH_SHORT).show(); 72 | } 73 | 74 | break; 75 | //checkbox状态改变触发此回调 76 | case ResultCode.CODE_ERROR_USER_CHECKBOX: 77 | responseModel = new AuthResponseModel(); 78 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 79 | 80 | responseModel.setResultCode(ResultCode.CODE_ERROR_USER_CHECKBOX); 81 | responseModel.setMsg("checkbox状态变为" + jsonObj.optBoolean("isChecked")); 82 | // fEventSink.success(responseModel.toJson()); 83 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 84 | 85 | break; 86 | //点击协议栏触发此回调 87 | case ResultCode.CODE_ERROR_USER_PROTOCOL_CONTROL: 88 | responseModel = new AuthResponseModel(); 89 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 90 | 91 | responseModel.setResultCode(ResultCode.CODE_ERROR_USER_PROTOCOL_CONTROL); 92 | responseModel.setMsg("点击协议," + "name: " + jsonObj.optString("name") + ", url: " + jsonObj.optString("url")); 93 | // fEventSink.success(responseModel.toJson()); 94 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 95 | 96 | break; 97 | case ResultCode.CODE_START_AUTH_PRIVACY: 98 | responseModel = new AuthResponseModel(); 99 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 100 | 101 | responseModel.setResultCode(ResultCode.CODE_START_AUTH_PRIVACY); 102 | responseModel.setMsg("点击授权页一键登录按钮拉起了授权页协议二次弹窗"); 103 | // fEventSink.success(responseModel.toJson()); 104 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 105 | 106 | break; 107 | case ResultCode.CODE_AUTH_PRIVACY_CLOSE: 108 | responseModel = new AuthResponseModel(); 109 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 110 | 111 | responseModel.setResultCode(ResultCode.CODE_AUTH_PRIVACY_CLOSE); 112 | responseModel.setMsg("授权页协议二次弹窗已关闭"); 113 | // fEventSink.success(responseModel.toJson()); 114 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 115 | 116 | break; 117 | case ResultCode.CODE_CLICK_AUTH_PRIVACY_CONFIRM: 118 | responseModel = new AuthResponseModel(); 119 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 120 | 121 | responseModel.setResultCode(ResultCode.CODE_CLICK_AUTH_PRIVACY_CONFIRM); 122 | responseModel.setMsg("授权页协议二次弹窗点击同意并继续"); 123 | // fEventSink.success(responseModel.toJson()); 124 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 125 | 126 | break; 127 | case ResultCode.CODE_CLICK_AUTH_PRIVACY_WEBURL: 128 | responseModel = new AuthResponseModel(); 129 | responseModel.setRequestId(Long.toString(System.currentTimeMillis())); 130 | 131 | responseModel.setResultCode(ResultCode.CODE_CLICK_AUTH_PRIVACY_WEBURL); 132 | responseModel.setMsg("点击授权页协议二次弹窗协议"); 133 | // fEventSink.success(responseModel.toJson()); 134 | mChannel.invokeMethod(AuthClient.DART_CALL_METHOD_ON_INIT,responseModel.toJson()); 135 | 136 | break; 137 | default: 138 | break; 139 | 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/config/DialogBackgroundDrawable.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.config; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.ColorFilter; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.graphics.PixelFormat; 8 | import android.graphics.Rect; 9 | import android.graphics.RectF; 10 | import android.graphics.drawable.Drawable; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.annotation.Nullable; 14 | 15 | public class DialogBackgroundDrawable extends Drawable { 16 | /** 17 | * 背景 18 | */ 19 | private Paint mPaint; 20 | /** 21 | * 边框 22 | */ 23 | private Paint mStrokePaint; 24 | private Path mPath; 25 | private RectF mRectF; 26 | private float mCornerRadius; 27 | private Float mBorderWidth; 28 | 29 | public DialogBackgroundDrawable(float cornerRadius, int color, Float borderWidth, Integer borderColor) { 30 | mCornerRadius = cornerRadius; 31 | mBorderWidth = borderWidth; 32 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 33 | mPaint.setColor(color); 34 | mPath = new Path(); 35 | mRectF = new RectF(); 36 | mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 37 | mStrokePaint.setStyle(Paint.Style.STROKE); 38 | mStrokePaint.setStrokeWidth(borderWidth); 39 | if (borderColor != null){ 40 | mStrokePaint.setColor(borderColor); 41 | } 42 | } 43 | 44 | 45 | @Override 46 | public void draw(@NonNull Canvas canvas) { 47 | mPath.reset(); 48 | mRectF.set(getBounds()); 49 | if (mBorderWidth != null) { 50 | mRectF.inset(mBorderWidth / 2, mBorderWidth / 2); 51 | } 52 | mPath.addRoundRect(mRectF, mCornerRadius, mCornerRadius, Path.Direction.CW); 53 | canvas.drawPath(mPath, mPaint); 54 | canvas.drawPath(mPath, mStrokePaint); 55 | } 56 | 57 | @Override 58 | public void setAlpha(int alpha) { 59 | mPaint.setAlpha(alpha); 60 | } 61 | 62 | @Override 63 | public void setColorFilter(@Nullable ColorFilter colorFilter) { 64 | mPaint.setColorFilter(colorFilter); 65 | } 66 | 67 | @Override 68 | public int getOpacity() { 69 | return PixelFormat.TRANSLUCENT; 70 | } 71 | 72 | @Override 73 | protected void onBoundsChange(Rect bounds) { 74 | super.onBoundsChange(bounds); 75 | mRectF.set(bounds); 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/mask/DecoyMaskActivity.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.mask; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | 8 | import androidx.annotation.Nullable; 9 | 10 | import com.fluttercandies.flutter_ali_auth.AuthClient; 11 | import com.fluttercandies.flutter_ali_auth.utils.Constant; 12 | import com.fluttercandies.flutter_ali_auth.R; 13 | import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper; 14 | 15 | import java.util.concurrent.Executors; 16 | import java.util.concurrent.ScheduledExecutorService; 17 | import java.util.concurrent.TimeUnit; 18 | 19 | public class DecoyMaskActivity extends Activity { 20 | 21 | 22 | public static final String TAG = DecoyMaskActivity.class.getSimpleName(); 23 | 24 | // public static boolean isRunning = false; 25 | 26 | @Override 27 | protected void onCreate(@Nullable Bundle savedInstanceState) { 28 | // isRunning = true; 29 | Log.i(TAG, "onCreate"); 30 | AuthClient authClient = AuthClient.getInstance(); 31 | AuthClient.decoyMaskActivity = this; 32 | // override the auth path open enter animation 33 | if (authClient.getAuthModel().getAuthUIStyle() == Constant.DIALOG_PORT) { 34 | overridePendingTransition(R.anim.zoom_in, R.anim.stay_animation); 35 | } else { 36 | overridePendingTransition(R.anim.slide_up, R.anim.stay_animation); 37 | } 38 | PhoneNumberAuthHelper authHelper = authClient.mAuthHelper; 39 | authHelper.getLoginToken(this.getBaseContext(), authClient.getLoginTimeout()); 40 | super.onCreate(savedInstanceState); 41 | } 42 | 43 | boolean isPause = false; 44 | 45 | @Override 46 | protected void onPause() { 47 | Log.i(TAG, "onPause"); 48 | isPause = true; 49 | super.onPause(); 50 | } 51 | 52 | @Override 53 | protected void onResume() { 54 | Log.i(TAG, "onResume"); 55 | 56 | if (isPause) { 57 | //TopActivityBack 58 | Runnable runnable = new Runnable() { 59 | @Override 60 | public void run() { 61 | finish(); 62 | } 63 | }; 64 | ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1); 65 | scheduledExecutorService.schedule(runnable, 0, TimeUnit.MILLISECONDS); 66 | } 67 | super.onResume(); 68 | } 69 | 70 | 71 | @Override 72 | public void finish() { 73 | super.finish(); 74 | Log.i(TAG, "finish"); 75 | AuthClient.decoyMaskActivity = null; 76 | } 77 | 78 | @Override 79 | protected void onDestroy() { 80 | super.onDestroy(); 81 | // isRunning = false; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/model/AuthModel.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.model; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.google.gson.Gson; 6 | 7 | import org.json.JSONException; 8 | import org.json.JSONObject; 9 | 10 | import java.util.Map; 11 | 12 | 13 | public class AuthModel { 14 | private String androidSdk; 15 | private Boolean enableLog; 16 | private Integer authUIStyle; 17 | private AuthUIModel authUIModel; 18 | 19 | // @NonNull 20 | // static public AuthModel Builder(Object params) { 21 | // AuthModel authModel = new Gson().fromJson(params.toString(), AuthModel.class); 22 | // 23 | // AuthUIModel authUIModel = JSON.to(AuthUIModel.class, json); 24 | // //Integer authUIStyle = (Integer) json.get("authUIStyle"); 25 | // Integer authUIStyle = authModel.authUIStyle; 26 | // authModel.setAndroidSdk(json.getString("androidSdk")); 27 | // authModel.setEnableLog(Boolean.valueOf(json.getString("enableLog"))); 28 | // authModel.setAuthUIStyle(authUIStyle); 29 | // authModel.setAuthUIModel(authUIModel); 30 | // return authModel; 31 | // } 32 | 33 | 34 | public void setAndroidSdk(String androidSdk) { 35 | this.androidSdk = androidSdk; 36 | } 37 | 38 | public void setEnableLog(Boolean enableLog) { 39 | this.enableLog = enableLog; 40 | } 41 | 42 | public void setAuthUIStyle(Integer authUIStyle) { 43 | this.authUIStyle = authUIStyle; 44 | } 45 | 46 | public void setAuthUIModel(AuthUIModel authUIModel) { 47 | this.authUIModel = authUIModel; 48 | } 49 | 50 | public String getAndroidSdk() { 51 | return androidSdk; 52 | } 53 | 54 | public Boolean getEnableLog() { 55 | return enableLog; 56 | } 57 | 58 | public Integer getAuthUIStyle() { 59 | return authUIStyle; 60 | } 61 | 62 | public AuthUIModel getAuthUIModel() { 63 | return authUIModel; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/model/AuthResponseModel.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.model; 2 | 3 | 4 | import android.text.TextUtils; 5 | import android.util.Log; 6 | 7 | import androidx.annotation.Nullable; 8 | 9 | import com.google.gson.Gson; 10 | import com.google.gson.reflect.TypeToken; 11 | import com.mobile.auth.gatewayauth.ResultCode; 12 | import com.mobile.auth.gatewayauth.model.TokenRet; 13 | 14 | import org.json.JSONException; 15 | import org.json.JSONObject; 16 | 17 | import java.lang.reflect.Type; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | import java.util.Objects; 21 | 22 | public class AuthResponseModel { 23 | private String resultCode; 24 | private String msg; 25 | private String requestId; 26 | private String token; 27 | private String innerMsg; 28 | private String innerCode; 29 | 30 | public static String initFailedMsg = "初始化失败或未初始化"; 31 | public static String nullSdkErrorMsg = "初始化失败,sdk为空"; 32 | public static String failedListeningMsg = "请先对插件进行监听"; 33 | public static String errorArgumentsMsg = "初始化失败,[AuthModel]解析失败"; 34 | public static String tokenDecodeFailedMsg = "回调信息解析失败"; 35 | public static String MSG_GET_MASK_SUCCESS = "600016"; 36 | public static String preLoginSuccessMsg = "预取号成功"; 37 | 38 | public static AuthResponseModel customModel(String resultCode, String msg) { 39 | String now = Long.toString(System.currentTimeMillis()); 40 | AuthResponseModel authResponseModel = new AuthResponseModel(); 41 | authResponseModel.setResultCode(resultCode); 42 | authResponseModel.setRequestId(now); 43 | authResponseModel.setMsg(msg); 44 | return authResponseModel; 45 | } 46 | 47 | public static AuthResponseModel initFailed(@Nullable String msg) { 48 | String now = Long.toString(System.currentTimeMillis()); 49 | assert msg != null; 50 | AuthResponseModel authResponseModel = new AuthResponseModel(); 51 | authResponseModel.setResultCode(ResultCode.CODE_ERROR_INVALID_PARAM); 52 | authResponseModel.setMsg(msg); 53 | authResponseModel.setRequestId(now); 54 | return authResponseModel; 55 | } 56 | 57 | public static AuthResponseModel nullSdkError() { 58 | String now = Long.toString(System.currentTimeMillis()); 59 | AuthResponseModel authResponseModel = new AuthResponseModel(); 60 | authResponseModel.setResultCode(ResultCode.CODE_ERROR_ANALYZE_SDK_INFO); 61 | authResponseModel.setMsg(nullSdkErrorMsg); 62 | authResponseModel.setRequestId(now); 63 | return authResponseModel; 64 | } 65 | 66 | public static AuthResponseModel tokenDecodeFailed() { 67 | String now = Long.toString(System.currentTimeMillis()); 68 | AuthResponseModel authResponseModel = new AuthResponseModel(); 69 | authResponseModel.setResultCode(ResultCode.MSG_ERROR_UNKNOWN_FAIL); 70 | authResponseModel.setMsg(tokenDecodeFailedMsg); 71 | authResponseModel.setRequestId(now); 72 | return authResponseModel; 73 | } 74 | 75 | public static AuthResponseModel onCustomViewBlocTap(Integer viewId) { 76 | String now = Long.toString(System.currentTimeMillis()); 77 | AuthResponseModel authResponseModel = new AuthResponseModel(); 78 | authResponseModel.setResultCode("700010"); 79 | authResponseModel.setMsg(viewId.toString()); 80 | authResponseModel.setRequestId(now); 81 | return authResponseModel; 82 | } 83 | 84 | public static AuthResponseModel accelerateLoginPageSuccess() { 85 | String now = Long.toString(System.currentTimeMillis()); 86 | AuthResponseModel authResponseModel = new AuthResponseModel(); 87 | authResponseModel.setResultCode(MSG_GET_MASK_SUCCESS); 88 | authResponseModel.setMsg("加速拉起授权页面成功"); 89 | authResponseModel.setRequestId(now); 90 | return authResponseModel; 91 | } 92 | 93 | public static AuthResponseModel fromTokenRect(TokenRet tokenRet) throws JSONException { 94 | 95 | //TokenRet{vendorName='ct_sjl', code='600024', msg='终端支持认证', carrierFailedResultData=', requestId=8147329b-1618-4b9f-98ce-02e468d237ba', requestCode=0, token='null'} 96 | 97 | AuthResponseModel authResponseModel = new AuthResponseModel(); 98 | 99 | authResponseModel.setResultCode(tokenRet.getCode()); 100 | 101 | authResponseModel.setRequestId(tokenRet.getRequestId()); 102 | 103 | authResponseModel.setMsg(tokenRet.getMsg()); 104 | 105 | String token = tokenRet.getToken(); 106 | 107 | if (Objects.nonNull(token) && !TextUtils.isEmpty(token) && !String.valueOf(token).equals("null")) { 108 | authResponseModel.setToken(token); 109 | } 110 | Map carrierFailedResultData = null; 111 | if (Objects.nonNull(tokenRet.getCarrierFailedResultData()) && !TextUtils.isEmpty(tokenRet.getCarrierFailedResultData()) && !String.valueOf(tokenRet.getCarrierFailedResultData()).equals("null")) { 112 | Gson gson = new Gson(); 113 | carrierFailedResultData = gson.fromJson(tokenRet.getCarrierFailedResultData(), new TypeToken>() { 114 | }.getType()); //反序列化 115 | } 116 | if (Objects.nonNull(carrierFailedResultData)) { 117 | assert carrierFailedResultData != null; 118 | if (Objects.nonNull(carrierFailedResultData.get("innerCode"))) { 119 | authResponseModel.setInnerCode((String) carrierFailedResultData.get("innerCode")); 120 | } 121 | if (Objects.nonNull(carrierFailedResultData.get("innerMsg"))) { 122 | authResponseModel.setInnerMsg(((String) carrierFailedResultData.get("innerMsg"))); 123 | } 124 | } 125 | 126 | return authResponseModel; 127 | } 128 | 129 | public void setResultCode(String resultCode) { 130 | this.resultCode = resultCode; 131 | } 132 | 133 | public void setMsg(String msg) { 134 | this.msg = msg; 135 | } 136 | 137 | public void setRequestId(String requestId) { 138 | this.requestId = requestId; 139 | } 140 | 141 | public void setToken(String token) { 142 | this.token = token; 143 | } 144 | 145 | public void setInnerMsg(String innerMsg) { 146 | this.innerMsg = innerMsg; 147 | } 148 | 149 | public void setInnerCode(String innerCode) { 150 | this.innerCode = innerCode; 151 | } 152 | 153 | public String getResultCode() { 154 | return resultCode; 155 | } 156 | 157 | public String getMsg() { 158 | return msg; 159 | } 160 | 161 | public String getRequestId() { 162 | return requestId; 163 | } 164 | 165 | public String getToken() { 166 | return token; 167 | } 168 | 169 | public String getInnerMsg() { 170 | return innerMsg; 171 | } 172 | 173 | public String getInnerCode() { 174 | return innerCode; 175 | } 176 | 177 | public Map toJson() { 178 | Map map = new HashMap<>(); 179 | map.put("requestId", requestId); 180 | map.put("resultCode", resultCode); 181 | map.put("msg", msg); 182 | map.put("token", token); 183 | map.put("innerCode", innerCode); 184 | map.put("innerMsg", innerMsg); 185 | return map; 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/model/CustomViewBlock.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.model; 2 | 3 | public class CustomViewBlock { 4 | public Integer viewId; // 用于回调时候判断返回的Id判断 5 | public String text; 6 | public String textColor; 7 | public Double textSize; 8 | public String backgroundColor; 9 | public String image; 10 | public Double offsetX; 11 | public Double offsetY; 12 | public Double width; 13 | public Double height; 14 | public Boolean enableTap; 15 | } 16 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/utils/AppUtils.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.utils; 2 | 3 | import android.content.Context; 4 | import android.util.DisplayMetrics; 5 | import android.view.WindowManager; 6 | 7 | public class AppUtils { 8 | public static int dp2px(Context context, float dipValue) { 9 | try { 10 | final float scale = context.getResources().getDisplayMetrics().density; 11 | return (int) (dipValue * scale + 0.5f); 12 | } catch (Exception e) { 13 | return (int) dipValue; 14 | } 15 | } 16 | 17 | public static int px2dp(Context context, float px) { 18 | try { 19 | final float scale = context.getResources().getDisplayMetrics().density; 20 | return (int) (px / scale + 0.5f); 21 | } catch (Exception e) { 22 | return (int) px; 23 | } 24 | } 25 | 26 | public static int getPhoneWidthPixels(Context context) { 27 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 28 | DisplayMetrics var2 = new DisplayMetrics(); 29 | if (wm != null) { 30 | wm.getDefaultDisplay().getMetrics(var2); 31 | } 32 | 33 | return var2.widthPixels; 34 | } 35 | 36 | public static int getPhoneHeightPixels(Context context) { 37 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 38 | DisplayMetrics var2 = new DisplayMetrics(); 39 | if (wm != null) { 40 | wm.getDefaultDisplay().getMetrics(var2); 41 | } 42 | 43 | return var2.heightPixels; 44 | } 45 | 46 | public static int integerTryParser(Object o,int defaultValue){ 47 | try { 48 | return (int) o; 49 | }catch (Exception ignore){ 50 | return defaultValue; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /android/src/main/java/com/fluttercandies/flutter_ali_auth/utils/Constant.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth.utils; 2 | 3 | import android.content.Context; 4 | import android.content.pm.ApplicationInfo; 5 | import android.content.pm.PackageManager; 6 | 7 | public class Constant { 8 | public static final String[] TYPES = {"全屏(竖屏)", "全屏(横屏)", "弹窗(竖屏)", 9 | "弹窗(横屏)", "底部弹窗", "自定义View", "自定义View(Xml)", "自定义Gif背景", "自定义视频背景(mov,mp4)", "自定义图片背景", "全屏(竖屏弹窗)", "全屏(横屏弹窗)"}; 10 | /** 11 | * 全屏(竖屏) 12 | */ 13 | public static final int FULL_PORT = 0; 14 | /** 15 | * 底部弹窗 16 | */ 17 | public static final int DIALOG_BOTTOM = 1; 18 | /** 19 | * 弹窗(竖屏) 20 | */ 21 | public static final int DIALOG_PORT = 2; 22 | 23 | 24 | /** 25 | * 全屏(横屏) 26 | */ 27 | public static final int FULL_LAND = 1; 28 | 29 | /** 30 | * "弹窗(横屏) 31 | */ 32 | public static final int DIALOG_LAND = 3; 33 | 34 | /** 35 | * 自定义View 36 | */ 37 | public static final int CUSTOM_VIEW = 5; 38 | /** 39 | * 自定义View(Xml) 40 | */ 41 | public static final int CUSTOM_XML = 6; 42 | /** 43 | * 自定义背景GIF 44 | */ 45 | public static final int CUSTOM_GIF = 7; 46 | /** 47 | * 自定义背景视频 48 | */ 49 | public static final int CUSTOM_MOV = 8; 50 | /** 51 | * 自定义背景图片 52 | */ 53 | public static final int CUSTOM_PIC = 9; 54 | 55 | /** 56 | * 全屏(竖屏弹窗) 57 | */ 58 | public static final int FULL_PORT_PRIVACY = 10; 59 | 60 | /** 61 | * 全屏(横屏弹窗 62 | */ 63 | public static final int FULL_LAND_PRIVACY = 11; 64 | 65 | public static final String THEME_KEY = "theme"; 66 | 67 | public static final String LOGIN_TYPE = "login_type"; 68 | 69 | public static final int LOGIN = 1; 70 | 71 | public static final int LOGIN_DELAY = 2; 72 | 73 | /** 74 | * UI Constant 75 | */ 76 | public static int Font_24 = 24; 77 | public static int Font_20 = 20; 78 | public static int Font_17 = 17; 79 | public static int Font_16 = 16; 80 | public static int Font_14 = 14; 81 | public static int Font_12 = 12; 82 | 83 | public static int kLogoOffset = 80; 84 | public static int kLogoSize = 100; 85 | 86 | public static int kPadding = 8; 87 | 88 | //public kBottomInset: Float = 32 89 | 90 | public static String getAppName(Context context){ 91 | ApplicationInfo applicationInfo = context.getApplicationInfo(); 92 | int stringId = applicationInfo.labelRes; 93 | return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : context.getString(stringId); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /android/src/main/res/anim/slide_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android/src/main/res/anim/slide_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /android/src/main/res/anim/stay_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /android/src/main/res/anim/zoom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | -------------------------------------------------------------------------------- /android/src/main/res/anim/zoom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 13 | 14 | 18 | -------------------------------------------------------------------------------- /android/src/main/res/color/privacy_alert_btn_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/src/main/res/color/selector_bottom_item_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/a.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/b.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/icon_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/icon_check.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/icon_close.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/icon_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/icon_notification.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/icon_return.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/icon_return.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/icon_uncheck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/icon_uncheck.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/login_btn_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/login_btn_normal.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/login_btn_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/login_btn_press.png -------------------------------------------------------------------------------- /android/src/main/res/drawable-xxhdpi/login_btn_unable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable-xxhdpi/login_btn_unable.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/dialog_page_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/login_btn_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/mytel_app_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable/mytel_app_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/phone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/android/src/main/res/drawable/phone.png -------------------------------------------------------------------------------- /android/src/main/res/drawable/rectangle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/right.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/selector_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/shap_btn_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android/src/main/res/drawable/shap_btn_press.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /android/src/main/res/layout/activity_custom_web.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /android/src/main/res/layout/custom_port_dialog_action_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 21 | 22 | 33 | -------------------------------------------------------------------------------- /android/src/main/res/layout/custom_switch_other.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 21 | 28 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /android/src/main/res/layout/dialog_action_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | -------------------------------------------------------------------------------- /android/src/main/res/raw/keep.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #FF000000 7 | #FF151515 8 | #616161 9 | #ffffffff 10 | #ff026ED2 11 | 12 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 号码认证Demo 3 | 4 | 切换到短信登录页面 5 | 自定义标题 6 | 自定义Slogan 7 | 同意服务条款才可以登录 8 | decoy 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 18 | 19 | 23 | 24 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /android/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | enrichgw.10010.com 5 | onekey.cmpassport.com 6 | 7 | -------------------------------------------------------------------------------- /build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | builders: 4 | json_serializable: 5 | options: 6 | create_factory: false 7 | include_if_null: false 8 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | lib/pages/config.dart 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_ali_auth_example 2 | 3 | Demonstrates how to use the flutter_ali_auth plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | defaultConfig { 38 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 39 | applicationId "com.fluttercandies.flutter_ali_auth_example" 40 | // You can update the following values to match your application needs. 41 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 42 | minSdkVersion 21 43 | targetSdkVersion flutter.targetSdkVersion 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | debug { 50 | ndk { 51 | abiFilters "armeabi", "armeabi-v7a","arm64-v8a", "x86", "arm64" 52 | } 53 | signingConfig signingConfigs.debug 54 | } 55 | release { 56 | ndk{ 57 | abiFilters "armeabi", "armeabi-v7a" 58 | // abiFilters "armeabi", "armeabi-v7a","arm64-v8a", "x86", "arm64" 59 | } 60 | // TODO: Add your own signing config for the release build. 61 | // Signing with the debug keys for now, so `flutter run --release` works. 62 | signingConfig signingConfigs.debug 63 | } 64 | } 65 | } 66 | 67 | flutter { 68 | source '../..' 69 | } 70 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 16 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/fluttercandies/flutter_ali_auth_example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.fluttercandies.flutter_ali_auth_example; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | enrichgw.10010.com 5 | onekey.cmpassport.com 6 | 7 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/images/app_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/app_bg.png -------------------------------------------------------------------------------- /example/images/check_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/check_icon.png -------------------------------------------------------------------------------- /example/images/flutter_candies_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/flutter_candies_logo.png -------------------------------------------------------------------------------- /example/images/icon_close_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/icon_close_gray.png -------------------------------------------------------------------------------- /example/images/icon_flutter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/icon_flutter.png -------------------------------------------------------------------------------- /example/images/login_btn_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/login_btn_normal.png -------------------------------------------------------------------------------- /example/images/login_btn_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/login_btn_press.png -------------------------------------------------------------------------------- /example/images/login_btn_unable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/login_btn_unable.png -------------------------------------------------------------------------------- /example/images/tb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/tb.png -------------------------------------------------------------------------------- /example/images/uncheck_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/uncheck_icon.png -------------------------------------------------------------------------------- /example/images/wb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/wb.png -------------------------------------------------------------------------------- /example/images/wx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/images/wx.png -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_ali_auth (0.0.1): 4 | - Flutter 5 | - MBProgressHUD 6 | - MJExtension 7 | - SDWebImage 8 | - MBProgressHUD (1.2.0) 9 | - MJExtension (3.4.1) 10 | - SDWebImage (5.17.0): 11 | - SDWebImage/Core (= 5.17.0) 12 | - SDWebImage/Core (5.17.0) 13 | 14 | DEPENDENCIES: 15 | - Flutter (from `Flutter`) 16 | - flutter_ali_auth (from `.symlinks/plugins/flutter_ali_auth/ios`) 17 | 18 | SPEC REPOS: 19 | trunk: 20 | - MBProgressHUD 21 | - MJExtension 22 | - SDWebImage 23 | 24 | EXTERNAL SOURCES: 25 | Flutter: 26 | :path: Flutter 27 | flutter_ali_auth: 28 | :path: ".symlinks/plugins/flutter_ali_auth/ios" 29 | 30 | SPEC CHECKSUMS: 31 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 32 | flutter_ali_auth: 7e96ab274f6144e20788046795d739a6007de55b 33 | MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 34 | MJExtension: 21c5f6f8c4d5d8844b7ae8fbae08fed0b501f961 35 | SDWebImage: 750adf017a315a280c60fde706ab1e552a3ae4e9 36 | 37 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 38 | 39 | COCOAPODS: 1.12.1 40 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Ali Auth 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_ali_auth_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:ui'; 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter/services.dart'; 6 | import 'package:flutter_ali_auth/flutter_ali_auth.dart'; 7 | import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; 8 | 9 | import 'pages/debug_page.dart'; 10 | import 'pages/release_page.dart'; 11 | 12 | void main() { 13 | runApp(const MyApp()); 14 | } 15 | 16 | class MyApp extends StatefulWidget { 17 | const MyApp({super.key}); 18 | 19 | @override 20 | State createState() => _MyAppState(); 21 | } 22 | 23 | class _MyAppState extends State { 24 | String _aliAuthVersion = '获取阿里云插件版本中'; 25 | 26 | ThemeMode themeMode = ThemeMode.system; 27 | 28 | Brightness? brightness; 29 | 30 | @override 31 | void initState() { 32 | super.initState(); 33 | initPlatformState(); 34 | SmartDialog.config.toast = SmartConfigToast( 35 | alignment: Alignment.center, 36 | animationType: SmartAnimationType.fade, 37 | ); 38 | 39 | brightness = 40 | MediaQueryData.fromView(PlatformDispatcher.instance.views.first) 41 | .platformBrightness; 42 | } 43 | 44 | Future initPlatformState() async { 45 | String aliAuthVersion; 46 | try { 47 | aliAuthVersion = (await AliAuthClient.version) as String? ?? '未知阿里云插件版本'; 48 | } on PlatformException { 49 | aliAuthVersion = 'Failed to get ali auth plugin version.'; 50 | } 51 | if (!mounted) return; 52 | setState(() { 53 | _aliAuthVersion = aliAuthVersion; 54 | }); 55 | } 56 | 57 | int _currentIndex = 1; 58 | 59 | @override 60 | Widget build(BuildContext context) { 61 | return MaterialApp( 62 | themeMode: themeMode, 63 | theme: ThemeData.light( 64 | useMaterial3: true, 65 | ), 66 | darkTheme: ThemeData.dark( 67 | useMaterial3: true, 68 | ), 69 | home: Scaffold( 70 | appBar: AppBar( 71 | title: Text(_aliAuthVersion), 72 | bottom: PreferredSize( 73 | preferredSize: const Size.fromHeight(48), 74 | child: Center( 75 | child: Row( 76 | mainAxisSize: MainAxisSize.min, 77 | children: [ 78 | const Text('暗黑模式:'), 79 | Switch.adaptive( 80 | value: brightness == Brightness.dark, 81 | onChanged: (bool? value) { 82 | setState(() { 83 | if (value ?? true) { 84 | themeMode = ThemeMode.dark; 85 | brightness = Brightness.dark; 86 | } else { 87 | themeMode = ThemeMode.light; 88 | brightness = Brightness.light; 89 | } 90 | }); 91 | }, 92 | ), 93 | ], 94 | ), 95 | ), 96 | ), 97 | ), 98 | body: IndexedStack( 99 | index: _currentIndex, 100 | children: const [ 101 | ReleasePage(), 102 | DebugPage(), 103 | ], 104 | ), 105 | bottomNavigationBar: BottomNavigationBar( 106 | currentIndex: _currentIndex, 107 | onTap: (int index) { 108 | setState(() { 109 | _currentIndex = index; 110 | }); 111 | }, 112 | items: const [ 113 | BottomNavigationBarItem( 114 | icon: Icon(Icons.verified), 115 | label: "发布", 116 | ), 117 | BottomNavigationBarItem( 118 | icon: Icon(Icons.bug_report), 119 | label: "测试", 120 | ), 121 | ], 122 | ), 123 | ), 124 | // here 125 | navigatorObservers: [FlutterSmartDialog.observer], 126 | // here 127 | builder: FlutterSmartDialog.init(toastBuilder: (String text) { 128 | return DecoratedBox( 129 | decoration: const ShapeDecoration( 130 | shape: StadiumBorder(), 131 | color: Colors.black87, 132 | ), 133 | child: Padding( 134 | padding: 135 | const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0), 136 | child: Text( 137 | text, 138 | style: Theme.of(context).textTheme.titleMedium?.copyWith( 139 | color: Colors.white, 140 | ), 141 | ), 142 | ), 143 | ); 144 | }), 145 | ); 146 | } 147 | } 148 | 149 | extension HexColor on Color { 150 | String toHex() { 151 | return '#${(0xFFFFFF & value).toRadixString(16).padLeft(6, '0')}'; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /example/lib/pages/release_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:flutter_ali_auth/flutter_ali_auth.dart'; 4 | import 'package:flutter_ali_auth_example/main.dart'; 5 | import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; 6 | 7 | class ReleasePage extends StatefulWidget { 8 | const ReleasePage({Key? key}) : super(key: key); 9 | 10 | @override 11 | State createState() => _ReleasePageState(); 12 | } 13 | 14 | class _ReleasePageState extends State { 15 | String get iosSdk { 16 | // TODO: provide your own iosSdkKey 17 | throw UnimplementedError(); 18 | } 19 | 20 | String get androidSdk { 21 | // TODO: provide your own iosSdkKey 22 | throw UnimplementedError(); 23 | } 24 | 25 | late final AuthConfig _authConfig = AuthConfig( 26 | iosSdk: iosSdk, 27 | androidSdk: androidSdk, 28 | enableLog: false, 29 | authUIStyle: AuthUIStyle.fullScreen, 30 | authUIConfig: FullScreenUIConfig( 31 | navConfig: NavConfig(navColor: Colors.pinkAccent.toHex()), 32 | logoConfig: const LogoConfig(logoImage: "images/app_icon"), 33 | ), 34 | ); 35 | 36 | @override 37 | void initState() { 38 | super.initState(); 39 | //uncomment this line to initialize sdk; 40 | //initialize(); 41 | } 42 | 43 | @override 44 | void dispose() { 45 | super.dispose(); 46 | } 47 | 48 | void initialize() { 49 | AliAuthClient.handleEvent(onEvent: _onEvent); 50 | } 51 | 52 | /// 登录成功处理 53 | Future _onEvent(AuthResponseModel responseModel) async { 54 | final AuthResultCode resultCode = AuthResultCode.fromCode( 55 | responseModel.resultCode!, 56 | ); 57 | switch (resultCode) { 58 | case AuthResultCode.success: 59 | if (responseModel.token != null && responseModel.token!.isNotEmpty) { 60 | //验证成功,获取到token 61 | // await onToken(token: responseModel.token!); 62 | } 63 | break; 64 | case AuthResultCode.envCheckSuccess: 65 | SmartDialog.showToast('当前环境支持一键登录'); 66 | break; 67 | case AuthResultCode.getMaskPhoneSuccess: 68 | SmartDialog.showToast('预先取号成功'); 69 | //预先取号成功再调起授权页面 70 | await AliAuthClient.login(timeout: 5); 71 | break; 72 | default: 73 | // implement your logic 74 | break; 75 | } 76 | } 77 | 78 | @override 79 | Widget build(BuildContext context) { 80 | return Center( 81 | child: Column( 82 | mainAxisSize: MainAxisSize.min, 83 | children: [ 84 | ElevatedButton( 85 | child: const Text('初始化SDK'), 86 | onPressed: () async { 87 | try { 88 | AliAuthClient.initSdk(authConfig: _authConfig); 89 | } on PlatformException catch (e) { 90 | final AuthResultCode resultCode = AuthResultCode.fromCode( 91 | e.code, 92 | ); 93 | SmartDialog.showToast(resultCode.message); 94 | } 95 | }, 96 | ), 97 | // ElevatedButton( 98 | // child: const Text('一键登陆'), 99 | // onPressed: () async { 100 | // try { 101 | // await AliAuthClient.login(); 102 | // } on PlatformException catch (e) { 103 | // final AuthResultCode resultCode = AuthResultCode.fromCode( 104 | // e.code, 105 | // ); 106 | // SmartDialog.showToast(resultCode.message); 107 | // } 108 | // }, 109 | // ), 110 | ], 111 | ), 112 | ); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | characters: 5 | dependency: transitive 6 | description: 7 | name: characters 8 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 9 | url: "https://pub.flutter-io.cn" 10 | source: hosted 11 | version: "1.3.0" 12 | collection: 13 | dependency: transitive 14 | description: 15 | name: collection 16 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" 17 | url: "https://pub.flutter-io.cn" 18 | source: hosted 19 | version: "1.17.1" 20 | flutter: 21 | dependency: "direct main" 22 | description: flutter 23 | source: sdk 24 | version: "0.0.0" 25 | flutter_ali_auth: 26 | dependency: "direct main" 27 | description: 28 | path: ".." 29 | relative: true 30 | source: path 31 | version: "0.7.0" 32 | flutter_lints: 33 | dependency: "direct dev" 34 | description: 35 | name: flutter_lints 36 | sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c 37 | url: "https://pub.flutter-io.cn" 38 | source: hosted 39 | version: "2.0.1" 40 | flutter_smart_dialog: 41 | dependency: "direct main" 42 | description: 43 | name: flutter_smart_dialog 44 | sha256: f8830d43c3906f42dc18464f31db5f42f5bc4ef7d36ed7c245cf5c1c0adc3f9f 45 | url: "https://pub.flutter-io.cn" 46 | source: hosted 47 | version: "4.5.5+6" 48 | js: 49 | dependency: transitive 50 | description: 51 | name: js 52 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 53 | url: "https://pub.flutter-io.cn" 54 | source: hosted 55 | version: "0.6.7" 56 | lints: 57 | dependency: transitive 58 | description: 59 | name: lints 60 | sha256: "5cfd6509652ff5e7fe149b6df4859e687fca9048437857cb2e65c8d780f396e3" 61 | url: "https://pub.flutter-io.cn" 62 | source: hosted 63 | version: "2.0.0" 64 | material_color_utilities: 65 | dependency: transitive 66 | description: 67 | name: material_color_utilities 68 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 69 | url: "https://pub.flutter-io.cn" 70 | source: hosted 71 | version: "0.2.0" 72 | meta: 73 | dependency: transitive 74 | description: 75 | name: meta 76 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 77 | url: "https://pub.flutter-io.cn" 78 | source: hosted 79 | version: "1.9.1" 80 | plugin_platform_interface: 81 | dependency: transitive 82 | description: 83 | name: plugin_platform_interface 84 | sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a 85 | url: "https://pub.flutter-io.cn" 86 | source: hosted 87 | version: "2.1.3" 88 | sky_engine: 89 | dependency: transitive 90 | description: flutter 91 | source: sdk 92 | version: "0.0.99" 93 | vector_math: 94 | dependency: transitive 95 | description: 96 | name: vector_math 97 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 98 | url: "https://pub.flutter-io.cn" 99 | source: hosted 100 | version: "2.1.4" 101 | sdks: 102 | dart: ">=3.0.0-0 <4.0.0" 103 | flutter: ">=3.0.0" 104 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_ali_auth_example 2 | description: Demonstrates how to use the flutter_ali_auth plugin. 3 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 4 | 5 | environment: 6 | sdk: '>=2.18.0 <3.0.0' 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | flutter_ali_auth: 13 | path: ../ 14 | 15 | flutter_smart_dialog: ^4.5.5+6 16 | 17 | dev_dependencies: 18 | flutter_lints: ^2.0.0 19 | 20 | flutter: 21 | uses-material-design: true 22 | 23 | assets: 24 | - images/ 25 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/ephemeral/ 38 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/AuthUIBuilder/AuthUIBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AuthUIBuilder.swift 3 | // ali_auth 4 | // 5 | // Created by kangkang on 2022/10/1. 6 | // 7 | 8 | import ATAuthSDK 9 | import Foundation 10 | 11 | enum AuthUIStyle: Int { 12 | case FullScreen 13 | case BottomSheet 14 | case Alert 15 | } 16 | 17 | typealias CustomViewBlockCallback = (ResponseModel) -> Void 18 | 19 | class AuthUIBuilder { 20 | var register: FlutterPluginRegistrar? 21 | 22 | var viewController: UIViewController? 23 | 24 | var customViewBlockCallback: CustomViewBlockCallback? 25 | 26 | public func buildUIModel(authUIStyle: AuthUIStyle, authUIConfig: AuthUIConfig, 27 | completionHandler: @escaping CustomViewBlockCallback) -> TXCustomModel 28 | { 29 | self.customViewBlockCallback = completionHandler 30 | 31 | switch authUIStyle { 32 | case .FullScreen: 33 | return self.buildFullScreenModel(config: authUIConfig) 34 | 35 | case .BottomSheet: 36 | return self.buildBottomSheetModel(config: authUIConfig) 37 | 38 | case .Alert: 39 | return self.buildAlertModel(config: authUIConfig) 40 | } 41 | } 42 | 43 | // MARK: - 获取Flutter的image 44 | 45 | func FlutterAssetImage(_ key: String?) -> UIImage? { 46 | if key == nil || (key?.isEmpty) == nil { 47 | return nil 48 | } 49 | guard let path = getFlutterAssetsPath(key: key!) else { 50 | return nil 51 | } 52 | 53 | return UIImage(contentsOfFile: path) 54 | } 55 | 56 | // MARK: - 获取Flutter Assets 路径 57 | 58 | func getFlutterAssetsPath(key: String) -> String? { 59 | let keyPath = self.register?.lookupKey(forAsset: key) 60 | // path:Optional("/private/var/containers/Bundle/Application/255AE8A8-DCFC-4907-B127-BBDFA4C86473/Runner.app/Frameworks/App.framework/flutter_assets/images/app_icon.png") 61 | return Bundle.main.path(forResource: keyPath, ofType: nil) 62 | } 63 | 64 | // MARK: - 获取插件Assets下的图片 65 | 66 | func BundleImage(_ key: String) -> UIImage? { 67 | if let image = UIImage(named: key, in: PluginBundle, compatibleWith: nil) { 68 | return image 69 | } 70 | return nil 71 | } 72 | 73 | // MARK: - 获取插件资源 74 | 75 | var PluginBundle: Bundle? { 76 | if let path = Bundle(for: SwiftFlutterAliAuthPlugin.self).path(forResource: "ATAuthSDK", ofType: "bundle") { 77 | let bundle = Bundle(path: path) 78 | return bundle 79 | } 80 | return nil 81 | } 82 | 83 | // MARK: - 构建自定义控件 84 | 85 | func buildCustomViewBlock(model: TXCustomModel, customViewConfigList: [CustomViewBlock]) { 86 | var customViewList: [UIView] = [] 87 | 88 | for index in 0 ..< customViewConfigList.count { 89 | let customView = UIButton(type: UIButton.ButtonType.custom) 90 | 91 | let customViewConfig = customViewConfigList[index] 92 | 93 | if let text = customViewConfig.text { 94 | customView.setTitle(text, for: UIControl.State.normal) 95 | } 96 | 97 | if let textColor = customViewConfig.textColor { 98 | customView.setTitleColor(textColor.uicolor(), for: UIControl.State.normal) 99 | } 100 | 101 | if let textSize = customViewConfig.textSize { 102 | customView.titleLabel?.font = UIFont.systemFont(ofSize: CGFloat(textSize)) 103 | } 104 | if let backgroundColor = customViewConfig.backgroundColor { 105 | customView.backgroundColor = backgroundColor.uicolor() 106 | } 107 | if let image = customViewConfig.image { 108 | if let imageFromFlutter = FlutterAssetImage(image) { 109 | customView.setImage(imageFromFlutter, for: UIControl.State.normal) 110 | customView.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) 111 | customView.imageView?.contentMode = .scaleAspectFill 112 | } 113 | } 114 | 115 | if customViewConfig.enableTap ?? false { 116 | // 添加点击事件 117 | if let viewId = customViewConfig.viewId { 118 | customView.tag = viewId 119 | customView.addTarget(self, action: #selector(self.customBtnOnTap), for: UIControl.Event.touchUpInside) 120 | } 121 | } 122 | 123 | customViewList.append(customView) 124 | } 125 | 126 | model.customViewBlock = { superCustomView in 127 | for index in 0 ..< customViewList.count { 128 | superCustomView.addSubview(customViewList[index]) 129 | } 130 | } 131 | 132 | model.customViewLayoutBlock = { _, _, _, _, _, _, _, _, _, _ in 133 | 134 | for index in 0 ..< customViewConfigList.count { 135 | let customViewConfig = customViewConfigList[index] 136 | let customViewBlock = customViewList[index] 137 | 138 | let x: Double = customViewConfig.offsetX ?? 0 139 | let y: Double = customViewConfig.offsetY ?? 0 140 | let width: Double = customViewConfig.width ?? 40 141 | let height: Double = customViewConfig.height ?? 40 142 | 143 | customViewBlock.frame = CGRect(x: x, y: y, width: width, height: height) 144 | } 145 | } 146 | } 147 | 148 | // MARK: - 自定义控件的点击事件 149 | 150 | @objc func customBtnOnTap(sender: UIButton) { 151 | // 回调自定义控件的点击事件,并且把viewId传递到flutter 152 | if let callback = customViewBlockCallback { 153 | let responseModel = ResponseModel(code: OnCustomViewTapCode, msg: String(describing: sender.tag)) 154 | 155 | callback(responseModel) 156 | } 157 | 158 | TXCommonHandler.sharedInstance().cancelLoginVC(animated: true, complete: nil) 159 | } 160 | 161 | var AppDisplayName: String { 162 | let infoDictionary = Bundle.main.infoDictionary! 163 | return infoDictionary["CFBundleDisplayName"] as! String 164 | } 165 | 166 | func isHorizontal(_ screenSize: CGSize) -> Bool { 167 | screenSize.width > screenSize.height 168 | } 169 | 170 | func onDispose() { 171 | self.register = nil 172 | self.viewController = nil 173 | self.customViewBlockCallback = nil 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /ios/Classes/FlutterAliAuthPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterAliAuthPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/FlutterAliAuthPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterAliAuthPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_ali_auth-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterAliAuthPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterAliAuthPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/Model/AuthConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AuthConfig.swift 3 | // aliauth 4 | // 5 | // Created by kangkang on 2022/10/1. 6 | // 7 | 8 | import Foundation 9 | 10 | struct AuthConfig { 11 | var iosSdk: String 12 | var enableLog: Bool 13 | var authUIStyle: AuthUIStyle 14 | var authUIConfig: AuthUIConfig 15 | 16 | init(params: [String: Any]) { 17 | iosSdk = params["iosSdk"] as? String ?? "" 18 | enableLog = params["enableLog"] as? Bool ?? false 19 | let index = params["authUIStyle"] as? Int ?? 0 20 | authUIStyle = AuthUIStyle(rawValue: index) ?? AuthUIStyle.FullScreen 21 | let decoder = JSONDecoder() 22 | decoder.keyDecodingStrategy = .convertFromSnakeCase 23 | authUIConfig = (try? decoder.decode(AuthUIConfig.self, from: JSONSerialization.data(withJSONObject: params, options: []))) ?? AuthUIConfig() 24 | } 25 | } 26 | 27 | struct AuthUIConfig: Codable { 28 | // gloabal config both fullscreen and alert 29 | 30 | var backgroundColor: String? // 十六进制的颜色 31 | 32 | var backgroundImage: String? 33 | 34 | var alertContentViewColor: String? // 十六进制的颜色 35 | 36 | var alertBlurViewColor: String? // 底部蒙层背景颜色,默认黑色 37 | 38 | var alertBlurViewAlpha: Float? // 底部蒙层背景透明度,默认0.5 39 | 40 | var alertBorderRadius: Float? // 四个角的圆角,默认为10 41 | 42 | var alertWindowWidth: Float? 43 | 44 | var alertWindowHeight: Float? 45 | 46 | // status bar 47 | var prefersStatusBarHidden: Bool? 48 | 49 | // nav 50 | var navIsHidden: Bool? 51 | var navTitle: String? 52 | var navTitleColor: String? 53 | var navTitleSize: Int? 54 | var navFrameOffsetX: Float? 55 | var navFrameOffsetY: Float? 56 | var navColor: String? 57 | 58 | // nav backItem 59 | var hideNavBackItem: Bool? 60 | 61 | var navBackImage: String? 62 | var navBackButtonOffsetX: Float? 63 | var navBackButtonOffsetY: Float? 64 | 65 | // alert bar 66 | var alertBarIsHidden: Bool? 67 | var alertCloseItemIsHidden: Bool? 68 | var alertTitleBarColor: String? 69 | 70 | var alertTitleText: String? 71 | var alertTitleTextColor: String? 72 | var alertTittleTextSize: Int? 73 | 74 | var alertCloseImage: String? 75 | var alertCloseImageOffsetX: Float? 76 | var alertCloseImageOffsetY: Float? 77 | 78 | // logo 79 | var logoIsHidden: Bool? 80 | var logoImage: String? 81 | var logoWidth: Float? 82 | var logoHeight: Float? 83 | 84 | var logoFrameOffsetX: Float? 85 | var logoFrameOffsetY: Float? 86 | 87 | // slogan 88 | var sloganIsHidden: Bool? 89 | var sloganText: String? 90 | var sloganTextColor: String? 91 | var sloganTextSize: Int? 92 | 93 | var sloganFrameOffsetX: Float? 94 | var sloganFrameOffsetY: Float? 95 | 96 | // number 97 | var numberColor: String? 98 | var numberFontSize: Int? 99 | 100 | var numberFrameOffsetX: Float? 101 | var numberFrameOffsetY: Float? 102 | 103 | // login button 104 | var loginBtnText: String? 105 | var loginBtnTextColor: String? 106 | var loginBtnTextSize: Int? 107 | 108 | var loginBtnNormalImage: String? 109 | var loginBtnUnableImage: String? 110 | var loginBtnPressedImage: String? 111 | 112 | var loginBtnFrameOffsetX: Float? 113 | var loginBtnFrameOffsetY: Float? 114 | 115 | var loginBtnWidth: Float? 116 | var loginBtnHeight: Float? 117 | 118 | var loginBtnLRPadding: Float? 119 | 120 | // change button 121 | var changeBtnIsHidden: Bool? 122 | var changeBtnTitle: String? 123 | var changeBtnTextColor: String? 124 | var changeBtnTextSize: Int? 125 | var changeBtnFrameOffsetX: Float? 126 | var changeBtnFrameOffsetY: Float? 127 | 128 | // checkBox 129 | var checkBoxIsChecked: Bool? 130 | var checkBoxIsHidden: Bool? 131 | var checkBoxWH: Float? 132 | 133 | var checkedImage: String? 134 | var uncheckImage: String? 135 | 136 | // priavacy 137 | var privacyOneName: String? 138 | var privacyOneUrl: String? 139 | var privacyTwoName: String? 140 | var privacyTwoUrl: String? 141 | var privacyThreeName: String? 142 | var privacyThreeUrl: String? 143 | 144 | var privacyFontSize: Int? 145 | var privacyFontColor: String? 146 | 147 | var privacyFrameOffsetX: Float? 148 | var privacyFrameOffsetY: Float? 149 | 150 | var privacyConnectTexts: String? 151 | 152 | var privacyPreText: String? 153 | var privacySufText: String? 154 | 155 | var privacyOperatorPreText: String? 156 | 157 | var privacyOperatorSufText: String? 158 | 159 | var privacyOperatorIndex: Int? 160 | 161 | var customViewBlockList: [CustomViewBlock]? 162 | } 163 | 164 | struct CustomViewBlock: Codable { 165 | var viewId: Int? 166 | var text: String? 167 | var textColor: String? 168 | var textSize: Double? 169 | var backgroundColor: String? 170 | var image: String? 171 | var offsetX: Double? 172 | var offsetY: Double? 173 | var width: Double? 174 | var height: Double? 175 | var enableTap: Bool? 176 | } 177 | 178 | -------------------------------------------------------------------------------- /ios/Classes/Model/ResponseModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponseModel.swift 3 | // ali_auth 4 | // 5 | // Created by kangkang on 2022/9/30. 6 | // 7 | 8 | import ATAuthSDK 9 | import Foundation 10 | 11 | struct ResponseModel: Codable { 12 | var resultCode: String? 13 | var msg: String? 14 | var requestId: String? 15 | var token: String? 16 | var innerMsg: String? 17 | var innerCode: String? 18 | 19 | // {msg: AppID、Appkey解析成功, resultCode: 600000, requestId: 481a2c9b50264cf3} 20 | init(_ data: [String: Any]) { 21 | self.resultCode = data["resultCode"] as? String 22 | self.msg = data["msg"] as? String 23 | self.requestId = data["requestId"] as? String 24 | self.token = data["token"] as? String 25 | self.innerMsg = data["innerMsg"] as? String 26 | self.innerCode = data["innerCode"] as? String 27 | // if let carrierFailedResultData = data["carrierFailedResultData"] { 28 | // self.carrierFailedResultData = carrierFailedResultData 29 | // } 30 | } 31 | 32 | init(_ data: [AnyHashable: Any]?) { 33 | self.resultCode = data?["resultCode"] as? String 34 | self.msg = data?["msg"] as? String 35 | self.requestId = data?["requestId"] as? String 36 | self.token = data?["token"] as? String 37 | self.innerMsg = data?["innerMsg"] as? String 38 | self.innerCode = data?["innerCode"] as? String 39 | } 40 | 41 | init(id: String?, code: String?, msg: String) { 42 | self.requestId = id ?? Date().timeStamp 43 | self.resultCode = code ?? PNSCodeSuccess 44 | self.msg = msg 45 | } 46 | 47 | init(code: String?, msg: String) { 48 | self.requestId = Date().timeStamp 49 | self.resultCode = code ?? PNSCodeSuccess 50 | self.msg = msg 51 | } 52 | 53 | init(msg: String) { 54 | self.requestId = Date().timeStamp 55 | self.resultCode = "600000" 56 | self.msg = msg 57 | } 58 | 59 | var json: [String: Any] { 60 | 61 | let jsonObject = try? JSONSerialization.jsonObject(with: JSONEncoder().encode(self)) 62 | return jsonObject as? [String: Any] ?? [:] 63 | } 64 | } 65 | 66 | extension Date { 67 | var timeStamp: String { 68 | let timeInterval: TimeInterval = self.timeIntervalSince1970 69 | return String(timeInterval).replacingOccurrences(of: ".", with: "") 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ios/Classes/Utils/ColorExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorExtension.swift 3 | // ali_auth 4 | // 5 | // Created by kangkang on 2022/9/29. 6 | // 7 | 8 | import Foundation 9 | 10 | extension String { 11 | /// 十六进制字符串颜色转为UIColor 12 | /// - Parameter alpha: 透明度 13 | func uicolor(alpha: CGFloat = 1.0) -> UIColor { 14 | // 存储转换后的数值 15 | var red: UInt64 = 0, green: UInt64 = 0, blue: UInt64 = 0 16 | var hex = self 17 | // 如果传入的十六进制颜色有前缀,去掉前缀 18 | if hex.hasPrefix("0x") || hex.hasPrefix("0X") { 19 | hex = String(hex[hex.index(hex.startIndex, offsetBy: 2)...]) 20 | } else if hex.hasPrefix("#") { 21 | hex = String(hex[hex.index(hex.startIndex, offsetBy: 1)...]) 22 | } 23 | // 如果传入的字符数量不足6位按照后边都为0处理,当然你也可以进行其它操作 24 | if hex.count < 6 { 25 | for _ in 0..<6 - hex.count { 26 | hex += "0" 27 | } 28 | } 29 | 30 | // 分别进行转换 31 | // 红 32 | Scanner(string: String(hex[.. FlutterViewController? { 14 | let viewController: UIViewController? = window?.rootViewController 15 | if (viewController?.isKind(of: FlutterViewController.self)) != nil { 16 | print("viewController as? FlutterViewController") 17 | return viewController as? FlutterViewController 18 | } else { 19 | print("getCurrentViewController() as? FlutterViewController") 20 | return getCurrentViewController() as? FlutterViewController 21 | } 22 | } 23 | 24 | // MARK: - 在view上添加UIViewController,查找当前的ViewController 25 | 26 | static func getCurrentViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? { 27 | if let nav = base as? UINavigationController { 28 | return getCurrentViewController(base: nav.visibleViewController) 29 | } 30 | if let tab = base as? UITabBarController { 31 | return getCurrentViewController(base: tab.selectedViewController) 32 | } 33 | if let presented = base?.presentedViewController { 34 | return getCurrentViewController(base: presented) 35 | } 36 | return base 37 | } 38 | 39 | // MARK: - 获取视窗 40 | 41 | static var window: UIWindow? { 42 | UIApplication.shared.keyWindow 43 | } 44 | 45 | // MARK: - 获取根视图 46 | 47 | static var getRootViewController: UIViewController? { 48 | // let window: UIWindow? = (UIApplication.shared.delegate?.window)! 49 | 50 | return window?.rootViewController 51 | } 52 | 53 | 54 | //MARK: - 顶部安全区高度 55 | static func xp_safeDistanceTop() -> CGFloat { 56 | if #available(iOS 13.0, *) { 57 | let scene = UIApplication.shared.connectedScenes.first 58 | guard let windowScene = scene as? UIWindowScene else { return 0 } 59 | guard let window = windowScene.windows.first else { return 0 } 60 | return window.safeAreaInsets.top 61 | } else if #available(iOS 11.0, *) { 62 | guard let window = UIApplication.shared.windows.first else { return 0 } 63 | return window.safeAreaInsets.top 64 | } 65 | return 0; 66 | } 67 | 68 | //MARK: - 底部安全区高度 69 | static func xp_safeDistanceBottom() -> CGFloat { 70 | if #available(iOS 13.0, *) { 71 | let scene = UIApplication.shared.connectedScenes.first 72 | guard let windowScene = scene as? UIWindowScene else { return 0 } 73 | guard let window = windowScene.windows.first else { return 0 } 74 | return window.safeAreaInsets.bottom 75 | } else if #available(iOS 11.0, *) { 76 | guard let window = UIApplication.shared.windows.first else { return 0 } 77 | return window.safeAreaInsets.bottom 78 | } 79 | return 0; 80 | } 81 | 82 | //MARK: - 顶部状态栏高度(包括安全区) 83 | static func xp_statusBarHeight() -> CGFloat { 84 | var statusBarHeight: CGFloat = 0 85 | if #available(iOS 13.0, *) { 86 | let scene = UIApplication.shared.connectedScenes.first 87 | guard let windowScene = scene as? UIWindowScene else { return 0 } 88 | guard let statusBarManager = windowScene.statusBarManager else { return 0 } 89 | statusBarHeight = statusBarManager.statusBarFrame.height 90 | } else { 91 | statusBarHeight = UIApplication.shared.statusBarFrame.height 92 | } 93 | return statusBarHeight 94 | } 95 | 96 | //MARK: - 导航栏高度 97 | static func xp_navigationBarHeight() -> CGFloat { 98 | return 44.0 99 | } 100 | 101 | //MARK: - 状态栏+导航栏的高度 102 | static func xp_navigationFullHeight() -> CGFloat { 103 | return xp_statusBarHeight() + xp_navigationBarHeight() 104 | } 105 | 106 | //MARK: - 底部导航栏高度 107 | static func xp_tabBarHeight() -> CGFloat { 108 | return 49.0 109 | } 110 | 111 | //MARK: - 底部导航栏高度(包括安全区) 112 | static func xp_tabBarFullHeight() -> CGFloat { 113 | return xp_tabBarHeight() + xp_safeDistanceBottom() 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /ios/flutter_ali_auth.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_ali_auth.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_ali_auth' 7 | s.version = '0.0.1' 8 | s.summary = 'Flutter Ali Auth Plugin 阿里云一键登录Flutter插件' 9 | s.description = <<-DESC 10 | Flutter Ali Auth Plugin 阿里云一键登录Flutter插件 11 | DESC 12 | s.homepage = 'https://github.com/fluttercandies/flutter_ali_auth' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'kangkang' => 'kangkanglaile1205@163.com' } 15 | s.source = { :path => '.' } 16 | 17 | s.source_files = 'Classes/**/*' 18 | s.public_header_files = 'Classes/**/*.h' 19 | 20 | s.dependency 'Flutter' 21 | s.dependency 'SDWebImage' 22 | s.dependency 'MJExtension' 23 | s.dependency 'MBProgressHUD' 24 | 25 | s.platform = :ios, '12.0' 26 | 27 | s.vendored_frameworks = 'frameworks/*.framework' 28 | s.framework = 'Network' 29 | s.resource = 'frameworks/ATAuthSDK.framework/ATAuthSDK.bundle' 30 | 31 | s.xcconfig = { 32 | 'OTHER_LDFLAGS' => '-ObjC', 33 | 'ENABLE_BITCODE' => 'NO' 34 | } 35 | 36 | # Flutter.framework does not contain a i386 slice. 37 | # s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 38 | s.pod_target_xcconfig = {'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } 39 | s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } 40 | s.swift_version = '5.0' 41 | end 42 | -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_check@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_check@2x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_check@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_check@3x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_close_gray@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_close_gray@2x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_close_gray@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_close_gray@3x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_gray@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_gray@2x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_gray@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_gray@3x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_light@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_light@2x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_light@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_nav_back_light@3x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_uncheck@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_uncheck@2x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_uncheck@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/ATAuthSDK.bundle/icon_uncheck@3x.png -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Headers/ATAuthSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // ATAuthSDK.h 3 | // ATAuthSDK 4 | // 5 | // Created by yangli on 2020/11/11. 6 | // Copyright © 2020. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ATAuthSDK. 12 | FOUNDATION_EXPORT double ATAuthSDKVersionNumber; 13 | 14 | //! Project version string for ATAuthSDK. 15 | FOUNDATION_EXPORT const unsigned char ATAuthSDKVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | #import "TXCommonHandler.h" 20 | #import "TXCommonUtils.h" 21 | #import "PNSReturnCode.h" 22 | #import "TXCustomModel.h" 23 | #import "PNSReporter.h" 24 | 25 | -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Headers/PNSReporter.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNSReporter.h 3 | // ATAuthSDK 4 | // 5 | // Created by 刘超的MacBook on 2020/5/21. 6 | // Copyright © 2020. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef NS_ENUM(NSInteger, PNSLoggerLevel) { 14 | PNSLoggerLevelVerbose = 1, 15 | PNSLoggerLevelDebug, 16 | PNSLoggerLevelInfo, 17 | PNSLoggerLevelWarn, 18 | PNSLoggerLevelError 19 | }; 20 | 21 | @interface PNSReporter : NSObject 22 | 23 | /** 24 | * 控制台日志输出开关,若开启会以PNS_LOGGER为开始标记对日志进行输出,Release模式记得关闭! 25 | * @param enable 开关参数,默认为NO 26 | */ 27 | - (void)setConsolePrintLoggerEnable:(BOOL)enable; 28 | 29 | /** 30 | * 设置埋点上传开关,但不会对通过 setupUploader: 接口实现的自定义上传方法起作用 31 | * @param enable 开关设置BOOL值,默认为YES 32 | */ 33 | - (void)setUploadEnable:(BOOL)enable DEPRECATED_MSG_ATTRIBUTE("日志不再上传");; 34 | 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Headers/PNSReturnCode.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNSReturnCode.h 3 | // ATAuthSDK 4 | // 5 | // Created by 刘超的MacBook on 2019/9/4. 6 | // Copyright © 2019. All rights reserved. 7 | // 8 | 9 | #ifndef PNSReturnCode_h 10 | #define PNSReturnCode_h 11 | 12 | #import 13 | 14 | #pragma mark - 该返回码为阿里云号码认证SDK⾃身的返回码,请注意600011及600012错误内均含有运营商返回码,具体错误在碰到之后查阅 https://help.aliyun.com/document_detail/85351.html?spm=a2c4g.11186623.6.561.32a7360cxvWk6H 15 | 16 | 17 | /// 接口成功 18 | static NSString * const PNSCodeSuccess = @"600000"; 19 | /// 获取运营商配置信息失败 20 | static NSString * const PNSCodeGetOperatorInfoFailed = @"600004"; 21 | /// 未检测到sim卡 22 | static NSString * const PNSCodeNoSIMCard = @"600007"; 23 | /// 蜂窝网络未开启或不稳定 24 | static NSString * const PNSCodeNoCellularNetwork = @"600008"; 25 | /// 无法判运营商 26 | static NSString * const PNSCodeUnknownOperator = @"600009"; 27 | /// 未知异常 28 | static NSString * const PNSCodeUnknownError = @"600010"; 29 | /// 获取token失败 30 | static NSString * const PNSCodeGetTokenFailed = @"600011"; 31 | /// 预取号失败 32 | static NSString * const PNSCodeGetMaskPhoneFailed = @"600012"; 33 | /// 运营商维护升级,该功能不可用 34 | static NSString * const PNSCodeInterfaceDemoted = @"600013"; 35 | /// 运营商维护升级,该功能已达最大调用次数 36 | static NSString * const PNSCodeInterfaceLimited = @"600014"; 37 | /// 接口超时 38 | static NSString * const PNSCodeInterfaceTimeout = @"600015"; 39 | /// AppID、Appkey解析失败 40 | static NSString * const PNSCodeDecodeAppInfoFailed = @"600017"; 41 | /// 该号码已被运营商管控,目前只有联通号码有该功能 42 | static NSString * const PNSCodePhoneBlack = @"600018"; 43 | /// 运营商已切换 44 | static NSString * const PNSCodeCarrierChanged = @"600021"; 45 | /// 终端环境检测失败(终端不支持认证 / 终端检测参数错误) 46 | static NSString * const PNSCodeEnvCheckFail = @"600025"; 47 | 48 | /*************** 号码认证授权页相关返回码 START ***************/ 49 | 50 | /// 唤起授权页成功 51 | static NSString * const PNSCodeLoginControllerPresentSuccess = @"600001"; 52 | /// 唤起授权页失败 53 | static NSString * const PNSCodeLoginControllerPresentFailed = @"600002"; 54 | /// 授权页已加载时不允许调用加速或预取号接口 55 | static NSString * const PNSCodeCallPreLoginInAuthPage = @"600026"; 56 | /// 点击返回,⽤户取消一键登录 57 | static NSString * const PNSCodeLoginControllerClickCancel = @"700000"; 58 | /// 点击切换按钮,⽤户取消免密登录 59 | static NSString * const PNSCodeLoginControllerClickChangeBtn = @"700001"; 60 | /// 点击登录按钮事件 61 | static NSString * const PNSCodeLoginControllerClickLoginBtn = @"700002"; 62 | /// 点击CheckBox事件 63 | static NSString * const PNSCodeLoginControllerClickCheckBoxBtn = @"700003"; 64 | /// 点击协议富文本文字 65 | static NSString * const PNSCodeLoginControllerClickProtocol = @"700004"; 66 | /// 中断页面消失的时候,也就是suspendDisMissVC设置为YES的时候,点击左上角返回按钮时透出的状态码 67 | static NSString * const PNSCodeLoginControllerSuspendDisMissVC = @"700010"; 68 | 69 | /*************** 号码认证授权页相关返回码 FINISH ***************/ 70 | 71 | 72 | /*************** 二次授权页返回code码 START ***************/ 73 | 74 | /// 点击一键登录拉起授权页二次弹窗 75 | static NSString * const PNSCodeLoginClickPrivacyAlertView = @"700006"; 76 | /// 隐私协议二次弹窗关闭 77 | static NSString * const PNSCodeLoginPrivacyAlertViewClose = @"700007"; 78 | /// 隐私协议二次弹窗点击确认并继续 79 | static NSString * const PNSCodeLoginPrivacyAlertViewClickContinue = @"700008"; 80 | /// 点击隐私协议二次弹窗上的协议富文本文字 81 | static NSString * const PNSCodeLoginPrivacyAlertViewPrivacyContentClick = @"700009"; 82 | 83 | /*************** 二次授权页返回code码 FINISH ***************/ 84 | 85 | 86 | #endif /* PNSReturnCode_h */ 87 | -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Headers/TXCommonHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // TXCommonHandler.h 3 | // ATAuthSDK 4 | // 5 | // Created by yangli on 15/03/2018. 6 | 7 | #import 8 | #import "TXCustomModel.h" 9 | #import "PNSReporter.h" 10 | 11 | typedef NS_ENUM(NSInteger, PNSAuthType) { 12 | PNSAuthTypeVerifyToken = 1, //本机号码校验 13 | PNSAuthTypeLoginToken = 2 //一键登录 14 | }; 15 | 16 | @interface TXCommonHandler : NSObject 17 | 18 | /** 19 | * 获取该类的单例实例对象 20 | * @return 单例实例对象 21 | */ 22 | + (instancetype _Nonnull )sharedInstance; 23 | 24 | /** 25 | * 获取当前SDK版本号 26 | * @return 字符串,sdk版本号 27 | */ 28 | - (NSString *_Nonnull)getVersion; 29 | 30 | /** 31 | * 初始化SDK调用参数,app生命周期内调用一次 32 | * @param info app对应的秘钥 33 | * @param complete 结果异步回调到主线程,成功时resultDic=@{resultCode:600000, msg:...},其他情况时"resultCode"值请参考PNSReturnCode 34 | */ 35 | - (void)setAuthSDKInfo:(NSString * _Nonnull)info complete:(void(^_Nullable)(NSDictionary * _Nonnull resultDic))complete; 36 | 37 | /** 38 | * 检查当前环境是否支持一键登录或号码认证,resultDic 返回 PNSCodeSuccess 说明当前环境支持 39 | * @param authType 服务类型 PNSAuthTypeVerifyToken 本机号码校验流程,PNSAuthTypeLoginToken 一键登录流程 40 | * @param complete 结果异步回调到主线程,成功时resultDic=@{resultCode:600000, msg:...},其他情况时"resultCode"值请参考PNSReturnCode,只有成功回调才能保障后续接口调用 41 | */ 42 | - (void)checkEnvAvailableWithAuthType:(PNSAuthType)authType complete:(void (^_Nullable)(NSDictionary * _Nullable resultDic))complete; 43 | 44 | /** 45 | * 加速获取本机号码校验token,防止调用 getVerifyTokenWithTimeout:complete: 获取token时间过长 46 | * @param timeout 接口超时时间,单位s,默认为3.0s 47 | * @param complete 结果异步回调到主线程,成功时resultDic=@{resultCode:600000, token:..., msg:...},其他情况时"resultCode"值请参考PNSReturnCode 48 | */ 49 | - (void)accelerateVerifyWithTimeout:(NSTimeInterval)timeout complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete; 50 | 51 | /** 52 | * 获取本机号码校验Token 53 | * @param timeout 接口超时时间,单位s,默认为3.0s 54 | * @param complete 结果异步回调到主线程,成功时resultDic=@{resultCode:600000, token:..., msg:...},其他情况时"resultCode"值请参考PNSReturnCode 55 | */ 56 | - (void)getVerifyTokenWithTimeout:(NSTimeInterval)timeout complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete; 57 | 58 | /** 59 | * 加速一键登录授权页弹起,防止调用 getLoginTokenWithTimeout:controller:model:complete: 等待弹起授权页时间过长 60 | * @param timeout 接口超时时间,单位s,默认为3.0s 61 | * @param complete 结果异步回调到主线程,成功时resultDic=@{resultCode:600000, msg:...},其他情况时"resultCode"值请参考PNSReturnCode 62 | */ 63 | - (void)accelerateLoginPageWithTimeout:(NSTimeInterval)timeout complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete; 64 | 65 | /** 66 | * 获取一键登录Token,调用该接口首先会弹起授权页,点击授权页的登录按钮获取Token 67 | * @warning 注意的是,如果前面没有调用 accelerateLoginPageWithTimeout:complete: 接口,该接口内部会自动先帮我们调用,成功后才会弹起授权页,所以有一个明显的等待过程 68 | * @param timeout 接口超时时间,单位s,默认为3.0s 69 | * @param controller 唤起自定义授权页的容器,内部会对其进行验证,检查是否符合条件 70 | * @param model 自定义授权页面选项,可为nil,采用默认的授权页面,具体请参考TXCustomModel.h文件 71 | * @param complete 结果异步回调到主线程,"resultDic"里面的"resultCode"值请参考PNSReturnCode,如下: 72 | * 73 | * 授权页控件点击事件:700000(点击授权页返回按钮)、700001(点击切换其他登录方式)、 74 | * 700002(点击登录按钮事件,根据返回字典里面的 "isChecked"字段来区分check box是否被选中,只有被选中的时候内部才会去获取Token)、700003(点击check box事件)、700004(点击协议富文本文字) 75 | 接口回调其他事件:600001(授权页唤起成功)、600002(授权页唤起失败)、600000(成功获取Token)、600011(获取Token失败)、 76 | * 600015(获取Token超时)、600013(运营商维护升级,该功能不可用)、600014(运营商维护升级,该功能已达最大调用次数)..... 77 | */ 78 | - (void)getLoginTokenWithTimeout:(NSTimeInterval)timeout controller:(UIViewController *_Nonnull)controller model:(TXCustomModel *_Nullable)model complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete; 79 | 80 | /** 81 | * 此接口仅用于开发期间用于一键登录页面不同机型尺寸适配调试(可支持模拟器),非正式页面,手机掩码为0,不能正常登录,请开发者注意下 82 | * @param controller 唤起自定义授权页的容器,内部会对其进行验证,检查是否符合条件 83 | * @param model 自定义授权页面选项,可为nil,采用默认的授权页面,具体请参考TXCustomModel.h文件 84 | * @param complete 结果异步回调到主线程,"resultDic"里面的"resultCode"值请参考PNSReturnCode 85 | */ 86 | - (void)debugLoginUIWithController:(UIViewController *_Nonnull)controller model:(TXCustomModel *_Nullable)model complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete; 87 | 88 | /** 89 | * 授权页弹起后,修改checkbox按钮选中状态,当checkout按钮隐藏时,设置不生效 90 | */ 91 | - (void)setCheckboxIsChecked:(BOOL)isChecked; 92 | 93 | /** 94 | * 手动隐藏一键登录获取登录Token之后的等待动画,默认为自动隐藏,当设置 TXCustomModel 实例 autoHideLoginLoading = NO 时, 可调用该方法手动隐藏 95 | */ 96 | - (void)hideLoginLoading; 97 | 98 | /** 99 | * 注销授权页,建议用此方法,对于移动卡授权页的消失会清空一些数据 100 | * @param flag 是否添加动画 101 | * @param complete 成功返回 102 | */ 103 | - (void)cancelLoginVCAnimated:(BOOL)flag complete:(void (^_Nullable)(void))complete; 104 | 105 | /** 106 | * 获取日志埋点相关控制对象 107 | */ 108 | - (PNSReporter * _Nonnull)getReporter; 109 | 110 | /** 111 | 关闭二次授权弹窗页 112 | */ 113 | - (void)closePrivactAlertView; 114 | 115 | 116 | 117 | /** 118 | * 检查及准备调用环境,resultDic返回PNSCodeSuccess才能调用下面的功能接口 119 | * @param complete 结果异步回调到主线程,成功时resultDic=@{resultCode:600000, msg:...},其他情况时"resultCode"值请参考PNSReturnCode,只有成功回调才能保障后续接口调用 120 | */ 121 | - (void)checkEnvAvailableWithComplete:(void (^_Nullable)(NSDictionary * _Nullable resultDic))complete DEPRECATED_MSG_ATTRIBUTE("Please use checkEnvAvailableWithAuthType:complete: instead"); 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Headers/TXCommonUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // TXCommonUtils.h 3 | // authsdk 4 | // 5 | // Created by yangli on 12/03/2018. 6 | 7 | #import 8 | 9 | @interface TXCommonUtils : NSObject 10 | 11 | /** 12 | 判断当前设备蜂窝数据网络是否开启,即3G/4G 13 | @return 结果 14 | */ 15 | + (BOOL)checkDeviceCellularDataEnable; 16 | 17 | /** 18 | 判断当前上网卡运营商是否是中国联通 19 | @return 结果 20 | */ 21 | + (BOOL)isChinaUnicom; 22 | 23 | /** 24 | 判断当前上网卡运营商是否是中国移动 25 | @return 结果 26 | */ 27 | + (BOOL)isChinaMobile; 28 | 29 | /** 30 | 判断当前上网卡运营商是否是中国电信 31 | @return 结果 32 | */ 33 | + (BOOL)isChinaTelecom; 34 | 35 | /** 36 | 获取当前上网卡运营商名称,比如中国移动、中国电信、中国联通 37 | @return 结果 38 | */ 39 | + (NSString *)getCurrentCarrierName; 40 | 41 | /** 42 | 获取当前上网卡网络类型,比如WiFi,4G 43 | @return 结果 44 | */ 45 | + (NSString *)getNetworktype; 46 | 47 | /** 48 | 判断当前设备是否有SIM卡 49 | @return 结果 50 | */ 51 | + (BOOL)simSupportedIsOK; 52 | 53 | /** 54 | 判断wwan是否开着(通过p0网卡判断,无wifi或有wifi情况下都能检测到) 55 | @return 结果 56 | */ 57 | + (BOOL)isWWANOpen; 58 | 59 | /** 60 | 判断wwan是否开着(仅无wifi情况下) 61 | @return 结果 62 | */ 63 | + (BOOL)reachableViaWWAN; 64 | 65 | /** 66 | 获取设备当前网络私网IP地址 67 | @return 结果 68 | */ 69 | + (NSString *)getMobilePrivateIPAddress:(BOOL)preferIPv4; 70 | 71 | /** 72 | 获取当前设备的唯一标识ID 73 | */ 74 | + (NSString *)getUniqueID; 75 | 76 | /** 77 | 通过颜色设置生成图片,支持弧度设置,比如一键登录按钮背景图片 78 | */ 79 | + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size isRoundedCorner:(BOOL )isRounded radius:(CGFloat)radius; 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/ATAuthSDK.framework/Info.plist -------------------------------------------------------------------------------- /ios/frameworks/ATAuthSDK.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module ATAuthSDK { 2 | umbrella header "ATAuthSDK.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Headers/ACMLogger.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | NS_ASSUME_NONNULL_BEGIN 5 | 6 | /// 日志级别 7 | extern NSString * const ACM_LOGGER_LEVEL_VERBOSE; 8 | extern NSString * const ACM_LOGGER_LEVEL_DEBUG; 9 | extern NSString * const ACM_LOGGER_LEVEL_INFO; 10 | extern NSString * const ACM_LOGGER_LEVEL_WARN; 11 | extern NSString * const ACM_LOGGER_LEVEL_ERROR; 12 | extern NSString * const ACM_LOGGER_LEVEL_REALTIME; 13 | 14 | @interface ACMLogger : NSObject 15 | 16 | - (instancetype)init NS_UNAVAILABLE; 17 | 18 | /// 日志是否入库,默认不入库 19 | @property (nonatomic, assign) BOOL enterDatabase;; 20 | 21 | /// 日志是否允许上传,默认不上传 22 | @property (nonatomic, assign) BOOL isAllowUpload; 23 | 24 | /** 25 | * 日志入库 26 | * @param obj 日志的具体内容 27 | * @param level 日志等级 28 | */ 29 | - (BOOL)logger:(id)obj level:(NSString *)level ; 30 | 31 | /** 32 | * 上传日志 33 | * @param startDate 日志开始时间,如果传nil则查询不加该条件 34 | * @param endDate 日志结束时间,如果传nil则查询不加该条件 35 | * @param levels 日志等级数组,里面包含对应的日志等级字符串,如果传nil则查询不加该条件 36 | */ 37 | - (void)uploadLoggersWithLevels:(NSArray * _Nullable)levels 38 | startDate:(NSDate * _Nullable)startDate 39 | endDate:(NSDate * _Nullable)endDate; 40 | 41 | /** 42 | * 上传失败的日志,一般放在重启应用后 43 | */ 44 | - (void)uploadFailedRecords; 45 | 46 | @end 47 | 48 | NS_ASSUME_NONNULL_END 49 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Headers/ACMManager.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | #import "ACMLogger.h" 4 | #import "ACMMonitor.h" 5 | #import "ACMProtocol.h" 6 | 7 | NS_ASSUME_NONNULL_BEGIN 8 | 9 | @interface ACMManager : NSObject 10 | 11 | /// 日志操作对象 12 | @property (nonatomic, strong, readonly) ACMLogger *logger; 13 | 14 | /// 埋点操作对象 15 | @property (nonatomic, strong, readonly) ACMMonitor *monitor; 16 | 17 | - (instancetype)init NS_UNAVAILABLE; 18 | 19 | /** 20 | * 初始化 21 | * @param databaseName 数据库名,不指定则默认为 “ACMDatabase” 22 | * @param monitorTableName 埋点表名,必须要指定,用来区分不同产品数据 23 | * @param loggerTablename 日志表名,必须要指定,用来区分不同产品数据 24 | * @param limitKeyPrefix 限流信息存储到本地key的前缀,用来区分不同产品的限流缓存 25 | */ 26 | - (instancetype)initWithDatabaseName:(NSString * _Nullable)databaseName 27 | monitorTableName:(NSString *)monitorTableName 28 | loggerTableName:(NSString *)loggerTablename 29 | limitKeyPrefix:(NSString *)limitKeyPrefix; 30 | 31 | /** 32 | * 获取组件当前版本号 33 | */ 34 | - (NSString *)getVersion; 35 | 36 | /** 37 | * 设置日志埋点上传代理对象 38 | * 注:这里是强引用 39 | * @param uploadDelegate 代理对象,需要实现 ACMProtocol 协议 40 | */ 41 | - (void)setUploadDelegate:(id _Nullable)uploadDelegate; 42 | 43 | /** 44 | * 更新限流相关 45 | * @param isLimit 是否限流 46 | * @param limitTimeHour 限流区间大小 47 | * @param limitCount 区间内限流次数 48 | */ 49 | - (void)updateLimitConfig:(BOOL)isLimit 50 | limitTimeHour:(NSInteger)limitTimeHour 51 | limitCount:(NSInteger)limitCount; 52 | 53 | @end 54 | 55 | NS_ASSUME_NONNULL_END 56 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Headers/ACMMonitor.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | NS_ASSUME_NONNULL_BEGIN 5 | 6 | @interface ACMMonitor : NSObject 7 | 8 | - (instancetype)init NS_UNAVAILABLE; 9 | 10 | /// 埋点是否入库,默认入库 11 | @property (nonatomic, assign) BOOL enterDatabase;; 12 | 13 | /// 埋点是否允许上传,默认上传 14 | @property (nonatomic, assign) BOOL isAllowUpload; 15 | 16 | /** 17 | * 非实时埋点入库 18 | * @param obj 埋点具体内容 19 | */ 20 | - (BOOL)monitor:(id)obj; 21 | 22 | /** 23 | * 实时埋点入库 24 | * @param obj 埋点的具体内容 25 | */ 26 | - (BOOL)monitorRealtime:(id)obj; 27 | 28 | /** 29 | * 手动触发埋点上传,只上传未上传过的埋点 30 | */ 31 | - (void)uploadMonitorByManual; 32 | 33 | /** 34 | * 上传失败的埋点,一般放在重启应用后 35 | */ 36 | - (void)uploadFailedRecords; 37 | 38 | @end 39 | 40 | NS_ASSUME_NONNULL_END 41 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Headers/ACMProtocol.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | NS_ASSUME_NONNULL_BEGIN 5 | 6 | @protocol ACMProtocol 7 | 8 | @required 9 | 10 | /// 埋点抛出,可在抛出里面进行上传 11 | - (BOOL)uploadMonitors:(NSArray *)monitors; 12 | /// 日志抛出,可在抛出里面进行上传 13 | - (BOOL)uploadLoggers:(NSArray *)loggers; 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Headers/YTXMonitor.h: -------------------------------------------------------------------------------- 1 | 2 | #import "ACMManager.h" 3 | #import "ACMProtocol.h" 4 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/YTXMonitor.framework/Info.plist -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module YTXMonitor { 2 | umbrella header "YTXMonitor.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ios/frameworks/YTXMonitor.framework/YTXMonitor: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/YTXMonitor.framework/YTXMonitor -------------------------------------------------------------------------------- /ios/frameworks/YTXOperators.framework/Headers/YTXNetUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // YTXNetUtils.h 3 | // YTXOperators 4 | // 5 | // Created by yangli on 2020/11/9. 6 | // Copyright © 2020 com.alicom. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YTXNetUtils : NSObject 14 | 15 | /** 16 | 判断当前设备蜂窝数据网络是否开启,即3G/4G 17 | @return 结果 18 | */ 19 | - (BOOL)checkDeviceCellularDataEnable; 20 | 21 | /** 22 | 判断当前上网卡运营商是否是中国联通 23 | @return 结果 24 | */ 25 | - (BOOL)isChinaUnicom; 26 | 27 | /** 28 | 判断当前上网卡运营商是否是中国移动 29 | @return 结果 30 | */ 31 | - (BOOL)isChinaMobile; 32 | 33 | /** 34 | 判断当前上网卡运营商是否是中国电信 35 | @return 结果 36 | */ 37 | - (BOOL)isChinaTelecom; 38 | 39 | /** 40 | 获取当前上网卡运营商名称,比如中国移动、中国电信、中国联通 41 | @return 结果 42 | */ 43 | - (NSString *)getCurrentCarrierName; 44 | 45 | /** 46 | 获取当前上网卡运营商编码,比如46000、46001、46003 47 | @return 结果 48 | */ 49 | - (NSString *)getCurrentCarrierCode API_DEPRECATED("废弃,完成不可用,返回空字符串", ios(4.0, 16.0)); 50 | 51 | /** 52 | 获取当前上网卡网络类型,比如WiFi,4G 53 | @return 结果 54 | */ 55 | - (NSString *)getNetworktype; 56 | 57 | /** 58 | 判断当前设备是否有SIM卡 59 | @return 结果 60 | */ 61 | - (BOOL)simSupportedIsOK; 62 | 63 | /** 64 | 判断wwan是否开着(通过p0网卡判断,无wifi或有wifi情况下都能检测到) 65 | @return 结果 66 | */ 67 | - (BOOL)isWWANOpen; 68 | 69 | /** 70 | 判断WiFi是否开着 71 | @return 结果 72 | */ 73 | - (BOOL)isWiFiOpen; 74 | 75 | /** 76 | 判断wwan是否开着(仅无wifi情况下) 77 | @return 结果 78 | */ 79 | - (BOOL)reachableViaWWAN; 80 | 81 | /** 82 | 获取设备当前网络私网IP地址 83 | @return 结果 84 | */ 85 | - (NSString *)getMobilePrivateIPAddress:(BOOL)preferIPv4; 86 | 87 | /** 88 | 获取双卡设备下,非上网卡信息 89 | @return 结果 90 | */ 91 | - (NSString *)getOptionalCarrierInfo API_DEPRECATED("废弃,完成不可用,返回空字符串", ios(4.0, 16.0));; 92 | 93 | /** 94 | 获取当前蜂网络Ip地址 95 | */ 96 | - (NSString *)getCellularIp; 97 | 98 | @end 99 | 100 | NS_ASSUME_NONNULL_END 101 | -------------------------------------------------------------------------------- /ios/frameworks/YTXOperators.framework/Headers/YTXOperators.h: -------------------------------------------------------------------------------- 1 | // 2 | // YTXOperators.h 3 | // YTXOperators 4 | // 5 | // Created by yangli on 2020/11/9. 6 | // Copyright © 2020 com.alicom. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for YTXOperators. 12 | FOUNDATION_EXPORT double YTXOperatorsVersionNumber; 13 | 14 | //! Project version string for YTXOperators. 15 | FOUNDATION_EXPORT const unsigned char YTXOperatorsVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | #import "YTXVendorService.h" 20 | #import "YTXNetUtils.h" 21 | -------------------------------------------------------------------------------- /ios/frameworks/YTXOperators.framework/Headers/YTXVendorService.h: -------------------------------------------------------------------------------- 1 | // 2 | // YTXVendorService.h 3 | // ATAuthSDK 4 | // 5 | // Created by 刘超的MacBook on 2020/1/15. 6 | // Copyright © 2020. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface YTXRequest : NSObject 14 | /// 接口调用超时时间,注:目前内部限制最小超时时间为5s,小于5s则按5s设置 15 | @property (nonatomic, assign) NSTimeInterval timeout; 16 | /// 是否是蜂窝网络 17 | @property (nonatomic, assign) BOOL isReachableViaWWAN; 18 | @end 19 | 20 | @interface YTXVendorConfig : NSObject 21 | /// 当前供应商标识:中移互联(cm_zyhl),小沃联通(cu_xw),电信世纪龙(ct_sjl) 22 | @property (nonatomic, copy) NSString *vendorKey; 23 | /// 供应商 access id 24 | @property (nonatomic, copy) NSString *vendorAccessId; 25 | /// 供应商 access secret 26 | @property (nonatomic, copy) NSString *vendorAccessSecret; 27 | @end 28 | 29 | @interface YTXVendorService : NSObject 30 | 31 | /** 32 | * 获取SDK版本号 33 | */ 34 | + (NSString *)getVersion; 35 | 36 | /** 37 | * 获取供应商SDK版本号 38 | */ 39 | + (NSDictionary *)getVendorsVersion; 40 | 41 | /** 42 | * 初始化或更新各个供应商的接口调用对象,根据各个供应商的配置信息 43 | * @param vendorConfigs 各个供应商配置信息 44 | */ 45 | - (void)updateVendorHandlers:(NSArray *)vendorConfigs; 46 | 47 | /** 48 | * 获取本机号码校验Token 49 | * @param request 请求参数结构体 50 | * @param vendorConfig 当前供应商配置信息 51 | * @param complete 结果回调 52 | */ 53 | - (void)getVerifyTokenWithRequest:(YTXRequest *)request 54 | vendorConfig:(YTXVendorConfig *)vendorConfig 55 | complete:(void(^)(NSDictionary *response))complete; 56 | 57 | /** 58 | * 获取手机掩码 59 | * @param request 请求参数结构体 60 | * @param vendorConfig 当前供应商配置信息 61 | * @param complete 结果回调 62 | */ 63 | - (void)getMaskNumberWithRequest:(YTXRequest *)request 64 | vendorConfig:(YTXVendorConfig *)vendorConfig 65 | complete:(void(^)(NSDictionary *response))complete; 66 | 67 | 68 | /** 69 | * 电信/联通获取一键登录Token 70 | * @param request 请求参数结构体 71 | * @param vendorConfig 当前供应商配置信息 72 | * @param complete 结果回调 73 | * @abstract 移动的获取登录Token不走这个回调,走弹起授权页的回调 74 | */ 75 | - (void)getLoginTokenWithRequest:(YTXRequest *)request 76 | vendorConfig:(YTXVendorConfig *)vendorConfig 77 | complete:(void(^)(NSDictionary *response))complete; 78 | 79 | - (void)deleteCacheWithVendorConfigs:(NSArray *)vendorConfigs; 80 | 81 | @end 82 | 83 | NS_ASSUME_NONNULL_END 84 | -------------------------------------------------------------------------------- /ios/frameworks/YTXOperators.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/YTXOperators.framework/Info.plist -------------------------------------------------------------------------------- /ios/frameworks/YTXOperators.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module YTXOperators { 2 | umbrella header "YTXOperators.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ios/frameworks/YTXOperators.framework/YTXOperators: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/flutter_ali_auth/65a0891b1e648b246a9e0aef00fe23503dc0bb3d/ios/frameworks/YTXOperators.framework/YTXOperators -------------------------------------------------------------------------------- /lib/flutter_ali_auth.dart: -------------------------------------------------------------------------------- 1 | library flutter_ali_auth; 2 | 3 | export 'src/auth_config/alert_ui_config.dart'; 4 | export 'src/auth_config/auth_config.dart'; 5 | export 'src/auth_config/auth_ui_config.dart'; 6 | export 'src/auth_config/full_screen_ui_config.dart'; 7 | export 'src/auth_config/part_ui_config.dart'; 8 | export 'src/auth_response_model/auth_response_model.dart'; 9 | export 'src/auth_response_model/auth_result_code.dart'; 10 | export 'src/internal/ali_auth_client.dart'; 11 | -------------------------------------------------------------------------------- /lib/src/auth_config/alert_ui_config.dart: -------------------------------------------------------------------------------- 1 | import '../auth_config/part_ui_config.dart'; 2 | import 'auth_ui_config.dart'; 3 | 4 | part 'alert_ui_config.g.dart'; 5 | 6 | class AlertUIConfig extends AuthUIConfig { 7 | const AlertUIConfig({ 8 | this.alertTitleBarConfig, 9 | this.alertContentViewColor, 10 | this.alertBlurViewColor, 11 | this.alertBlurViewAlpha, 12 | this.alertBorderRadius, 13 | this.alertBorderWidth, 14 | this.alertBorderColor, 15 | this.alertWindowHeight, 16 | this.alertWindowWidth, 17 | super.logoConfig, 18 | super.sloganConfig, 19 | super.phoneNumberConfig, 20 | super.loginButtonConfig, 21 | super.changeButtonConfig, 22 | super.checkBoxConfig, 23 | super.privacyConfig, 24 | }); 25 | 26 | final AlertTitleBarConfig? alertTitleBarConfig; 27 | 28 | ///十六进制的颜色 29 | final String? alertContentViewColor; 30 | 31 | ///底部蒙层背景颜色,默认黑色 32 | final String? alertBlurViewColor; 33 | 34 | ///底部蒙层背景透明度,默认0.5 35 | final double? alertBlurViewAlpha; 36 | 37 | /// 四个角的圆角,默认为10 38 | final double? alertBorderRadius; 39 | 40 | /// 边框宽度,仅Android生效 41 | final double? alertBorderWidth; 42 | 43 | /// 边框颜色,仅Android生效 44 | final String? alertBorderColor; 45 | 46 | /// 宽度 47 | final double? alertWindowWidth; 48 | 49 | /// 高度 50 | final double? alertWindowHeight; 51 | 52 | @override 53 | Map toJson() { 54 | return { 55 | 'alertContentViewColor': alertContentViewColor, 56 | 'alertBlurViewColor': alertBlurViewColor, 57 | 'alertBlurViewAlpha': alertBlurViewAlpha, 58 | 'alertBorderRadius': alertBorderRadius, 59 | 'alertBorderWidth': alertBorderWidth, 60 | 'alertBorderColor': alertBorderColor, 61 | 'alertWindowWidth': alertWindowWidth, 62 | 'alertWindowHeight': alertWindowHeight, 63 | 'customViewBlockList': 64 | customViewBlockList?.map((e) => e.toJson()).toList(growable: false), 65 | ...?alertTitleBarConfig?.toJson(), 66 | ...?logoConfig?.toJson(), 67 | ...?sloganConfig?.toJson(), 68 | ...?phoneNumberConfig?.toJson(), 69 | ...?loginButtonConfig?.toJson(), 70 | ...?changeButtonConfig?.toJson(), 71 | ...?checkBoxConfig?.toJson(), 72 | ...?privacyConfig?.toJson(), 73 | }..removeWhere((key, value) => value == null); 74 | } 75 | 76 | @override 77 | String toString() { 78 | return 'AlertUIConfig${toJson()}'; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/src/auth_config/alert_ui_config.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'alert_ui_config.dart'; 4 | 5 | // ************************************************************************** 6 | // CopyWithGenerator 7 | // ************************************************************************** 8 | 9 | abstract class _$AlertUIConfigCWProxy { 10 | /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. 11 | /// 12 | /// Usage 13 | /// ```dart 14 | /// AlertUIConfig(...).copyWith(id: 12, name: "My name") 15 | /// ```` 16 | AlertUIConfig call({ 17 | double? alertBlurViewAlpha, 18 | String? alertBlurViewColor, 19 | double? alertBorderRadius, 20 | String? alertContentViewColor, 21 | AlertTitleBarConfig? alertTitleBarConfig, 22 | double? alertWindowHeight, 23 | double? alertWindowWidth, 24 | ChangeButtonConfig? changeButtonConfig, 25 | CheckBoxConfig? checkBoxConfig, 26 | LoginButtonConfig? loginButtonConfig, 27 | LogoConfig? logoConfig, 28 | PhoneNumberConfig? phoneNumberConfig, 29 | PrivacyConfig? privacyConfig, 30 | SloganConfig? sloganConfig, 31 | }); 32 | } 33 | 34 | /// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfAlertUIConfig.copyWith(...)`. 35 | class _$AlertUIConfigCWProxyImpl implements _$AlertUIConfigCWProxy { 36 | final AlertUIConfig _value; 37 | 38 | const _$AlertUIConfigCWProxyImpl(this._value); 39 | 40 | @override 41 | 42 | /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. 43 | /// 44 | /// Usage 45 | /// ```dart 46 | /// AlertUIConfig(...).copyWith(id: 12, name: "My name") 47 | /// ```` 48 | AlertUIConfig call({ 49 | Object? alertBlurViewAlpha = const $CopyWithPlaceholder(), 50 | Object? alertBlurViewColor = const $CopyWithPlaceholder(), 51 | Object? alertBorderRadius = const $CopyWithPlaceholder(), 52 | Object? alertContentViewColor = const $CopyWithPlaceholder(), 53 | Object? alertTitleBarConfig = const $CopyWithPlaceholder(), 54 | Object? alertWindowHeight = const $CopyWithPlaceholder(), 55 | Object? alertWindowWidth = const $CopyWithPlaceholder(), 56 | Object? changeButtonConfig = const $CopyWithPlaceholder(), 57 | Object? checkBoxConfig = const $CopyWithPlaceholder(), 58 | Object? loginButtonConfig = const $CopyWithPlaceholder(), 59 | Object? logoConfig = const $CopyWithPlaceholder(), 60 | Object? phoneNumberConfig = const $CopyWithPlaceholder(), 61 | Object? privacyConfig = const $CopyWithPlaceholder(), 62 | Object? sloganConfig = const $CopyWithPlaceholder(), 63 | }) { 64 | return AlertUIConfig( 65 | alertBlurViewAlpha: alertBlurViewAlpha == const $CopyWithPlaceholder() 66 | ? _value.alertBlurViewAlpha 67 | // ignore: cast_nullable_to_non_nullable 68 | : alertBlurViewAlpha as double?, 69 | alertBlurViewColor: alertBlurViewColor == const $CopyWithPlaceholder() 70 | ? _value.alertBlurViewColor 71 | // ignore: cast_nullable_to_non_nullable 72 | : alertBlurViewColor as String?, 73 | alertBorderRadius: alertBorderRadius == const $CopyWithPlaceholder() 74 | ? _value.alertBorderRadius 75 | // ignore: cast_nullable_to_non_nullable 76 | : alertBorderRadius as double?, 77 | alertContentViewColor: 78 | alertContentViewColor == const $CopyWithPlaceholder() 79 | ? _value.alertContentViewColor 80 | // ignore: cast_nullable_to_non_nullable 81 | : alertContentViewColor as String?, 82 | alertTitleBarConfig: 83 | alertTitleBarConfig == const $CopyWithPlaceholder() || 84 | alertTitleBarConfig == null 85 | ? _value.alertTitleBarConfig 86 | // ignore: cast_nullable_to_non_nullable 87 | : alertTitleBarConfig as dynamic, 88 | alertWindowHeight: alertWindowHeight == const $CopyWithPlaceholder() 89 | ? _value.alertWindowHeight 90 | // ignore: cast_nullable_to_non_nullable 91 | : alertWindowHeight as double?, 92 | alertWindowWidth: alertWindowWidth == const $CopyWithPlaceholder() 93 | ? _value.alertWindowWidth 94 | // ignore: cast_nullable_to_non_nullable 95 | : alertWindowWidth as double?, 96 | changeButtonConfig: changeButtonConfig == const $CopyWithPlaceholder() || 97 | changeButtonConfig == null 98 | ? _value.changeButtonConfig 99 | // ignore: cast_nullable_to_non_nullable 100 | : changeButtonConfig as dynamic, 101 | checkBoxConfig: checkBoxConfig == const $CopyWithPlaceholder() || 102 | checkBoxConfig == null 103 | ? _value.checkBoxConfig 104 | // ignore: cast_nullable_to_non_nullable 105 | : checkBoxConfig as dynamic, 106 | loginButtonConfig: loginButtonConfig == const $CopyWithPlaceholder() || 107 | loginButtonConfig == null 108 | ? _value.loginButtonConfig 109 | // ignore: cast_nullable_to_non_nullable 110 | : loginButtonConfig as dynamic, 111 | logoConfig: 112 | logoConfig == const $CopyWithPlaceholder() || logoConfig == null 113 | ? _value.logoConfig 114 | // ignore: cast_nullable_to_non_nullable 115 | : logoConfig as dynamic, 116 | phoneNumberConfig: phoneNumberConfig == const $CopyWithPlaceholder() || 117 | phoneNumberConfig == null 118 | ? _value.phoneNumberConfig 119 | // ignore: cast_nullable_to_non_nullable 120 | : phoneNumberConfig as dynamic, 121 | privacyConfig: 122 | privacyConfig == const $CopyWithPlaceholder() || privacyConfig == null 123 | ? _value.privacyConfig 124 | // ignore: cast_nullable_to_non_nullable 125 | : privacyConfig as dynamic, 126 | sloganConfig: 127 | sloganConfig == const $CopyWithPlaceholder() || sloganConfig == null 128 | ? _value.sloganConfig 129 | // ignore: cast_nullable_to_non_nullable 130 | : sloganConfig as dynamic, 131 | ); 132 | } 133 | } 134 | 135 | extension $AlertUIConfigCopyWith on AlertUIConfig { 136 | /// Returns a callable class that can be used as follows: `instanceOfAlertUIConfig.copyWith(...)`. 137 | // ignore: library_private_types_in_public_api 138 | _$AlertUIConfigCWProxy get copyWith => _$AlertUIConfigCWProxyImpl(this); 139 | } 140 | -------------------------------------------------------------------------------- /lib/src/auth_config/auth_config.dart: -------------------------------------------------------------------------------- 1 | import 'auth_ui_config.dart'; 2 | import 'part_ui_config.dart'; 3 | 4 | //part 'auth_config.g.dart'; 5 | 6 | class AuthConfig { 7 | AuthConfig({ 8 | required this.iosSdk, 9 | required this.androidSdk, 10 | required this.enableLog, 11 | this.authUIStyle = AuthUIStyle.fullScreen, 12 | this.authUIConfig, 13 | }); 14 | 15 | final String iosSdk; 16 | final String androidSdk; 17 | AuthUIStyle authUIStyle; 18 | AuthUIConfig? authUIConfig; 19 | final bool enableLog; 20 | 21 | Map toJson() { 22 | return { 23 | 'iosSdk': iosSdk, 24 | 'androidSdk': androidSdk, 25 | 'enableLog': enableLog, 26 | 'authUIStyle': authUIStyle.index, 27 | ...?authUIConfig?.toJson(), 28 | }..removeWhere((key, value) => value == null); 29 | } 30 | 31 | @override 32 | String toString() { 33 | return 'AuthConfig{iosSdk: $iosSdk, androidSdk: $androidSdk, authUIStyle: $authUIStyle, authUIConfig: $authUIConfig, enableLog: $enableLog}'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/auth_config/auth_config.g.dart: -------------------------------------------------------------------------------- 1 | // // GENERATED CODE - DO NOT MODIFY BY HAND 2 | // 3 | // part of 'auth_config.dart'; 4 | // 5 | // // ************************************************************************** 6 | // // CopyWithGenerator 7 | // // ************************************************************************** 8 | // 9 | // abstract class _$AuthConfigCWProxy { 10 | // /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. 11 | // /// 12 | // /// Usage 13 | // /// ```dart 14 | // /// AuthConfig(...).copyWith(id: 12, name: "My name") 15 | // /// ```` 16 | // AuthConfig call({ 17 | // String? androidSdk, 18 | // AuthUIConfig? authUIConfig, 19 | // AuthUIStyle? authUIStyle, 20 | // String? iosSdk, 21 | // }); 22 | // } 23 | // 24 | // /// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfAuthConfig.copyWith(...)`. 25 | // class _$AuthConfigCWProxyImpl implements _$AuthConfigCWProxy { 26 | // final AuthConfig _value; 27 | // 28 | // const _$AuthConfigCWProxyImpl(this._value); 29 | // 30 | // @override 31 | // 32 | // /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. 33 | // /// 34 | // /// Usage 35 | // /// ```dart 36 | // /// AuthConfig(...).copyWith(id: 12, name: "My name") 37 | // /// ```` 38 | // AuthConfig call({ 39 | // Object? androidSdk = const $CopyWithPlaceholder(), 40 | // Object? authUIConfig = const $CopyWithPlaceholder(), 41 | // Object? authUIStyle = const $CopyWithPlaceholder(), 42 | // Object? iosSdk = const $CopyWithPlaceholder(), 43 | // Object? enableLog = const $CopyWithPlaceholder(), 44 | // }) { 45 | // return AuthConfig( 46 | // androidSdk: 47 | // androidSdk == const $CopyWithPlaceholder() || androidSdk == null 48 | // ? _value.androidSdk 49 | // // ignore: cast_nullable_to_non_nullable 50 | // : androidSdk as String, 51 | // authUIConfig: 52 | // authUIConfig == const $CopyWithPlaceholder() || authUIConfig == null 53 | // ? _value.authUIConfig 54 | // // ignore: cast_nullable_to_non_nullable 55 | // : authUIConfig as AuthUIConfig, 56 | // enableLog: enableLog == const $CopyWithPlaceholder() || enableLog == null 57 | // ? _value.enableLog 58 | // : enableLog as bool, 59 | // authUIStyle: 60 | // authUIStyle == const $CopyWithPlaceholder() || authUIStyle == null 61 | // ? _value.authUIStyle 62 | // // ignore: cast_nullable_to_non_nullable 63 | // : authUIStyle as AuthUIStyle, 64 | // iosSdk: iosSdk == const $CopyWithPlaceholder() || iosSdk == null 65 | // ? _value.iosSdk 66 | // // ignore: cast_nullable_to_non_nullable 67 | // : iosSdk as String, 68 | // ); 69 | // } 70 | // } 71 | // 72 | // extension $AuthConfigCopyWith on AuthConfig { 73 | // /// Returns a callable class that can be used as follows: `instanceOfAuthConfig.copyWith(...)`. 74 | // // ignore: library_private_types_in_public_api 75 | // _$AuthConfigCWProxy get copyWith => _$AuthConfigCWProxyImpl(this); 76 | // } 77 | -------------------------------------------------------------------------------- /lib/src/auth_config/auth_ui_config.dart: -------------------------------------------------------------------------------- 1 | import '../auth_config/part_ui_config.dart'; 2 | 3 | abstract class AuthUIConfig { 4 | const AuthUIConfig({ 5 | this.logoConfig, 6 | this.sloganConfig, 7 | this.phoneNumberConfig, 8 | this.loginButtonConfig, 9 | this.changeButtonConfig, 10 | this.checkBoxConfig, 11 | this.privacyConfig, 12 | this.customViewBlockList, 13 | }); 14 | 15 | final LogoConfig? logoConfig; 16 | final SloganConfig? sloganConfig; 17 | final PhoneNumberConfig? phoneNumberConfig; 18 | final LoginButtonConfig? loginButtonConfig; 19 | final ChangeButtonConfig? changeButtonConfig; 20 | final CheckBoxConfig? checkBoxConfig; 21 | final PrivacyConfig? privacyConfig; 22 | final List? customViewBlockList; 23 | 24 | Map toJson(); 25 | 26 | @override 27 | String toString() { 28 | return 'AuthUIConfig{logoConfig: $logoConfig, sloganConfig: $sloganConfig, phoneNumberConfig: $phoneNumberConfig, loginButtonConfig: $loginButtonConfig, changeButtonConfig: $changeButtonConfig, checkBoxConfig: $checkBoxConfig, privacyConfig: $privacyConfig, customViewBlockList: $customViewBlockList}'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/src/auth_config/full_screen_ui_config.dart: -------------------------------------------------------------------------------- 1 | import '../auth_config/part_ui_config.dart'; 2 | import 'auth_ui_config.dart'; 3 | 4 | part 'full_screen_ui_config.g.dart'; 5 | 6 | class FullScreenUIConfig extends AuthUIConfig { 7 | const FullScreenUIConfig({ 8 | this.navConfig, 9 | this.backgroundImage, 10 | this.backgroundColor, 11 | this.prefersStatusBarHidden = false, 12 | super.logoConfig, 13 | super.sloganConfig, 14 | super.phoneNumberConfig, 15 | super.loginButtonConfig, 16 | super.changeButtonConfig, 17 | super.checkBoxConfig, 18 | super.privacyConfig, 19 | super.customViewBlockList, 20 | }); 21 | 22 | final NavConfig? navConfig; 23 | 24 | ///十六进制的颜色 25 | final String? backgroundColor; 26 | final String? backgroundImage; 27 | 28 | ///状态栏是否隐藏,默认显示 29 | final bool prefersStatusBarHidden; 30 | 31 | @override 32 | Map toJson() { 33 | return { 34 | 'backgroundColor': backgroundColor, 35 | 'backgroundImage': backgroundImage, 36 | 'prefersStatusBarHidden': prefersStatusBarHidden, 37 | 'customViewBlockList': 38 | customViewBlockList?.map((e) => e.toJson()).toList(growable: false), 39 | ...?navConfig?.toJson(), 40 | ...?logoConfig?.toJson(), 41 | ...?sloganConfig?.toJson(), 42 | ...?phoneNumberConfig?.toJson(), 43 | ...?loginButtonConfig?.toJson(), 44 | ...?changeButtonConfig?.toJson(), 45 | ...?checkBoxConfig?.toJson(), 46 | ...?privacyConfig?.toJson(), 47 | }..removeWhere((key, value) => value == null); 48 | } 49 | 50 | @override 51 | String toString() { 52 | return 'FullScreenUIConfig{${toJson()}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/src/auth_config/full_screen_ui_config.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'full_screen_ui_config.dart'; 4 | 5 | // ************************************************************************** 6 | // CopyWithGenerator 7 | // ************************************************************************** 8 | 9 | abstract class _$FullScreenUIConfigCWProxy { 10 | /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. 11 | /// 12 | /// Usage 13 | /// ```dart 14 | /// FullScreenUIConfig(...).copyWith(id: 12, name: "My name") 15 | /// ```` 16 | FullScreenUIConfig call({ 17 | String? backgroundColor, 18 | String? backgroundImage, 19 | ChangeButtonConfig? changeButtonConfig, 20 | CheckBoxConfig? checkBoxConfig, 21 | LoginButtonConfig? loginButtonConfig, 22 | LogoConfig? logoConfig, 23 | NavConfig? navConfig, 24 | PhoneNumberConfig? phoneNumberConfig, 25 | bool? prefersStatusBarHidden, 26 | PrivacyConfig? privacyConfig, 27 | SloganConfig? sloganConfig, 28 | }); 29 | } 30 | 31 | /// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfFullScreenUIConfig.copyWith(...)`. 32 | class _$FullScreenUIConfigCWProxyImpl implements _$FullScreenUIConfigCWProxy { 33 | final FullScreenUIConfig _value; 34 | 35 | const _$FullScreenUIConfigCWProxyImpl(this._value); 36 | 37 | @override 38 | 39 | /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. 40 | /// 41 | /// Usage 42 | /// ```dart 43 | /// FullScreenUIConfig(...).copyWith(id: 12, name: "My name") 44 | /// ```` 45 | FullScreenUIConfig call({ 46 | Object? backgroundColor = const $CopyWithPlaceholder(), 47 | Object? backgroundImage = const $CopyWithPlaceholder(), 48 | Object? changeButtonConfig = const $CopyWithPlaceholder(), 49 | Object? checkBoxConfig = const $CopyWithPlaceholder(), 50 | Object? loginButtonConfig = const $CopyWithPlaceholder(), 51 | Object? logoConfig = const $CopyWithPlaceholder(), 52 | Object? navConfig = const $CopyWithPlaceholder(), 53 | Object? phoneNumberConfig = const $CopyWithPlaceholder(), 54 | Object? prefersStatusBarHidden = const $CopyWithPlaceholder(), 55 | Object? privacyConfig = const $CopyWithPlaceholder(), 56 | Object? sloganConfig = const $CopyWithPlaceholder(), 57 | }) { 58 | return FullScreenUIConfig( 59 | backgroundColor: backgroundColor == const $CopyWithPlaceholder() 60 | ? _value.backgroundColor 61 | // ignore: cast_nullable_to_non_nullable 62 | : backgroundColor as String?, 63 | backgroundImage: backgroundImage == const $CopyWithPlaceholder() 64 | ? _value.backgroundImage 65 | // ignore: cast_nullable_to_non_nullable 66 | : backgroundImage as String?, 67 | changeButtonConfig: changeButtonConfig == const $CopyWithPlaceholder() 68 | ? _value.changeButtonConfig 69 | // ignore: cast_nullable_to_non_nullable 70 | : changeButtonConfig as ChangeButtonConfig?, 71 | checkBoxConfig: checkBoxConfig == const $CopyWithPlaceholder() 72 | ? _value.checkBoxConfig 73 | // ignore: cast_nullable_to_non_nullable 74 | : checkBoxConfig as CheckBoxConfig?, 75 | loginButtonConfig: loginButtonConfig == const $CopyWithPlaceholder() 76 | ? _value.loginButtonConfig 77 | // ignore: cast_nullable_to_non_nullable 78 | : loginButtonConfig as LoginButtonConfig?, 79 | logoConfig: logoConfig == const $CopyWithPlaceholder() 80 | ? _value.logoConfig 81 | // ignore: cast_nullable_to_non_nullable 82 | : logoConfig as LogoConfig?, 83 | navConfig: navConfig == const $CopyWithPlaceholder() 84 | ? _value.navConfig 85 | // ignore: cast_nullable_to_non_nullable 86 | : navConfig as NavConfig?, 87 | phoneNumberConfig: phoneNumberConfig == const $CopyWithPlaceholder() 88 | ? _value.phoneNumberConfig 89 | // ignore: cast_nullable_to_non_nullable 90 | : phoneNumberConfig as PhoneNumberConfig?, 91 | prefersStatusBarHidden: 92 | prefersStatusBarHidden == const $CopyWithPlaceholder() 93 | ? _value.prefersStatusBarHidden 94 | : prefersStatusBarHidden as bool, 95 | privacyConfig: privacyConfig == const $CopyWithPlaceholder() 96 | ? _value.privacyConfig 97 | // ignore: cast_nullable_to_non_nullable 98 | : privacyConfig as PrivacyConfig?, 99 | sloganConfig: sloganConfig == const $CopyWithPlaceholder() 100 | ? _value.sloganConfig 101 | // ignore: cast_nullable_to_non_nullable 102 | : sloganConfig as SloganConfig?, 103 | ); 104 | } 105 | } 106 | 107 | extension $FullScreenUIConfigCopyWith on FullScreenUIConfig { 108 | /// Returns a callable class that can be used as follows: `instanceOfFullScreenUIConfig.copyWith(...)`. 109 | // ignore: library_private_types_in_public_api 110 | _$FullScreenUIConfigCWProxy get copyWith => 111 | _$FullScreenUIConfigCWProxyImpl(this); 112 | } 113 | -------------------------------------------------------------------------------- /lib/src/auth_response_model/auth_response_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | part 'auth_response_model.g.dart'; 4 | 5 | class AuthResponseModel { 6 | const AuthResponseModel({ 7 | this.resultCode, 8 | this.msg, 9 | this.requestId, 10 | this.token, 11 | this.innerMsg, 12 | this.innerCode, 13 | }); 14 | 15 | factory AuthResponseModel.fromJson(Map json) => 16 | _$AuthResponseModelFromJson(json); 17 | 18 | final String? resultCode; 19 | final String? msg; 20 | final String? requestId; 21 | final String? token; 22 | final String? innerMsg; 23 | final String? innerCode; 24 | 25 | Map toJson() => _$AuthResponseModelToJson(this); 26 | 27 | @override 28 | String toString() => jsonEncode(toJson()); 29 | } 30 | -------------------------------------------------------------------------------- /lib/src/auth_response_model/auth_response_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'auth_response_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | AuthResponseModel _$AuthResponseModelFromJson(Map json) => 10 | AuthResponseModel( 11 | resultCode: json['resultCode'] as String?, 12 | msg: json['msg'] as String?, 13 | requestId: json['requestId'] as String?, 14 | token: json['token'] as String?, 15 | innerMsg: json['innerMsg'] as String?, 16 | innerCode: json['innerCode'] as String?, 17 | ); 18 | 19 | Map _$AuthResponseModelToJson(AuthResponseModel instance) { 20 | final val = {}; 21 | 22 | void writeNotNull(String key, dynamic value) { 23 | if (value != null) { 24 | val[key] = value; 25 | } 26 | } 27 | 28 | writeNotNull('resultCode', instance.resultCode); 29 | writeNotNull('msg', instance.msg); 30 | writeNotNull('requestId', instance.requestId); 31 | writeNotNull('token', instance.token); 32 | writeNotNull('innerMsg', instance.innerMsg); 33 | writeNotNull('innerCode', instance.innerCode); 34 | return val; 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/auth_response_model/auth_result_code.dart: -------------------------------------------------------------------------------- 1 | ///阿里云SDK返回回调Enum 2 | ///@author kangkang 3 | ///@date 2023-01-10 4 | /// 5 | ///新备注(2023-02-04) 6 | ///#pragma mark - 该返回码为阿里云号码认证SDK⾃身的返回码,请注意600011及600012错误内均含有运营商返回码,(如果没有返回码请提ISSUE) 7 | ///具体错误在碰到之后查阅 https://help.aliyun.com/document_detail/85351.html?spm=a2c4g.11186623.6.561.32a7360cxvWk6H 8 | enum AuthResultCode { 9 | success('600000', '接口返回成功'), 10 | getOperatorInfoFailed('600004', '获取运营商配置信息失败'), 11 | 12 | /// 获取运营商配置信息失败 13 | noSIMCard('600007', '未检测到sim卡'), 14 | noCellularNetwork('600008', '蜂窝网络未开启或不稳定'), 15 | unknownOperator('600009', '无法判运营商'), 16 | unknownError('600010', '未知异常'), 17 | getTokenFailed('600011', '获取token失败'), 18 | getMaskPhoneFailed('600012', '预取号失败'), 19 | interfaceDemoted('600013', '运营商维护升级,该功能不可用'), 20 | interfaceLimited('600014', '运营商维护升级,该功能已达最大调用次数'), 21 | interfaceTimeout('600015', '接口超时'), 22 | getMaskPhoneSuccess('600016', '预取号成功'), 23 | decodeAppInfoFailed('600017', 'AppID Secret解析失败'), 24 | carrierChanged('600021', '运营商已切换'), 25 | envCheckSuccess('600024', '终端支持认证'), 26 | envCheckFail('600025', '终端环境检测失败(1.终端不支持认证;2.终端检测参数错误;3.初始化未成功)'), 27 | 28 | /// 号码认证授权页相关返回码 START 29 | loginControllerPresentSuccess('600001', '唤起授权页成功'), 30 | loginControllerPresentFailed('600002', '唤起授权页失败'), 31 | callPreLoginInAuthPage('600026', '授权页已加载时不允许调用加速或预取号接口'), 32 | loginControllerClickCancel('700000', '点击返回,⽤户取消一键登录'), 33 | loginControllerClickChangeBtn('700001', '点击切换按钮,⽤户取消免密登录'), 34 | loginControllerClickLoginBtn('700002', '点击登录按钮事件'), 35 | loginControllerClickCheckBoxBtn('700003', ' 点击CheckBox事件'), 36 | loginControllerClickProtocol('700004', '点击协议富文本文字'), 37 | 38 | /// 活体认证相关返回码 START 39 | loginClickPrivacyAlertView('700006', '点击一键登录拉起授权页二次弹窗'), 40 | loginPrivacyAlertViewClose('700007', '隐私协议二次弹窗关闭'), 41 | loginPrivacyAlertViewClickContinue('700008', '隐私协议二次弹窗点击确认并继续'), 42 | loginPrivacyAlertViewPrivacyContentClick('700009', '点击隐私协议二次弹窗上的协议富文本文字'), 43 | onCustomViewTap('700010', '用户点击了自定义控件的按钮,此时会[msg]会回调控件的viewId'), 44 | 45 | /// 活体认证相关返回码 START / 46 | failed('600030', ' 接口请求失败'), 47 | errorNetwork('600031', '网络错误'), 48 | errorClientTimestamp('600032', '客户端设备时间错误'), 49 | featureInvalid('600033', '功能不可用,需要到控制台开通对应功能'), 50 | codeSDKInfoInvalid('600034', '不合法的SDK密钥'), 51 | statusBusy('600035', '状态繁忙'), 52 | outOfService('600036', '业务停机'), 53 | liftBodyVerifyReadyStating('700005', '活体认证页面准备启动'), 54 | ; 55 | 56 | factory AuthResultCode.fromCode(String resultCode) { 57 | return values.firstWhere( 58 | (element) => element.code == resultCode, 59 | orElse: () => AuthResultCode.unknownError, 60 | ); 61 | } 62 | 63 | const AuthResultCode(this.code, this.message); 64 | 65 | final String code; 66 | final String message; 67 | } 68 | -------------------------------------------------------------------------------- /lib/src/internal/ali_auth_client.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/services.dart'; 5 | 6 | import '../../flutter_ali_auth.dart'; 7 | 8 | class AliAuthClient { 9 | const AliAuthClient._(); 10 | 11 | static const MethodChannel _methodChannel = MethodChannel('flutter_ali_auth'); 12 | 13 | // static const EventChannel _loginEventChannel = EventChannel('auth_event'); 14 | 15 | static Future getPlatformVersion() { 16 | return _methodChannel.invokeMethod('getPlatformVersion'); 17 | } 18 | 19 | /// 初始化 20 | /// 如果初始化错误,会抛出异常,需要用try-catch[PlatformException]捕获插件返回的异常 21 | /// 返回是否成功 22 | static Future initSdk({ 23 | required AuthConfig authConfig, 24 | }) async { 25 | return await _methodChannel.invokeMethod( 26 | 'init', 27 | authConfig.toJson(), 28 | ); 29 | } 30 | 31 | /// 初始化之后的SDK的异步回调 32 | /// [onEvent] 初始化之后会进行环境检查和加速拉起授权页面,这些回调会在这里返回, 33 | /// 可根据[AuthResponseModel.resultCode]和[AuthResponseModel.innerCode]的进行判断, 34 | /// 详情可以参考[AuthResultCode] 35 | /// 36 | static void handleEvent({ 37 | required AsyncValueSetter onEvent, 38 | // required ValueChanged onLoginEvent, 39 | }) { 40 | _methodChannel.setMethodCallHandler((call) async { 41 | switch (call.method) { 42 | case "onEvent": 43 | final AuthResponseModel responseModel = AuthResponseModel.fromJson( 44 | Map.from(call.arguments), 45 | ); 46 | await onEvent.call(responseModel); 47 | break; 48 | default: 49 | throw UnsupportedError('Unrecognized JSON message'); 50 | } 51 | }); 52 | } 53 | 54 | /// 一键登陆 需要用try-catch[PlatformException]捕获插件返回的异常 55 | /// 无返回内容,调用之后,会在[handleEvent]的[onEvent]返回回调 56 | /// [timeout] 超时,单位秒 57 | static Future login({int timeout = 5}) { 58 | return _methodChannel.invokeMethod('login', timeout); 59 | } 60 | 61 | /// 一键登陆,建议debug时使用, 用新的配置去拉起授权页 需要用try-catch[PlatformException]捕获插件返回的异常 62 | /// 无返回内容,调用之后,会在[onHandle]的[onLogin]返回回调 63 | /// [timeout] 超时,单位秒 64 | static Future loginWithConfig({ 65 | required AuthConfig authConfig, 66 | int timeout = 5, 67 | }) { 68 | return _methodChannel.invokeMethod( 69 | 'loginWithConfig', 70 | [authConfig.toJson(), timeout], 71 | ); 72 | } 73 | 74 | static void removeHandler() { 75 | _methodChannel.setMethodCallHandler(null); 76 | } 77 | 78 | // static Stream? _pluginStream; 79 | // static StreamSubscription? _streamSubscription; 80 | // 81 | // static Future onListen( 82 | // ValueChanged onData, { 83 | // Function? onError, 84 | // VoidCallback? onDone, 85 | // bool? cancelOnError, 86 | // }) async { 87 | // if (_pluginStream != null) { 88 | // return; 89 | // } 90 | // _pluginStream = _loginEventChannel.receiveBroadcastStream(); 91 | // _streamSubscription = _pluginStream!.listen( 92 | // onData, 93 | // onError: onError, 94 | // onDone: onDone, 95 | // cancelOnError: cancelOnError, 96 | // ); 97 | // } 98 | // 99 | // static FutureOr removeListener() async { 100 | // if (_streamSubscription == null) { 101 | // return false; 102 | // } 103 | // //call this method will trigger native side: [EventChannel.EventSink]#endOfStream,flutter side:[Stream]#onDone 104 | // await _methodChannel.invokeMethod('cancelStream'); 105 | // _streamSubscription!.cancel(); 106 | // _streamSubscription = null; 107 | // _pluginStream = null; 108 | // return true; 109 | // } 110 | // 111 | // /// 判断网络是否支持,一般不需要主动调用 112 | // static Future checkVerifyEnable() { 113 | // ///{msg: 无SIM卡, requestId: 941e9389efee47b9, resultCode: 600007} 114 | // return _methodChannel.invokeMethod("checkEnv"); 115 | // } 116 | // 117 | // /// 预取号,一般不需要主动调用 118 | // static Future accelerateLoginPage() { 119 | // return _methodChannel.invokeMethod('accelerateLoginPage'); 120 | // } 121 | 122 | /// 检查版本 123 | static Future get version { 124 | return _methodChannel.invokeMethod('getAliAuthVersion'); 125 | } 126 | 127 | /// 关闭授权页loading 128 | /// 安卓 SDK完成回调之后不会关闭loading,需要开发者主动调用hideLoginLoading关闭loading 129 | /// IOS 手动隐藏一键登录获取登录Token之后的等待动画,默认为自动隐藏 130 | static Future hideLoginLoading() { 131 | return _methodChannel.invokeMethod("hideLoginLoading"); 132 | } 133 | 134 | /// 退出授权认证页,IOS一般不用主动调用,除非个人需要,安卓看情况 135 | /// 安卓 SDK完成回调之后不会关闭授权页,需要开发者主动调⽤quitLoginPage退出授权页 136 | /// IOS 注销授权页,建议用此方法,对于移动卡授权页的消失会清空一些数据 137 | static Future quitLoginPage() { 138 | return _methodChannel.invokeMethod("quitLoginPage"); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /lib/src/internal/flutter_ali_auth_method_channel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/services.dart'; 3 | 4 | import 'flutter_ali_auth_platform_interface.dart'; 5 | 6 | /// An implementation of [FlutterAliAuthPlatform] that uses method channels. 7 | class MethodChannelFlutterAliAuth extends FlutterAliAuthPlatform { 8 | /// The method channel used to interact with the native platform. 9 | @visibleForTesting 10 | final methodChannel = const MethodChannel('flutter_ali_auth'); 11 | 12 | @override 13 | Future getPlatformVersion() async { 14 | final version = 15 | await methodChannel.invokeMethod('getPlatformVersion'); 16 | return version; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/src/internal/flutter_ali_auth_platform_interface.dart: -------------------------------------------------------------------------------- 1 | import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 2 | 3 | import 'flutter_ali_auth_method_channel.dart'; 4 | 5 | abstract class FlutterAliAuthPlatform extends PlatformInterface { 6 | /// Constructs a FlutterAliAuthPlatform. 7 | FlutterAliAuthPlatform() : super(token: _token); 8 | 9 | static final Object _token = Object(); 10 | 11 | static FlutterAliAuthPlatform _instance = MethodChannelFlutterAliAuth(); 12 | 13 | /// The default instance of [FlutterAliAuthPlatform] to use. 14 | /// 15 | /// Defaults to [MethodChannelFlutterAliAuth]. 16 | static FlutterAliAuthPlatform get instance => _instance; 17 | 18 | /// Platform-specific implementations should set this with their own 19 | /// platform-specific class that extends [FlutterAliAuthPlatform] when 20 | /// they register themselves. 21 | static set instance(FlutterAliAuthPlatform instance) { 22 | PlatformInterface.verifyToken(instance, _token); 23 | _instance = instance; 24 | } 25 | 26 | Future getPlatformVersion() { 27 | throw UnimplementedError('platformVersion() has not been implemented.'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_ali_auth 2 | description: Flutter Ali Auth Plugin 阿里云一键登录Flutter插件 3 | repository: https://github.com/fluttercandies/flutter_ali_auth 4 | version: 0.7.0 5 | homepage: https://github.com/fluttercandies/flutter_ali_auth 6 | 7 | environment: 8 | sdk: '>=2.17.0 <3.0.0' 9 | flutter: ">=3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | plugin_platform_interface: ^2.0.2 15 | dev_dependencies: 16 | flutter_lints: ^2.0.0 17 | build_runner: ^2.2.1 18 | 19 | flutter: 20 | plugin: 21 | platforms: 22 | android: 23 | package: com.fluttercandies.flutter_ali_auth 24 | pluginClass: FlutterAliAuthPlugin 25 | ios: 26 | pluginClass: FlutterAliAuthPlugin 27 | --------------------------------------------------------------------------------