flutter_smart_auth icon indicating copy to clipboard operation
flutter_smart_auth copied to clipboard

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

Open fozilbekimomov opened this issue 2 years ago • 8 comments
trafficstars

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
        )

fozilbekimomov avatar Nov 13 '23 09:11 fozilbekimomov

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

VasuBhav avatar Nov 21 '23 11:11 VasuBhav

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

fozilbekimomov avatar Nov 21 '23 16:11 fozilbekimomov

any updates ?

umidshox99 avatar Nov 28 '23 10:11 umidshox99

Hey guys, I'll check the PR today.

Tkko avatar Nov 28 '23 10:11 Tkko

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

mrrhak avatar Jan 13 '24 07:01 mrrhak

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

devanshlala1 avatar Jan 19 '24 08:01 devanshlala1

Merged the PR The changes are included in version 2.0.0

Tkko avatar Jan 22 '24 10:01 Tkko

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"

soumyajitdas365 avatar Sep 03 '24 10:09 soumyajitdas365

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"

Please checkout the readme.

Tkko avatar Dec 20 '24 17:12 Tkko