Android-only plugin for Capacitor 7 that retrieves SMS messages without requiring runtime permissions. Suitable for OTP (One-Time Password) use cases using the Google Play Services SMS Retriever API.
npm install @michaelkhabarov/capacitor-sms-retriever- Android: Fully supported
- iOS: Not supported
- Web: Not supported
import { Capacitor } from '@capacitor/core'
import { CapacitorSmsRetriever } from "@michaelkhabarov/capacitor-sms-retriever";
if (Capacitor.getPlatform() === 'android') {
// Start listening for SMS
CapacitorSmsRetriever.startListening()
.then((res) => console.log("SMS Content", res.body))
.catch((err) => console.log("Failed", err));
// Stop listening
CapacitorSmsRetriever.stopListening();
// Get signature
CapacitorSmsRetriever.getAppSignature()
.then((res) => { console.log("App signature", res.signature) });
}Starts listening for incoming SMS messages.
Returns: Promise<{ body: string }>
Stops listening for SMS messages.
This is a helper method to generate your message hash to be included in your SMS message. Without the correct hash, your app won't receive the message callback. This only needs to be generated once per app and stored.
Note: Do not use hash strings dynamically computed on the client in your verification messages.
Returns: Promise<{ signature: string }>
- Capacitor 7.0.0 or higher
- Android SDK 23 (Android 6.0) or higher
- Android Gradle Plugin 8.7.2
- Google Play Services (play-services-auth-api-phone 18.1.0)
This plugin uses the Google Play Services SMS Retriever API, which allows your app to automatically retrieve verification codes from SMS messages without requiring the READ_SMS permission. The SMS message must be formatted according to Google's requirements (max 140 bytes, contains a hash string identifying your app).
For more information, see the SMS Retriever API documentation.
This package is based on: