capacitor-sms-verification
v0.0.1
Published
Read SMS with OTP for verification purpose sent by server
Readme
capacitor-sms-verification
Implementation of Android sms-retriever feature for capacitor project.
It only support android for now.
Install
npm install capacitor-sms-verification
npx cap syncUsage
After installation completed, continue the process as below:
- Get app signature, this step should be removed on production. Please follow this instruction to generate app signature on production.
import { SmsVerification } from 'capacitor-sms-verification'
const appSignature = SmsVerification.getAppSignatures()
// Append the appSignature to the very bottom of sms content.- Start listening for
SMSVerificationReceivedofSmsVerificationfor incoming sms verification and take action based on sms content
import { SmsVerification } from 'capacitor-sms-verification'
SmsVerification.addListener('SMSVerificationReceived', sms => {
let text = sms.text
// Do something with the text
// Remove all started listener
SmsVerification.removeAllListeners()
})- Send request to server and start sms-retriever service
import { SmsVerification } from 'capacitor-sms-verification'
// api.post('/me/login', {phone})
SmsVerification.startListening()API
addListener('SMSVerificationReceived', ...)getAppSignatures()removeAllListeners()startListening()- Interfaces
addListener('SMSVerificationReceived', ...)
addListener(eventName: 'SMSVerificationReceived', listenerFunc: (result: SMSVerificationResult) => void) => Promise<PluginListenerHandle>Start listening for incoming sms verification
| Param | Type |
| ------------------ | -------------------------------------------------------------------------------------------- |
| eventName | 'SMSVerificationReceived' |
| listenerFunc | (result: SMSVerificationResult) => void |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
getAppSignatures()
getAppSignatures() => Promise<void>Get for development app signature
Since: 1.0.0
removeAllListeners()
removeAllListeners() => Promise<void>Remove listener for sms verification
Since: 1.0.0
startListening()
startListening() => Promise<void>Start listening for SMS verification
Since: 1.0.0
Interfaces
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
SMSVerificationResult
| Prop | Type | Description | Since |
| ---------- | ------------------- | ------------ | ----- |
| text | string | The SMS text | 1.0.0 |
