Zum Inhalt springen

Getting Started

GitHub

Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie die Capgo Fähigkeiten Ihrem AI-Tool mit der folgenden Befehl hinzu:

Terminal-Fenster
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Dann verwenden Sie den folgenden Prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-authentication` plugin in my project.

Wenn Sie die manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und die darunter angegebenen Plattform-spezifischen Anweisungen befolgen:

Terminal-Fenster
bun add @capgo/capacitor-firebase-authentication
bunx cap sync
import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';

Eine Bestätigung des code sendet, die dem Benutzer per E-Mail zugesandt wurde.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.applyActionCode({ oobCode: 'oob-code' });

Abschließt den Passwortschutzprozess.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.confirmPasswordReset({
oobCode: 'oob-code',
newPassword: 'new-password',
});

Abschließt den Telefonnummernverifizierungsprozess.

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.

Erstellt ein neues Benutzerkonto mit E-Mail-Adresse und Passwort. Wenn das neue Konto erstellt wurde, wird der Benutzer automatisch eingeloggt.

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.

Löscht und meldet den Benutzer ab.

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

Holt die Anmeldemethoden für eine E-Mail-Adresse.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.fetchSignInMethodsForEmail({ email: 'user@example.com' });
console.log(result);

Liefert den derzeit angemeldeten Benutzer.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getCurrentUser();
// The result holds sensitive values: use it without logging it.

Gibt die SignInResult wenn Ihre App eine Web-Anmeldeflow gestartet hat und das Betriebssystem die App während des Hintergrunds bereinigt.

Nur für Android verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getPendingAuthResult();
// The result holds sensitive values: use it without logging it.

Liefert den Firebase Auth ID Token für den derzeit angemeldeten Benutzer.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getIdToken();
// The result holds sensitive values: use it without logging it.

Rückgibt ein deserialisiertes JSON-Web-Token (JWT), das verwendet wird, um den Benutzer bei einem Firebase-Dienst zu identifizieren.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getIdTokenResult();
// The result holds sensitive values: use it without logging it.

Rückgibt das SignInResult aus dem redirect-basierten Anmeldeprozess.

Wenn die Anmeldung fehlschlägt, fehlschlägt sie mit einem Fehler. Wenn keine Redirect-Operation aufgerufen wurde, wird ein SignInResult mit einem nullen Benutzer zurückgegeben.

Nur für Web verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getRedirectResult();
// The result holds sensitive values: use it without logging it.

Ermitteln Sie die Tenant-ID.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.getTenantId();
console.log(result);

Überprüft, ob ein eingehendes Link ein Anmelden mit E-Mail-Link ist, der für signInWithEmailLink.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.isSignInWithEmailLink({ emailLink: 'https://example.com' });
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit dem Apple-Authentifizierungsanbieter.

Der Benutzer muss auf der native Ebene angemeldet sein. Die skipNativeAuth Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithApple();
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit dem E-Mail-Authentifizierungsanbieter.

Der Benutzer muss auf der native Ebene angemeldet sein. Die skipNativeAuth Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithEmailAndPassword({
email: 'user@example.com',
password: 'password',
});
// The result holds sensitive values: use it without logging it.

Verknüpft das Benutzerkonto mit dem E-Mail-Authentifizierungsanbieter.

Der Benutzer muss auf der native Ebene angemeldet sein. Die skipNativeAuth Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithEmailLink({
email: 'user@example.com',
emailLink: 'https://example.com',
});
// The result holds sensitive values: use it without logging it.

Verknüpft das Benutzerkonto mit dem Facebook-Authentifizierungsanbieter.

Der Benutzer muss auf der native Ebene angemeldet sein. Die skipNativeAuth Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithFacebook();
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit dem Game Center-Authentifizierungsanbieter.

Der Benutzer muss auf der native Layer angemeldet sein. Der skipNativeAuth Diese Konfigurationsoption hat hier keinen Einfluss.

Nur für iOS verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithGameCenter();
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit GitHub-Authentifizierungsanbieter.

Der Benutzer muss auf der native Layer angemeldet sein. Der skipNativeAuth Diese Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithGithub();
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit dem Google-Authentifizierungsanbieter.

Der Benutzer muss sich auf der native Ebene angemeldet haben. Der skipNativeAuth Diese Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithGoogle();
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit dem Microsoft-Authentifizierungsanbieter.

Der Benutzer muss sich auf der native Ebene angemeldet haben. Der skipNativeAuth Diese Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithMicrosoft();
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit einem OpenID-Connect-Anbieter.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithOpenIdConnect({ providerId: 'provider-id-123' });
// The result holds sensitive values: use it without logging it.

Verbindet das Benutzerkonto mit der Telefonnummer-Authentifizierungsanbieter.

Der Benutzer muss sich auf der native Ebene angemeldet haben. skipNativeAuth Die Konfigurationsoption hat hier keinen Einfluss.

Verwende den phoneVerificationCompleted Hörer, um benachrichtigt zu werden, wenn die Verifizierung abgeschlossen ist. phoneVerificationFailed Hörer, um benachrichtigt zu werden, wenn die Verifizierung fehlgeschlagen ist. phoneCodeSent Hörer, um den Verifizierungscode zu erhalten.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.linkWithPhoneNumber({ phoneNumber: "+16505550101" });

Verbindet das Benutzerkonto mit dem Play Games-Authentifizierungsanbieter.

Der Benutzer muss sich auf der native Ebene angemeldet haben. skipNativeAuth Die Konfigurationsoption hat hier keinen Einfluss.

Nur für Android verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithPlayGames();
// The result holds sensitive values: use it without logging it.

Verknüpft das Benutzerkonto mit dem Twitter-Authentifizierungsanbieter.

Der Benutzer muss auf der native Ebene angemeldet sein. Die skipNativeAuth Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithTwitter();
// The result holds sensitive values: use it without logging it.

Verknüpft das Benutzerkonto mit dem Yahoo-Authentifizierungsanbieter.

Der Benutzer muss auf der native Ebene angemeldet sein. Die skipNativeAuth Konfigurationsoption hat hier keinen Einfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.linkWithYahoo();
// The result holds sensitive values: use it without logging it.

Aktualisiert Benutzerkontodaten, wenn angemeldet.

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

Widerruft den angegebenen Zugriffstoken. Aktuell nur Apple OAuth-Zugriffstoken unterstützt.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.revokeAccessToken({ token: 'token-123' });

Sendet eine Verifizierungs-E-Mail an den derzeit angemeldeten Benutzer.

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

Sendet eine E-Mail zur Passwort-Neudefinition.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendPasswordResetEmail({ email: 'user@example.com' });

Sendet einen Anmelde-Link per E-Mail an den Benutzer mit der angegebenen E-Mail-Adresse.

Um den Anmeldevorgang mit dem E-Mail-Link abzuschließen, rufen Sie signInWithEmailLink mit der E-Mail-Adresse und dem E-Mail-Link auf, der dem Benutzer in der E-Mail zugesendet wurde.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.sendSignInLinkToEmail({
email: 'user@example.com',
actionCodeSettings: { url: 'https://example.com' },
});

Setzt die Benutzerfassungssprache code für Auth-Bereiche.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setLanguageCode({ languageCode: "en-US" });

Setzt den Typ der Persistenz für die derzeit gespeicherte Auth-Sitzung.

Nur für Web verfügbar.

import { FirebaseAuthentication, Persistence } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setPersistence({ persistence: Persistence.IndexedDbLocal });

Setzt die Tenant-ID.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.setTenantId({ tenantId: 'tenant-id-123' });

Als anonymer Benutzer anmelden.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInAnonymously();
// The result holds sensitive values: use it without logging it.

Startet den Apple-Anmeldungsfluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithApple();
// The result holds sensitive values: use it without logging it.

Startet den Custom Token-Anmeldungsfluss.

Dieser Methode kann nicht in Combination mit skipNativeAuth auf Android- und iOS-Geräten. In diesem Fall müssen Sie die signInWithCustomToken direkt an der Firebase JS SDK-Schnittstelle verwenden.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithCustomToken({ token: 'token-123' });
// The result holds sensitive values: use it without logging it.

Startet den Anmeldeprozess mithilfe einer E-Mail-Adresse und eines Passworts.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithEmailAndPassword({
email: 'user@example.com',
password: 'password',
});
// The result holds sensitive values: use it without logging it.

Mithilfe eines E-Mail-Kontos und eines E-Mail-Anmelde-Link.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithEmailLink({
email: 'user@example.com',
emailLink: 'https://example.com',
});
// The result holds sensitive values: use it without logging it.

Startet das Facebook-Anmeldeverfahren.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithFacebook();
// The result holds sensitive values: use it without logging it.

Startet den Game Center-Anmeldefluss.

Verfügbar nur für iOS.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithGameCenter();
// The result holds sensitive values: use it without logging it.

Startet den GitHub-Anmeldefluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithGithub();
// The result holds sensitive values: use it without logging it.

Startet den Google-Anmeldefluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithGoogle();
// The result holds sensitive values: use it without logging it.

Startet den Microsoft-Anmeldefluss.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithMicrosoft();
// The result holds sensitive values: use it without logging it.

Der OpenID-Connect-Anmeldeprozess wird gestartet.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithOpenIdConnect({ providerId: 'provider-id-123' });
// The result holds sensitive values: use it without logging it.

Der Anmeldeprozess mit einer Telefonnummer wird gestartet.

Verwende das phoneVerificationCompleted Hörer, der benachrichtigt wird, wenn die Überprüfung abgeschlossen ist.\nVerwenden Sie phoneVerificationFailed Hinweis-Listener, um benachrichtigt zu werden, wenn die Überprüfung fehlschlägt. phoneCodeSent Nur für Android und iOS verfügbar.

Nur für Android und iOS verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.signInWithPhoneNumber({ phoneNumber: "+16505550101" });

Startet den Anmeldefluss für Play Games.

Nur für Android verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithPlayGames();
// The result holds sensitive values: use it without logging it.

Startet den Anmeldefluss für Twitter.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithTwitter();
// The result holds sensitive values: use it without logging it.

Startet den Anmeldefluss für Yahoo.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.signInWithYahoo();
// The result holds sensitive values: use it without logging it.

Startet den Abmeldefluss.

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

Entkoppelt einen Anbieter von einem Benutzerkonto.

import { FirebaseAuthentication, ProviderId } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.unlink({ providerId: ProviderId.APPLE });
// The result holds sensitive values: use it without logging it.

Aktualisiert die E-Mail-Adresse des aktuellen angemeldeten Benutzers.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateEmail({ newEmail: 'user@example.com' });

Aktualisiert das Passwort des aktuellen angemeldeten Benutzers.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updatePassword({ newPassword: 'new-password' });

Aktualisiert die Benutzerprofil-Daten.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.updateProfile({
displayName: 'display',
photoUrl: 'https://example.com',
});

Setzt die Benutzerfachsprache code als Standardanwendungsprache.

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

Instrumentiert die Anwendung, um mit dem Authentifizierungsimulator zu kommunizieren.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.useEmulator({ host: "127.0.0.1" });

Überprüft die neue E-Mail-Adresse, bevor die E-Mail-Adresse des aktuellen angemeldeten Benutzers aktualisiert wird.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
await FirebaseAuthentication.verifyBeforeUpdateEmail({ newEmail: 'user@example.com' });

Überprüft den aktuellen Status der Anwendungsverfolgungstransparenz.

Nur auf iOS verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.checkAppTrackingTransparencyPermission();
console.log(result);

Öffnet das Systemdialogfeld, um die App-Tracking-Transparenz zu autorisieren.

Achtung: Der Benutzer hat möglicherweise die Trackinganfrage in den Geräte-Einstellungen deaktiviert, siehe Dokumentation von Apple.

Nur auf iOS verfügbar.

import { FirebaseAuthentication } from '@capgo/capacitor-firebase-authentication';
const result = await FirebaseAuthentication.requestAppTrackingTransparencyPermission();
console.log(result);
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;
}

CreateUserWithEmailAndPasswordOptions

Benennung "CreateUserWithEmailAndPasswordOptions"
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>;
}

Diese Seite wurde aus dem Plugin generiert. src/definitions.tsRe-run die Synchronisierung, wenn die öffentliche API sich im Hintergrund ändert.

Wenn Sie sich für die Verwendung von Getting Started um die Authentifizierung und die Kontenflüsse zu planen, mit ihm zu verbinden @capgo/capacitor-Social-Login um die Implementierungsdetails in @capgo/capacitor-social-login zu erhalten. @capgo/capacitor-Passkey um die Implementierungsdetails in @capgo/capacitor-passkey zu erhalten. @capgo/capacitor-native-biometrisch für die Implementierungsdetails in @capgo/capacitor-native-biometrisch Zweifaktor-Authentifizierung für die Implementierungsdetails in Zweifaktor-Authentifizierung und SSO (Unternehmen) für die Implementierungsdetails in SSO (Unternehmen).