メインコンテンツにスキップ

はじめに

ターミナル画面
bun add @capgo/capacitor-firebase-authentication
bunx cap sync
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';

codeを確認する

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.applyActionCode({} as ApplyActionCodeOptions);

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

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmPasswordReset({} as ConfirmPasswordResetOptions);

電話番号の検証プロセスを完了します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmVerificationCode({} as ConfirmVerificationCodeOptions);

メールとパスワードを使用して新しいユーザーアカウントを作成します。 新しいアカウントが作成された場合、ユーザーは自動的にログインされます。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.createUserWithEmailAndPassword({} as CreateUserWithEmailAndPasswordOptions);

ユーザーを削除してログアウトします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.deleteUser();

指定されたメールアドレスのサインイン方法を取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.fetchSignInMethodsForEmail({} as FetchSignInMethodsForEmailOptions);

現在サインインしているユーザーを取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getCurrentUser();

返します。 SignInResult アプリがWebサインインフローを開始し、OSがバックグラウンドでアプリをクリーンアップした場合。

Androidのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getPendingAuthResult();

現在サインインしているユーザーのFirebase Auth IDトークンを取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdToken();

ユーザーをFirebaseサービスに識別するために使用される、デシリアライズされたJSON Web Token (JWT)を返します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getIdTokenResult();

リダイレクトベースのサインインフローから SignInResult サインインが失敗した場合、エラーで失敗します。 リダイレクトオペレーションが呼び出されなかった場合、ユーザーがnullの場合に返されます。

Only available for Web. SignInResult クリップボードにコピー

getTenantIdセクション

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getRedirectResult();

テナントIDを取得します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.getTenantId();

メールアドレスでサインインするためのリンクが適切かどうかを確認します。 signInWithEmailLink.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.isSignInWithEmailLink({} as IsSignInWithEmailLinkOptions);

Apple認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithApple();

Email認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブ層でログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailAndPassword({} as LinkWithEmailAndPasswordOptions);

Email認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブ層でログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithEmailLink({} as LinkWithEmailLinkOptions);

Facebook認証プロバイダとユーザーアカウントをリンクします。

ユーザーはネイティブ層でログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithFacebook();

Game Center認証プロバイダとユーザーアカウントをリンクします。

ネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

iOSのみ

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGameCenter();

ユーザーアカウントをGitHub認証プロバイダとリンクします。

ネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGithub();

Google認証プロバイダーとユーザーアカウントをリンクします。

ネイティブレイヤーでログインしている必要があります。 skipNativeAuth このセクションでは、設定オプションの影響はありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithGoogle();

Microsoft認証プロバイダーとユーザーアカウントをリンクします。

ネイティブレイヤーでログインしている必要があります。 skipNativeAuth このセクションでは、設定オプションの影響はありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithMicrosoft();

OpenID Connect認証プロバイダーとユーザーアカウントをリンクします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithOpenIdConnect({} as LinkWithOpenIdConnectOptions);

電話番号認証プロバイダーとユーザーアカウントをリンクします。

ネイティブレイヤーでログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

検証が完了したときに通知を受け取るためのリスナーを使用してください。 phoneVerificationCompleted 検証が失敗したときに通知を受け取るためのリスナーを使用してください。 phoneVerificationFailed 検証IDを取得するためのリスナーを使用してください。 phoneCodeSent クリップボードにコピー

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPhoneNumber({} as LinkWithPhoneNumberOptions);

Section titled “linkWithApple”

native層でログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

Androidのみ対応です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPlayGames();

Twitter認証プロバイダとユーザーアカウントをリンクします。

native層でログインしている必要があります。 skipNativeAuth この設定オプションはここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithTwitter();

Yahoo認証プロバイダとユーザーアカウントをリンクします。

native層でログインしている必要があります。 skipNativeAuth __CAPGO_KEEP_0__はここでは効果がありません。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithYahoo();

サインインしている場合、ユーザーアカウントデータを再読み込みします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.reload();

指定されたアクセストークンを取り消します。現在はApple OAuthアクセストークンのみをサポートしています。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({} as RevokeAccessTokenOptions);

現在サインインしているユーザーにメールの確認を送信します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendEmailVerification();

パスワードリセットメールを送信します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({} as SendPasswordResetEmailOptions);

指定されたメールアドレスのユーザーに送信リンクを含むサインインメールを送信します。

メールリンクでサインインを完了するには、次の呼び出しを行ってください。 signInWithEmailLink 指定されたメールアドレスとメールに含まれるメールリンクを使用してください。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendSignInLinkToEmail({} as SendSignInLinkToEmailOptions);

認証オペレーションでユーザーに表示される言語codeを設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setLanguageCode({} as SetLanguageCodeOptions);

現在保存されている認証セッションの永続化の種類を設定します。

Only available for Web.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setPersistence({} as SetPersistenceOptions);

テナントIDを設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setTenantId({} as SetTenantIdOptions);

匿名ユーザーとしてログインします。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInAnonymously();

Appleのサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithApple();

カスタム トークン サインイン フローを開始します。

このメソッドは、AndroidおよびiOSで使用することができません。 この場合、Firebase JS __CAPGO_KEEP_0__の直接インターフェイスを使用する必要があります。 skipNativeAuth コピー signInWithCustomToken interface of the Firebase JS SDK directly.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithCustomToken({} as SignInWithCustomTokenOptions);

signInWithEmailAndPassword

コピー

「signInWithEmailLink」セクション

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailAndPassword({} as SignInWithEmailAndPasswordOptions);
コピー

「signInWithFacebook」セクション

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithEmailLink({} as SignInWithEmailLinkOptions);

Facebookでサインインのフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithFacebook();

Game Centerでサインインのフローを開始します。

iOSのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGameCenter();

Starts the GitHub sign-in flow.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGithub();

Googleでサインインのフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithGoogle();

Microsoftサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithMicrosoft();

OpenID Connectサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithOpenIdConnect({} as SignInWithOpenIdConnectOptions);

検証が完了したときに通知を受け取るリスナーを使用してください。

検証が失敗したときに通知を受け取るリスナーを使用してください。 phoneVerificationCompleted 検証IDを取得するリスナーを使用してください。 phoneVerificationFailed 検証IDを取得するリスナーを使用してください。 phoneCodeSent 検証が完了したときに通知を受け取るリスナーを使用してください。

AndroidおよびiOSのみ対応。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({} as SignInWithPhoneNumberOptions);

Play Gamesのサインインフローを開始します。

Androidのみ対応。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPlayGames();

Twitterのサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithTwitter();

Yahooのサインインフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithYahoo();

サインアウトのフローを開始します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signOut();

クリップボードにコピー

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.unlink({} as UnlinkOptions);

現在サインインしているユーザーのパスワードを更新

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({} as UpdateEmailOptions);

updatePassword

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({} as UpdatePasswordOptions);

ユーザーのプロファイルデータを更新します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({} as UpdateProfileOptions);

アプリの言語を code に設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useAppLanguage();

アプリをエミュレータと通信するように設定します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useEmulator({} as UseEmulatorOptions);

現在ログインしているユーザーのメールアドレスを更新する前に、新しいメールアドレスを確認します。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.verifyBeforeUpdateEmail({} as VerifyBeforeUpdateEmailOptions);

アプリのトラッキング透明性の現在の状態を確認します。

iOSのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.checkAppTrackingTransparencyPermission();

アプリのトラッキング透明性の許可を求めるシステムダイアログを開きます。

注意: ユーザーは、デバイスの設定でトラッキングの要求を無効にしている可能性があります。詳細は Appleのドキュメント.

iOSのみで利用可能です。

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.requestAppTrackingTransparencyPermission();

Type Reference

種類の参照
export interface ApplyActionCodeOptions {
/**
* A verification code sent to the user.
*
* @since 0.2.2
*/
oobCode: string;
}
export interface ConfirmPasswordResetOptions {
/**
* A verification code sent to the user.
*
* @since 0.2.2
*/
oobCode: string;
/**
* The new password.
*
* @since 0.2.2
*/
newPassword: string;
}
export interface ConfirmVerificationCodeOptions {
/**
* The verification ID received from the `phoneCodeSent` listener.
*
* The `verificationCode` option must also be provided.
*
* @since 5.0.0
*/
verificationId: string;
/**
* The verification code either received from the `phoneCodeSent` listener or entered by the user.
*
* The `verificationId` option must also be provided.
*
* @since 5.0.0
*/
verificationCode: string;
}
export interface SignInResult {
/**
* The currently signed-in user, or null if there isn't any.
*
* @since 0.1.0
*/
user: User | null;
/**
* Credentials returned by an auth provider.
*
* @since 0.1.0
*/
credential: AuthCredential | null;
/**
* Additional user information from a federated identity provider.
*
* @since 0.5.1
*/
additionalUserInfo: AdditionalUserInfo | null;
}
export interface CreateUserWithEmailAndPasswordOptions {
/**
* @since 0.2.2
*/
email: string;
/**
* @since 0.2.2
*/
password: string;
}
export interface FetchSignInMethodsForEmailOptions {
/**
* The user's email address.
*
* @since 6.0.0
*/
email: string;
}
export interface FetchSignInMethodsForEmailResult {
/**
* The sign-in methods for the specified email address.
*
* This list is empty when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection)
* is enabled, irrespective of the number of authentication methods available for the given email.
*
* @since 6.0.0
*/
signInMethods: string[];
}
export interface GetCurrentUserResult {
/**
* The currently signed-in user, or null if there isn't any.
*
* @since 0.1.0
*/
user: User | null;
}
export interface GetIdTokenOptions {
/**
* Force refresh regardless of token expiration.
*
* @since 0.1.0
*/
forceRefresh: boolean;
}
export interface GetIdTokenResult {
/**
* The Firebase Auth ID token JWT string.
*
* @since 0.1.0
*/
token: string;
}
export interface GetIdTokenResultOptions {
/**
* Force refresh regardless of token expiration.
*
* @since 7.4.0
*/
forceRefresh: boolean;
}
export interface GetIdTokenResultResult {
/**
* The authentication time in milliseconds since the epoch.
*
* This is the time the user authenticated (signed in) and not the time the token was refreshed.
*
* @since 7.4.0
*/
authTime: number;
/**
* The ID token expiration time in milliseconds since the epoch.
*
* @since 7.4.0
*/
expirationTime: number;
/**
* The ID token issuance time in milliseconds since the epoch.
*
* @since 7.4.0
*/
issuedAtTime: number;
/**
* The sign-in provider through which the ID token was obtained.
*
* @since 7.4.0
*/
signInProvider: string | null;
/**
* The type of second factor associated with this session, provided the user was multi-factor
* authenticated (eg. phone, etc).
*
* @since 7.4.0
*/
signInSecondFactor: string | null;
/**
* The entire payload claims of the ID token including the standard reserved claims as well as
* the custom claims.
*
* @since 7.4.0
*/
claims: Record<string, unknown>;
}

このページはプラグインから生成されています。 src/definitions.ts公開用の API がアップストリームで変更された場合に再度同期を実行してください。