GithubHelp home page GithubHelp logo

tkko / flutter_smart_auth Goto Github PK

View Code? Open in Web Editor NEW
40.0 1.0 19.0 315 KB

Flutter package for listening SMS code on Android, suggesting phone number, email, saving a credential.

Home Page: https://pub.dev/packages/smart_auth

License: MIT License

Kotlin 23.63% Dart 20.03% Ruby 4.17% Swift 2.34% Objective-C 0.67% CMake 16.81% C++ 25.32% C 2.50% HTML 3.83% Shell 0.72%
smsretrieverapi smsuserconsentapi androidautofill pin pin-input sms-code smsverify sms-verification flutter flutterpackage

flutter_smart_auth's Introduction

Hi 👋, I'm Tornike,

Flutter Engineer, Building Pixel Perfect Mobile/Web Apps

Looking for a remote job 🧐? JobDistricts.com

  • 🚀 Mobile Engineer
  • 📫 Reach out on: LinkedIn
  • ☝️ Open to Remote/Relocate
  • 💡 To get readme like this, create a repository with the name that matches your GitHub username.
  • 👨‍💻 More info is available on tornike.dev

Connect with me:

tornike thornike_ thornike @thornike

Languages and Tools:

dart figma firebase flutter git hive kotlin postman

dd dss

Top freelance platforms for developers

flutter_smart_auth's People

Contributors

dependabot[bot] avatar jonsheller avatar mahdinba97 avatar tiffapps avatar tkko avatar zhangyc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_smart_auth's Issues

Sms code retrieval is not working when the app is published on the play store

Describe the bug
When I publish the app on playstore the auto sms code retrieval is not working, and I think the issue is caused by appsignature changing when its published that causes it not to detect the sms code ,because the signauture appears similar for all devices and it has a space between the appsignature string

Execution failed for task ':app:checkDebugAarMetadata'

I am getting this error message after adding pinput which is dependent on this repository

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.google.android.gms:play-repositories-auth:20.1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/android/gms/play-repositories-auth/20.1.0/play-repositories-auth-20.1.0.pom
       - https://repo.maven.apache.org/maven2/com/google/android/gms/play-repositories-auth/20.1.0/play-repositories-auth-20.1.0.pom
       - https://storage.googleapis.com/download.flutter.io/com/google/android/gms/play-repositories-auth/20.1.0/play-repositories-auth-20.1.0.pom
     Required by:
         project :app > project :smart_auth
   > Could not find com.google.android.gms:play-repositories-auth-api-phone:18.0.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/android/gms/play-repositories-auth-api-phone/18.0.1/play-repositories-auth-api-phone-18.0.1.pom
       - https://repo.maven.apache.org/maven2/com/google/android/gms/play-repositories-auth-api-phone/18.0.1/play-repositories-auth-api-phone-18.0.1.pom
       - https://storage.googleapis.com/download.flutter.io/com/google/android/gms/play-repositories-auth-api-phone/18.0.1/play-repositories-auth-api-phone-18.0.1.pom
     Required by:
         project :app > project :smart_auth

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 42s
Exception: Gradle task assembleDebug failed with exit code 1

[Q] What are the cases that 'getAppSignature' returns 'N/A'?

Hi,

I have a general question regarding the 'getAppSignature' function:
What are the cases that 'getAppSignature' returns 'N/A'?

It seems that it mostly happens with iOS. Is it a correct behavior?
Sometimes (rare but still) it happens also in Android, what could be a reason for that?

Thanks.

smartAuth.requestHint getting crash

Getting crash when requestinh phone hint

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/credentials/HintRequest$Builder;

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.credentials.HintRequest$Builder" on path: DexPathList[[zip file "/data/app/~~b646lIclmArAMB3At_-jyw==/com.app-Lfbja4qsyhQwiTlaNeLhiA==/base.apk"],nativeLibraryDirectories=[/data/app/~~b646lIclmArAMB3At_-jyw==/com.app-Lfbja4qsyhQwiTlaNeLhiA==/lib/arm64, /data/app/~~b646lIclmArAMB3At_-jyw==/com.app-Lfbja4qsyhQwiTlaNeLhiA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]

Operation not permitted in IOS

Describe the bug
Cannot open file '/Users/username/Documents/src/flutter/bin/cache/artifacts/engine/ios/Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Modules/module.modulemap': Operation not permitted

