Getting Started
このプラグインのインストール手順とフルマークダウンガイドを含むセットアッププロンプトをコピーします。
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.
インストール
「インストール」のセクションAI-Assisted セットアップを使用してプラグインをインストールできます。AI ツールに Capgo スキルを追加するには、以下のコマンドを使用してください。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用してください:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-android-sms-retriever` plugin in my project.Manual Setup を使用する場合は、以下のコマンドを実行してプラットフォーム固有の指示に従ってください:
bun add @capgo/capacitor-android-sms-retrieverbunx cap sync androidインポート
「インポート」のセクションimport { AndroidSmsRetriever } from '@capgo/capacitor-android-sms-retriever';Android の要件
「Android の要件」のセクションSMS Retriever は Android デバイス上の Google Play サービスが必要です。プラグインは、SMS Retriever を要求しません。 READ_SMS または RECEIVE_SMS 権限。
アプリハッシュが含まれるSMSを確認する必要があります。 getHashString(). アプリを配布するために使用される署名キーを生成してください。
Debug、Release、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最終行にアプリ署名キー用のハッシュを置き換えてください。
Getting Startedから続けてください
セクション「Getting Startedから続けてください」Capgoを使用している場合 Getting Started ネイティブ プラグインの作業を計画するには、 ネイティブ機能のために@capgo/capacitor-android-sms-retrieverを使用する ネイティブ機能のために@capgo/capacitor-android-sms-retrieverを使用する Capgo プラグイン ディレクトリ Capgo プラグイン ディレクトリ Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 プラグインの追加または更新 Ionic Enterprise プラグインの代替 Ionic Enterprise プラグイン代替品の製品ワークフローについて。