Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fozilbekimomov opened this issue Nov 13, 2023 · 8 comments
Assignees

Comments

@fozilbekimomov
Copy link

fozilbekimomov commented Nov 13, 2023

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
Copy link

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

@fozilbekimomov
Copy link
Author

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
Copy link

any updates ?

@Tkko
Copy link
Owner

Tkko commented Nov 28, 2023

Hey guys,
I'll check the PR today.

@mrrhak
Copy link

mrrhak commented Jan 13, 2024

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
Copy link

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

@Tkko
Copy link
Owner

Tkko commented Jan 22, 2024

Merged the PR
The changes are included in version 2.0.0

@soumyajitdas365
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants