Skip to content

Commit

Permalink
feat: migrate to v2 embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadhorsephile committed Aug 28, 2024
1 parent 7089c87 commit 3aad2cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Breaking: Upgrade Gradle version.
* Breaking: Upgrade Kotlin version.
* Breaking: Remove v1 embedding support.

## 3.0.4

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <senderPhone> <message>
```
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.
Expand Down
17 changes: 2 additions & 15 deletions android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:label="test_otp_autofill"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<meta-data android:name="flutterEmbedding" android:value="2"/>
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down

0 comments on commit 3aad2cb

Please sign in to comment.