ガイド
How to use Firebase Authentication in Capacitor
@capgo/capacitor-firebase-authentication
CapgoのCapacitorプラグインは、Firebase Authenticationをサポートしています。
インストール
bun add @capgo/capacitor-firebase-authentication
bunx cap sync
bunx cap sync プラグインのネイティブ code をあなたのネイティブ プロジェクトにコピーします。プラグインのアップグレード後は再度実行してください。
インポート
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
API を一目で
| 方法 | 説明 |
|---|---|
applyActionCode |
ユーザーにメールで送られた検証 code を適用します。 |
confirmPasswordReset |
パスワードリセットプロセスを完了します。 |
confirmVerificationCode |
電話番号検証プロセスを完了します。 |
createUserWithEmailAndPassword |
メールアドレスとパスワードで新しいユーザーアカウントを作成します。新しいアカウントが作成された場合、ユーザーは自動的にログインします。 |
deleteUser |
ユーザーを削除し、ログアウトします。 |
fetchSignInMethodsForEmail |
メールアドレスに対してサインイン方法を取得します。 |
getCurrentUser |
現在ログインしているユーザーを取得します。 |
getPendingAuthResult |
リターンします。 SignInResult アプリがWebサインインフローを実行した場合に、OSがアプリをバックグラウンドでクリーンアップした場合に返します。 |
getIdToken |
現在サインインしているユーザーのFirebase Auth IDトークンを取得します。 |
getIdTokenResult |
Firebaseサービスにユーザーを識別するために使用される、デシリアライズされたJSON Webトークン (JWT) を返します。 |
getRedirectResult |
リターンします。 SignInResult リダイレクトベースのサインインフローから取得します。 |
getTenantId |
テナントIDを取得します。 |
isSignInWithEmailLink |
メールアドレスでサインインするためのリンクが、以下の条件を満たしている場合にチェックします。 signInWithEmailLink. |
linkWithApple |
Apple認証プロバイダとユーザーアカウントをリンクします。 |
linkWithEmailAndPassword |
Email認証プロバイダとユーザーアカウントをリンクします。 |
linkWithEmailLink |
Email認証プロバイダとユーザーアカウントをリンクします。 |
linkWithFacebook |
Facebook認証プロバイダとユーザーアカウントをリンクします。 |
linkWithGameCenter |
Game Center認証プロバイダとユーザーアカウントをリンクします。 |
linkWithGithub |
GitHub認証プロバイダとユーザーアカウントをリンクします。 |
linkWithGoogle |
Google認証プロバイダとユーザーアカウントをリンクします。 |
linkWithMicrosoft |
Microsoft認証プロバイダとユーザーアカウントをリンクします。 |
linkWithOpenIdConnect |
OpenID Connectプロバイダとユーザーアカウントをリンクします。 |
linkWithPhoneNumber |
電話番号認証プロバイダとユーザーアカウントをリンクします。 |
linkWithPlayGames |
Play Games認証プロバイダとユーザーアカウントをリンクします。 |
linkWithTwitter |
Twitter認証プロバイダとユーザーアカウントをリンクします。 |
linkWithYahoo |
Yahoo認証プロバイダとユーザーアカウントをリンクします。 |
reload |
サインインしている場合にユーザーアカウントデータを再読み込みします。 |
revokeAccessToken |
指定されたアクセストークンを取り消します。現在はApple OAuthアクセストークンのみをサポートしています。 |
sendEmailVerification |
現在サインインしているユーザーに確認メールを送信します。 |
sendPasswordResetEmail |
パスワードリセットメールを送信します。 |
sendSignInLinkToEmail |
指定されたメールアドレスのユーザーにサインインメールリンクを送信します。 |
setLanguageCode |
認証操作で使用するユーザー向け言語を code に設定します。 |
setPersistence |
現在保存されている認証セッションの保存方法を設定します。 |
setTenantId |
テナントIDを設定します。 |
signInAnonymously |
匿名ユーザーとしてサインインします。 |
signInWithApple |
Appleサインインフローを開始します。 |
signInWithCustomToken |
カスタムトークンサインインフローを開始します。 |
signInWithEmailAndPassword |
メールアドレスとパスワードを使用してサインインフローを開始します。 |
signInWithEmailLink |
メールアドレスとサインインメールリンクを使用してサインインします。 |
signInWithFacebook |
Facebookサインインフローを開始します。 |
signInWithGameCenter |
Game Centerサインインフローを開始します。 |
signInWithGithub |
GitHubのサインインフローを開始します。 |
signInWithGoogle |
Googleのサインインフローを開始します。 |
signInWithMicrosoft |
Microsoftのサインインフローを開始します。 |
signInWithOpenIdConnect |
OpenID Connectのサインインフローを開始します。 |
signInWithPhoneNumber |
電話番号を使用したサインインフローを開始します。 |
signInWithPlayGames |
Play Gamesのサインインフローを開始します。 |
signInWithTwitter |
Twitterのサインインフローを開始します。 |
signInWithYahoo |
Yahooのサインインフローを開始します。 |
signOut |
サインアウトフローを開始します。 |
unlink |
プロバイダーをユーザーアカウントから削除します。 |
updateEmail |
現在サインインしているユーザーのメールアドレスを更新します。 |
updatePassword |
現在サインインしているユーザーのパスワードを更新します。 |
updateProfile |
ユーザープロファイルデータを更新します。 |
useAppLanguage |
ユーザー向けの言語をcodeをデフォルトのアプリ言語に設定します。 |
useEmulator |
アプリをAuthenticationエミュレータと通信するように設定します。 |
verifyBeforeUpdateEmail |
現在ログインしているユーザーのメールアドレスを更新する前に、新しいメールアドレスを検証します。 |
checkAppTrackingTransparencyPermission |
アプリのトラッキング透明性の現在のステータスを確認します。 |
requestAppTrackingTransparencyPermission |
アプリのトラッキング透明性の許可を求めるシステムダイアログを開きます。 |
例
applyActionCode()
メールで送られた検証用のcodeを適用します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.applyActionCode({ oobCode: 'oob-code' });
confirmPasswordReset()
ユーザーに送信されたメールで送信された検証__CAPGO_KEEP_0__を適用します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmPasswordReset({
oobCode: 'oob-code',
newPassword: 'new-password',
});
confirmVerificationCode()
パスワードリセットプロセスを完了します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.confirmVerificationCode({
verificationId: 'phoneCodeSent',
verificationCode: 'phoneCodeSent',
});
// The result holds sensitive values: use it without logging it.
createUserWithEmailAndPassword()
電話番号検証プロセスを完了します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.createUserWithEmailAndPassword({
email: 'user@example.com',
password: 'password',
});
// The result holds sensitive values: use it without logging it.
deleteUser()
メールアドレスとパスワードを使用して新しいユーザーアカウントを作成します。新しいアカウントが作成された場合、ユーザーは自動的にログインします。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.deleteUser();
fetchSignInMethodsForEmail()
メールアドレスのサインイン方法を取得します。
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.fetchSignInMethodsForEmail({ email: 'user@example.com' });
console.log(result);
上の表には、59のコアメソッドがリストされています。リスナーとバージョンヘルパー、各メソッドのフルコントラクトは、以下の__CAPGO_KEEP_0__リポジトリにドキュメントされています。 GitHub リポジトリ.
イベントをリスンする
addListener ハンドルを返します。画面がアンマウントされたとき、またはリスナーをすべてクリアしたいときは handle.remove() clear()を呼び出してください。 FirebaseAuthentication.removeAllListeners() フルリファレンス
ドキュメント
@capgo/capacitor-firebase-authentication
Capgoを使用している場合 @capgo/capacitor-firebase-authenticationを使用 authenticationを計画し、会員フローを接続するには @capgo/capacitor-ソーシャルログイン ソーシャルログインの実装詳細のために@capgo/capacitor-ソーシャルログイン @capgo/capacitor-パスキー @capgo/capacitor-パスキー実装詳細のために capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, 二要素認証 for the implementation detail in Two-factor authentication, and SSO (Enterprise) CapgoのSSO (Enterprise)実装の詳細について。