Skip to content

Commit

Permalink
feat: Migrate to v2 Embedding (#99)
Browse files Browse the repository at this point in the history
## Changes

- Remove v1 Embedding Support
- Add more info about Android Testing to README.md

## Checklist

- [x] Have you added an explanation of what your changes do and why
you'd like us to include them?
- [x] Is there an existing issue for this PR?
  - resolve #97 
- [ ] Have the files been linted and formatted?
- [ ] Have the docs been updated to match the changes in the PR?
- [ ] Have the tests been updated to match the changes in the PR?
- [ ] Attached videos/screenshots demonstrating the fix/feature.
- [x] Have you run the tests locally to confirm they pass?
  • Loading branch information
Sadhorsephile authored Aug 28, 2024
1 parent 7089c87 commit d070e5e
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 d070e5e

Please sign in to comment.