https://github.com/applogistdev/alsmsretriever-android
Retrieve SMS from SMS User Consent API or SMS Retriever API
https://github.com/applogistdev/alsmsretriever-android
Last synced: 6 months ago
JSON representation
Retrieve SMS from SMS User Consent API or SMS Retriever API
- Host: GitHub
- URL: https://github.com/applogistdev/alsmsretriever-android
- Owner: applogistdev
- License: mit
- Created: 2020-02-11T11:08:16.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-30T05:52:44.000Z (almost 5 years ago)
- Last Synced: 2025-04-19T20:16:46.278Z (about 1 year ago)
- Language: Kotlin
- Size: 144 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ALSmsRetriever
## Important
A message triggers the broadcast only if it meets these criteria:
- The message contains a 4-10 character alphanumeric string with at least one number.
- The message was sent by a phone number that's not in the user's contacts.
- If you specified the sender's phone number, the message was sent by that number.
Sample message : **Your verification code is 1234**
## Installation
[](https://jitpack.io/#applogistdev/ALSmsRetriever-android)
```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.applogistdev:ALSmsRetriever-android:lastVersion'
}
```
## Usage with SMS User Consent API (https://developers.google.com/identity/sms-retriever/user-consent/overview)
Register your listener
```kotlin
OneTapSmsReceiver.instance?.start(this,this, object :
OneTapSmsListener {
override fun onSuccess(message: String) {
Log.d("onSuccess", message)
}
override fun onFailure(errorCode: Int) {
Log.e("onFailure", errorCode.toString())
}
})
```
Add onActivityResult
```kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
OneTapSmsReceiver.instance?.handleOnActivityResult(requestCode,resultCode,data)
super.onActivityResult(requestCode, resultCode, data)
}
```
## Usage with SMS Retriever API (https://developers.google.com/identity/sms-retriever/overview)
Create your Debug or Release signature with [AppSignatureHelper](https://github.com/applogistdev/ALSmsRetriever-android/blob/master/app/src/main/java/com/applogist/alsmsretriever_sample/AppSignatureHelper.kt) (IMPORTANT: When you release at Google Play with Google App Signing this Release signature won't work.)
```kotlin
AppSignatureHelper(this).appSignatures.toString()
```
You must send your message with this signature. Sample: "Yumm! Pie à la Android mode! 123456 1Ouzi0b+Kxq"
Register your listener
```kotlin
SmsRetrieverReceiver.instance?.start(this,this, object : SmsRetrieverListener{
override fun onReceive(message: String) {
Log.d("message", message)
}
override fun onFailure(errorCode: Int) {
Log.e("onFailure", errorCode.toString())
}
})
```
## Get Google Play Release Hash
https://stackoverflow.com/questions/51365778/how-to-generate-11-char-hash-key-for-sms-retriever-with-google-app-signing