はじめに
このプラグインのインストール手順と全マークダウンガイドを含む設定の質問をコピーします。
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.
インストール
「インストール」のセクションbun add @capgo/capacitor-android-sms-retrieverbunx cap sync androidインポート
「インポート」のセクションimport { AndroidSmsRetriever } from '@capgo/capacitor-android-sms-retriever';Androidの要件
Android の要件Android デバイス上の Google Play サービスが必要です。プラグインは、SMS Retriever に必要な " READ_SMS SMS Retriever に必要な " RECEIVE_SMS 、を要求しません。
SMS の検証に使用するアプリのハッシュを含む SMS が必要です。このハッシュは、 getHashString()で生成する必要があります。
アプリの署名キーを使用してアプリを配布する場合、デバッグ、リリース、Play App Signing ビルドは異なるハッシュを生成する可能性があります。
検証 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();コピー
停止await AndroidSmsRetriever.stopWatch();アプリハッシュを取得
「アプリハッシュを取得」のセクションconst { hash } = await AndroidSmsRetriever.getHashString();console.log(hash);バックエンドから送信される検証SMSの末尾にこのハッシュを使用してください。
電話番号ヒントを要求
「電話番号ヒントを要求」のセクションconst { phoneNumber } = await AndroidSmsRetriever.getPhoneNumber();console.log(phoneNumber);Androidはユーザーが選択した電話番号を返すネイティブの電話番号ヒントUIを表示します。
例SMS
「例SMS」のセクション<#> 123456 is your verification code.FA+9qCX9VSu最終行にアプリ署名キー用のハッシュを置き換えてください。