-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TandohAnthonyNwiAckah/development
Development
- Loading branch information
Showing
20 changed files
with
425 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Flutter Lint | ||
|
||
on: | ||
pull_request: | ||
branches: [ "master", "development"] | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
channel: stable | ||
flutter-version: 3.24.2 | ||
- run: flutter --version | ||
|
||
- name: Install dependencies | ||
run: flutter pub get | ||
|
||
- name: Run Dart analyzer | ||
run: flutter analyze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 0.2.2 | ||
## 1.0.0 | ||
- Upgrade dependencies. | ||
- Code cleanup. | ||
|
||
## 0.2.2 | ||
- initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,100 @@ | ||
# otp_autofill_sms | ||
A versatile and efficient solution designed to enhance the user experience by automating the process of filling in OTPs sent via SMS. | ||
|
||
`otp_autofill_sms` is a Flutter plugin designed to simplify OTP (One-Time Password) autofill for | ||
Android applications. | ||
|
||
This plugin is available only for Android, as iOS handles OTP autofill natively. While iOS users | ||
benefit from built-in OTP autofill functionality, this plugin provides a seamless experience for | ||
Android users by managing OTP autofill without requiring SMS read permissions, thus enhancing user | ||
convenience. | ||
|
||
## Features | ||
|
||
- **Automatic OTP Detection**: Automatically captures and fills OTPs sent via SMS, enhancing user | ||
convenience. | ||
|
||
- **No SMS Permissions Required**: Utilizes | ||
the [SMS User Consent API](https://developers.google.com/identity/sms-retriever/user-consent/overview) | ||
to function without needing explicit SMS read permissions. | ||
- **Easy Integration**: Simple setup and integration with your Flutter project. | ||
|
||
## Screenshots | ||
|
||
| Default Screen | OTP Autofill | | ||
|-------------------------------------------|-------------------------------------------| | ||
|  |  | | ||
|
||
## How It Works | ||
|
||
The plugin leverages Google's SMS Retriever API to detect OTPs automatically. To ensure proper | ||
detection, the SMS message must adhere to specific formatting rules: | ||
|
||
### SMS Formatting Guidelines | ||
|
||
- **Length**: SMS should be no longer than 140 bytes. | ||
|
||
- **Content**: The message must contain a one-time code for user verification. | ||
|
||
- **End String**: The message should end with an 11-character hash string that identifies your app. | ||
|
||
### Example SMS Format | ||
|
||
> Your ExampleApp code is: 915456 FA+9qCVSz | ||
**Make sure to generate the Signature Code for both the release and debug versions of your app and append it to your message.** | ||
|
||
|
||
## Installation | ||
|
||
To add `otp_autofill_sms` to your Flutter project, follow these steps: | ||
|
||
1. **Add Dependency**: Include the plugin in your `pubspec.yaml` file: | ||
```yaml | ||
dependencies: | ||
otp_autofill_sms: ^1.0.0 | ||
``` | ||
2. **Install Packages**: Run `flutter pub get` to fetch the package. | ||
|
||
3. **Android Configuration**: Follow the setup instructions below to configure your Android project. | ||
|
||
## Setup Instructions | ||
|
||
1 **Flutter Integration**: Import and initialize the plugin in your Dart code: | ||
```dart | ||
import 'package:otp_autofill_sms/otp_autofill_sms.dart'; | ||
``` | ||
|
||
2 **Basic Usage**: | ||
```dart | ||
// Get the app signature code. | ||
Future<void> _getSignatureCode() async { | ||
String? signature = await OtpAutofillSms.getAppSignature(); | ||
print("Signature: $signature"); | ||
} | ||
// Start listening for incoming SMS messages | ||
void _startListeningSms() { | ||
OtpAutofillSms.startListeningSms().then((message) { | ||
setState(() { | ||
print("Message: $message"); | ||
}); | ||
}); | ||
} | ||
``` | ||
|
||
|
||
## Contributing | ||
|
||
Contributions are welcome! If you find any bugs or have ideas for improvements, please submit a pull | ||
request or open an issue on | ||
the [otp_autofill_sms repository](https://github.com/TandohAnthonyNwiAckah/otp_autofill_sms) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
android/src/main/kotlin/com/tanacom/otp_autofill_sms/MyListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
package com.tanacom.otp_autofill_sms | ||
|
||
|
||
/** MyListener **/ | ||
/** | ||
* MyListener interface to handle OTP events. | ||
*/ | ||
interface MyListener { | ||
/** | ||
* Called when an OTP is received. | ||
* @param message The received OTP message. | ||
*/ | ||
fun onOtpReceived(message: String?) | ||
fun onOtpTimeout() | ||
|
||
/** | ||
* Called when OTP retrieval times out. | ||
*/ | ||
fun onOtpTimeout() | ||
} |
Oops, something went wrong.