Tkko / flutter_smart_auth

Flutter package for listening SMS code on Android, suggesting phone number, email, saving a credential.
https://pub.dev/packages/smart_auth
MIT License
43 stars 26 forks source link

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

Open fozilbekimomov opened 1 year ago

fozilbekimomov commented 1 year ago

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
        )
VasuBhav commented 1 year ago

When I include ContextCompat how in this solution, I get an error.

fozilbekimomov commented 1 year ago

When I include ContextCompat how in this solution, I get an error.

You should update gradle file also as given above. After errors with ContextCompat must disappear

umidshox99 commented 12 months ago

any updates ?

Tkko commented 12 months ago

Hey guys, I'll check the PR today.

mrrhak commented 10 months ago

Any update for API 34? My app has been crashed when start OTP using package Pinput but the main error is trigger from smart auth package.

E/MethodChannel#fman.smart_auth(22790): java.lang.SecurityException: com.example.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
devanshlala1 commented 10 months ago

Hey @Tkko, thanks for sharing this. Any update on support for Android 14?

Tkko commented 10 months ago

Merged the PR The changes are included in version 2.0.0

soumyajitdas365 commented 2 months ago

Hello there, Hope you're doing great. I'm getting a error whenever the message is recieved "E/Pinput/SmartAuth(22173): Retrieved SMS is null, check if SMS contains correct app signature"