flutter_smart_auth
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.
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
)