Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-android-sms-retriever`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/android-sms-retriever/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Install
Section titled “Install”bun add @capgo/capacitor-android-sms-retrieverbunx cap sync androidImport
Section titled “Import”import { AndroidSmsRetriever } from '@capgo/capacitor-android-sms-retriever';Android Requirements
Section titled “Android Requirements”SMS Retriever requires Google Play services on the Android device. The plugin does not request READ_SMS or RECEIVE_SMS permissions.
Your verification SMS must include the app hash returned by getHashString(). Generate the hash for the signing key used to distribute the app. Debug, release, and Play App Signing builds can have different hashes.
Listen For A Verification SMS
Section titled “Listen For A Verification SMS”import { AndroidSmsRetriever } from '@capgo/capacitor-android-sms-retriever';
const received = await AndroidSmsRetriever.addListener('smsReceived', ({ message }) => { const code = message.match(/\b\d{6}\b/)?.[0]; console.log('Verification code:', code);});
const timeout = await AndroidSmsRetriever.addListener('smsRetrieverTimeout', () => { console.log('SMS Retriever timed out');});
const errors = await AndroidSmsRetriever.addListener('smsRetrieverError', ({ message }) => { console.error('SMS Retriever error:', message);});
await AndroidSmsRetriever.startWatch();
// Remove listeners when the verification flow is done.await received.remove();await timeout.remove();await errors.remove();Stop Watching
Section titled “Stop Watching”await AndroidSmsRetriever.stopWatch();Get The App Hash
Section titled “Get The App Hash”const { hash } = await AndroidSmsRetriever.getHashString();console.log(hash);Use this hash at the end of the verification SMS sent by your backend.
Request A Phone Number Hint
Section titled “Request A Phone Number Hint”const { phoneNumber } = await AndroidSmsRetriever.getPhoneNumber();console.log(phoneNumber);Android shows the native Phone Number Hint UI and returns the phone number selected by the user.
Example SMS
Section titled “Example SMS”<#> 123456 is your verification code.FA+9qCX9VSuReplace the final line with the hash for your app signing key.