Incompatibility with play-services-auth 21.0.0 and google_sign_in_android 6.1.22

Describe the bug
I can't compile my (android) app in release mode after upgrading google_sign_in_android to 6.1.22.
I get errors (10+) like:

[ +1 ms] Missing class com.google.android.gms.auth.api.credentials.CredentialPickerConfig$Builder (referenced from: void fman.ge.smart_auth.SmartAuthPlugin.requestHint(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result))

To Reproduce
Steps to reproduce the behavior:

  1. Have both smart_auth and google_sign_in_android latest versions in a flutter project with android
  2. flutter build apk --release --verbose

Screenshots
N/A

smart_auth version: 2.0.0

Result of: flutter doctor --verbose

[√] Flutter (Channel stable, 3.19.3, on Microsoft Windows [Version 10.0.22621.3296], locale el-GR) • Flutter version 3.19.3 on channel stable at c:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ba39319843 (3 weeks ago), 2024-03-07 15:22:21 -0600 • Engine revision 2e4ba9c6fb • Dart version 3.3.1 • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at [reducted]
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.7.34003.232
• Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)

[√] VS Code (version 1.87.2)
• VS Code at [reducted]
• Flutter extension version 3.84.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.3296]
• Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.59
• Edge (web) • edge • web-javascript • Microsoft Edge 120.0.2210.133

[√] Network resources
• All expected network resources are available.

• No issues found!

Smartphone (please complete the following information):

  • Device: Android Emulator
  • OS: Android API 33

Additional context
So, going through the release notes, google_sign_in_android says they upgraded play-services-auth to 21.0.0 (url)
The release notes of play-services-auth say that there is a major breaking change: they removed Credentials API! (https://developers.google.com/android/guides/releases#february_15_2024)
The settings.gradle of this plugin I see it depends on play-services-auth 20.7.0 (

implementation 'com.google.android.gms:play-services-auth:20.7.0'
)

I guess 21 is preferred over 20.7 during compilation, so no wonder why those classes mentioned in the error log can not be found.

This is why I think this is worthy of a bug report for smart_auth: can you please support the new Credential Manager API?

Dependency 'androidx.core:core-ktx:1.12.0' requires libraries and applications depend on it to compile against version 34 or later of the Android APIs.

smart_auth: ^2.0.0

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:checkReleaseAarMetadata'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
2 issues were found when checking AAR metadata:

   1.  Dependency 'androidx.core:core-ktx:1.12.0' requires libraries and applications that
       depend on it to compile against version 34 or later of the
       Android APIs.

       :app is currently compiled against android-33.

       Also, the maximum recommended compile SDK version for Android Gradle
       plugin 7.4.2 is 33.

       Recommended action: Update this project's version of the Android Gradle
       plugin to one that supports 34, then update this project to use
       compileSdkVerion of at least 34.

       Note that updating a library or application's compileSdkVersion (which
       allows newer APIs to be used) can be done separately from updating
       targetSdkVersion (which opts the app in to new runtime behavior) and
       minSdkVersion (which determines which devices the app can be installed
       on).

   2.  Dependency 'androidx.core:core:1.12.0' requires libraries and applications that
       depend on it to compile against version 34 or later of the
       Android APIs.

       :app is currently compiled against android-33.

       Also, the maximum recommended compile SDK version for Android Gradle
       plugin 7.4.2 is 33.

       Recommended action: Update this project's version of the Android Gradle
       plugin to one that supports 34, then update this project to use
       compileSdkVerion of at least 34.

       Note that updating a library or application's compileSdkVersion (which
       allows newer APIs to be used) can be done separately from updating
       targetSdkVersion (which opts the app in to new runtime behavior) and
       minSdkVersion (which determines which devices the app can be installed
       on).
  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 1m 52s

java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.example.sms_flutter (has extras) } in fman.ge.smart_auth.SmartAuthPlugin$SmsBroadcastReceiver@79393a2

As long as you use getSmsCode to receive the verification code, it starts to flash back, prompting this error

D[/AndroidRuntime]()(31911): Shutting down VM E[/AndroidRuntime]()(31911): FATAL EXCEPTION: main E[/AndroidRuntime]()(31911): Process: com.example.sms_flutter, PID: 31911 E[/AndroidRuntime]()(31911): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.example.sms_flutter (has extras) } in fman.ge.smart_auth.SmartAuthPlugin$SmsBroadcastReceiver@79393a2 E[/AndroidRuntime]()(31911): at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1581) E[/AndroidRuntime]()(31911): at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) E[/AndroidRuntime]()(31911): at android.os.Handler.handleCallback(Handler.java:938) E[/AndroidRuntime]()(31911): at android.os.Handler.dispatchMessage(Handler.java:99) E[/AndroidRuntime]()(31911): at android.os.Looper.loop(Looper.java:233) E[/AndroidRuntime]()(31911): at android.app.ActivityThread.main(ActivityThread.java:8030) E[/AndroidRuntime]()(31911): at java.lang.reflect.Method.invoke(Native Method) E[/AndroidRuntime]()(31911): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) E[/AndroidRuntime]()(31911): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) E[/AndroidRuntime]()(31911): Caused by: java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String E[/AndroidRuntime]()(31911): at fman.ge.smart_auth.SmartAuthPlugin$SmsBroadcastReceiver.onReceive(SmartAuthPlugin.kt:433) E[/AndroidRuntime]()(31911): at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1566) E[/AndroidRuntime]()(31911): ... 8 more I[/Process]() (31911): Sending signal. PID: 31911 SIG: 9

On Android API 34 (Android 14) sms retriever not working. Need to change codes as mentioned in official documentation.

I have ready solution. Need to change gradle dependencies.
dependencies to given below:

build.gradle:


group 'fman.ge.smart_auth'
version '1.0-SNAPSHOT'

buildscript {
//    ext.kotlin_version = '1.10.1'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
//        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    // Conditional for compatibility with AGP <4.2.
    if (project.android.hasProperty("namespace")) {
        namespace 'fman.ge.smart_auth'
    }
    
    compileSdkVersion 34

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        minSdkVersion 16
    }
}

dependencies {
    implementation "androidx.core:core-ktx:1.10.1"
    implementation 'com.google.android.gms:play-services-auth:20.7.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
}

Then in SmartAuthPlugin.kt

code from line 241 to 247 given below:


 mContext.registerReceiver(
            smsReceiver,
            IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION),
            SmsRetriever.SEND_PERMISSION,
            null,

            )


need to change to :

  val intentFilter = IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION)
        ContextCompat.registerReceiver(
            mContext,
            smsReceiver,
            intentFilter,
            SmsRetriever.SEND_PERMISSION,
            null,
            ContextCompat.RECEIVER_EXPORTED
        )

Application crashes when SMS is received.

Here, I am using Firebase OTP. When I try to use autofill with the userConsent API .
Here is the Details Log when app crash.

I/PlayCore(17213): UID: [11666] PID: [17213] IntegrityService : reportBinderDeath
I/PlayCore(17213): UID: [11666] PID: [17213] IntegrityService : IntegrityService : Binder has died.
D/AndroidRuntime(17213): Shutting down VM
E/AndroidRuntime(17213): FATAL EXCEPTION: main
E/AndroidRuntime(17213): Process: , PID: 17213
E/AndroidRuntime(17213): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=has extras) } in com.google.android.gms.internal.firebase-auth-api.zzaby@81dcfe5
E/AndroidRuntime(17213): at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1708)
E/AndroidRuntime(17213): at android.app.LoadedApk$ReceiverDispatcher$Args$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AndroidRuntime(17213): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(17213): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17213): at android.os.Looper.loopOnce(Looper.java:210)
E/AndroidRuntime(17213): at android.os.Looper.loop(Looper.java:299)
E/AndroidRuntime(17213): at android.app.ActivityThread.main(ActivityThread.java:8319)
E/AndroidRuntime(17213): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17213): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
E/AndroidRuntime(17213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1038)
E/AndroidRuntime(17213): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
E/AndroidRuntime(17213): at java.util.regex.Matcher.reset(Matcher.java:256)
E/AndroidRuntime(17213): at java.util.regex.Matcher.(Matcher.java:167)
E/AndroidRuntime(17213): at java.util.regex.Pattern.matcher(Pattern.java:1040)
E/AndroidRuntime(17213): at com.google.android.gms.internal.firebase-auth-api.zzaby.onReceive(com.google.firebase:firebase-auth@@22.0.0:8)
E/AndroidRuntime(17213): at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1694)
E/AndroidRuntime(17213): ... 9 more
W/OOMEventManagerFK(17213): Failed to mkdir /data/mqsas/hprof/
I/Process (17213): Sending signal. PID: 17213 SIG: 9
Lost connection to device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.