メインコンテンツへスキップ
@capgo/capacitor-firebase-authentication 認証とセキュリティ オープンソース

Firebase Authentication Capacitor プラグイン

Firebase Authentication 用の Capacitor プラグイン

インストール

bun add @capgo/capacitor-firebase-authentication bunx cap sync
npm、pnpm、または yarn
  • npm install @capgo/capacitor-firebase-authentication
  • pnpm add @capgo/capacitor-firebase-authentication
  • yarn add @capgo/capacitor-firebase-authentication

ガイド

Capacitor で Firebase Authentication を使う方法

@capgo/capacitor-firebase-authentication の使用

Firebase Authentication 用の Capacitor プラグイン

インストール

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 Token を取得します。
getIdTokenResult Firebase サービスでユーザーを識別するために使用される、デシリアライズされた JSON Web Token (JWT) を返します。
getRedirectResult リダイレクトによるサインインフローから SignInResult を返します。
getTenantId テナントIDを取得します。
isSignInWithEmailLink Checks if an incoming link is a sign-in with email link suitable for 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 App Tracking Transparency の現在のステータスを確認します。
requestAppTrackingTransparencyPermission App Tracking Transparency の許可を求めるシステムダイアログを表示します。

例

applyActionCode()

メールでユーザーに送信された検証用 code を適用します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';

await FirebaseAuthentication.applyActionCode({ oobCode: 'oob-code' });

confirmPasswordReset()

パスワードリセット処理を完了します。

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個のコアメソッドを一覧にしています。Listenerとversionヘルパー、各メソッドの完全な仕様は次に記載されています。 GitHub リポジトリ.

イベントをリッスンする

addListener ハンドルを返します。画面がアンマウントされるときに handle.remove() 画面がアンマウントされるとき、または FirebaseAuthentication.removeAllListeners() すべてのリスナーを解除します。

完全なリファレンス

「@capgo/capacitor-firebase-authentication の使い方」から続ける

使用している場合 @capgo/capacitor-firebase-authentication の使用 認証とアカウントフローを計画するには、これを次と連携させてください @capgo/capacitor-social-login @capgo/capacitor-social-login の実装の詳細については、 @capgo/capacitor-passkey @capgo/capacitor-passkey の実装詳細については、 @capgo/capacitor-native-biometric @capgo/capacitor-native-biometric の実装の詳細については、 2要素認証 二要素認証の実装の詳細については、また、 SSO (エンタープライズ) SSO (Enterprise) の実装の詳細については。

よくある質問

Firebase Authentication プラグインの FAQ

Capacitor アプリに Firebase Authentication プラグインをインストールするにはどうすればよいですか?

"bun add @capgo/capacitor-firebase-authentication"(または "npm install @capgo/capacitor-firebase-authentication")を実行した後、"bunx cap sync" を実行して、iOS および Android プロジェクトにネイティブの code を反映させてください。その後、アプリの code から "@capgo/capacitor-firebase-authentication" をインポートします。

@capgo/capacitor-firebase-authentication は React、Vue、Angular で動作しますか?

はい。Firebase Authentication は Capacitor パッケージであるため、Ionic、React、Vue、Angular、Svelte、およびプレーンな JavaScript を含む、Capacitor 内で動作するあらゆる Web フレームワークで使用できます。

@capgo/capacitor-firebase-authentication はどの Capacitor バージョンをサポートしていますか?

Capgo プラグインは Capacitor のメジャーバージョンに合わせています。使用している Capacitor のメジャーバージョンに一致するプラグインのメジャーバージョンを使ってください (例: Capacitor 8 ならプラグイン v8)。GitHub の README にある互換性テーブルに、メンテナンス中のバージョンが記載されています。

@capgo/capacitor-firebase-authentication は無料のオープンソースですか?

はい。code のソースコードは GitHub の https://github.com/Cap-go/capacitor-firebase/tree/main/packages/authentication で公開されており、パッケージは npm から無料でインストールできます。バグ報告やプルリクエストをお待ちしています。

App Store の審査なしで、Firebase Authentication を使用している code をアップデートできますか?

プラグインのインストールやアップグレードはネイティブの code を変更するため、新しいストアビルドが必要です。その後は、プラグインを呼び出す JavaScript、HTML、CSS の変更を Capgo Live Updates で即座に配信できます。

アプリの審査を待たずに Firebase Authentication の変更をリリース

プラグインをストア用ビルドに組み込めば、Capgo live updates で JavaScript、HTML、CSS の変更を数分でユーザーに配信できます

Capgo から始める