From 3aad2cb8c72fef30efe3a708aa1595dd24ad68e2 Mon Sep 17 00:00:00 2001 From: sadhorsephile Date: Wed, 28 Aug 2024 11:10:37 +0300 Subject: [PATCH] feat: migrate to v2 embedding --- CHANGELOG.md | 1 + README.md | 12 ++++++++++++ .../ru/surfstudio/otp_autofill/OTPPlugin.kt | 17 ++--------------- .../android/app/src/main/AndroidManifest.xml | 1 + 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e28ec05..4185adb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Breaking: Upgrade Gradle version. * Breaking: Upgrade Kotlin version. +* Breaking: Remove v1 embedding support. ## 3.0.4 diff --git a/README.md b/README.md index 7085df7..7f367c3 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,18 @@ If you use the [SMS User Consent API](https://developers.google.com/identity/sms The `OTPInteractor.startListenForCode` method allows the application to start receiving verification codes from a specific phone number, specified by the `senderPhone` argument. +You also can use Android Emulator to test the plugin. To do this, you need to send an SMS to the emulator with the following command: + +```bash +adb emu sms send +``` +E.g.: +```bash +adb emu sms send 900 "Your code is 12345. Do not share it with anyone." +``` + +Make sure `senderPhone` is the same as the one you specified in the `startListenForCode` method. + ## Usage You should use `OTPInteractor` to interact with OTP. diff --git a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt index 33bf6c2..ee74e34 100644 --- a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt +++ b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt @@ -19,7 +19,6 @@ import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler import io.flutter.plugin.common.MethodChannel.Result import io.flutter.plugin.common.PluginRegistry -import io.flutter.plugin.common.PluginRegistry.Registrar /// Channel const val channelName: String = "otp_surfstudio" @@ -53,20 +52,8 @@ class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.ActivityResul channel = MethodChannel(flutterPluginBinding.binaryMessenger, channelName) channel.setMethodCallHandler(this); } - - companion object { - private var context: Context? = null - private var lastResult: Result? = null - - @JvmStatic - fun registerWith(registrar: Registrar) { - context = registrar.context() - val channel = MethodChannel(registrar.messenger(), channelName) - val plugin = OTPPlugin() - channel.setMethodCallHandler(plugin) - registrar.addActivityResultListener(plugin) - } - } + private var context: Context? = null + private var lastResult: Result? = null override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { when (call.method) { diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 07f7a01..44748ce 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ android:label="test_otp_autofill" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> +