Capacitor plugin for Firebase Authentication.
npm install @capacitor-firebase/authenticationUnofficial Capacitor plugin for Firebase Authentication.[^1]
| Plugin Version | Capacitor Version | Status |
| -------------- | ----------------- | -------------- |
| 8.x.x | >=8.x.x | Active support |
| 7.x.x | 7.x.x | Deprecated |
| 6.x.x | 6.x.x | Deprecated |
| 5.x.x | 5.x.x | Deprecated |
| 1.x.x | 4.x.x | Deprecated |
``bash`
npm install @capacitor-firebase/authentication firebase
npx cap sync
Add Firebase to your project if you haven't already (Android / iOS / Web).
On iOS, verify that this function is included in your app's AppDelegate.swift:
`swift`
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
Attention: If you use this plugin on iOS in combination with @capacitor-firebase/messaging, then add the following to your app's AppDelegate.swift:
`diff
+ import FirebaseAuth
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
+ if Auth.auth().canHandle(url) {
+ return true
+ }
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
`
The further installation steps depend on the selected authentication method:
- Apple Sign-In
- Facebook Sign-In
- Game Center Sign-In
- GitHub Sign-In
- Google Sign-In
- Microsoft Sign-In
- OpenID Connect Sign-In
- Play Games Sign-In
- Twitter Sign-In
- Yahoo Sign-In
- Anonymous Sign-In
- Email Link Sign-In
- Phone Number Sign-In
- Custom Token Sign-In
Attention: Please note that this plugin uses third-party SDKs to offer native sign-in.
These SDKs can initialize on their own and collect various data.
For more information, see Third-Party SDKs.
These configuration values are available:
| Prop | Type | Description | Default | Since |
| -------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
| authDomain | string | Configure the custom auth domain you want to use. Only available for Android and iOS. | | 7.3.0 |
| skipNativeAuth | boolean | Configure whether the plugin should skip the native authentication. Only needed if you want to use the Firebase JavaScript SDK. This configuration option has no effect on Firebase account linking. Note that the plugin may behave differently across the platforms. Only available for Android and iOS. | false | 0.1.0 |
| providers | string[] | Configure the providers that should be loaded by the plugin. Possible values: ["apple.com", "facebook.com", "gc.apple.com", "github.com", "google.com", "microsoft.com", "playgames.google.com", "twitter.com", "yahoo.com", "phone"] Only available for Android and iOS. | [] | 0.1.0 |
In capacitor.config.json:
`json`
{
"plugins": {
"FirebaseAuthentication": {
"authDomain": undefined,
"skipNativeAuth": false,
"providers": ["apple.com", "facebook.com"]
}
}
}
In capacitor.config.ts:
`ts
///
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
FirebaseAuthentication: {
authDomain: undefined,
skipNativeAuth: false,
providers: ["apple.com", "facebook.com"],
},
},
};
export default config;
`
1. What does this plugin do?
This plugin enables the use of Firebase Authentication in a Capacitor app.
It uses the Firebase SDK for Java (Android), Swift (iOS) and JavaScript.
1. What is the difference between the web implementation of this plugin and the Firebase JS SDK?
The web implementation of this plugin encapsulates the Firebase JS SDK and enables a consistent interface across all platforms.
You can decide if you prefer to use the web implementation or the Firebase JS SDK.
1. What is the difference between the native and web authentication?
For web authentication, the Firebase JS SDK is used. This only works to a limited extent on Android and iOS in the WebViews (see here).
For native authentication, the native SDKs from Firebase, Google, etc. are used.
These offer all the functionalities that the Firebase JS SDK also offers on the web.
However, after a login with the native SDK, the user is only logged in on the native layer of the app.
If the user should also be logged in on the web layer (for example to access Cloud Firestore via Firebase JS SDK), additional steps are required (see here).
1. How can I use this plugin with the Firebase JavaScript SDK?
See here.
Here you can find information on how to use the plugin with the Firebase JS SDK.
A working example can be found here: robingenz/capacitor-firebase-authentication-demo
The following starter templates are available:
`typescript
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const applyActionCode = async () => {
await FirebaseAuthentication.applyActionCode({ oobCode: '1234' });
};
const createUserWithEmailAndPassword = async () => {
const result = await FirebaseAuthentication.createUserWithEmailAndPassword({
email: 'mail@exmaple.com',
password: '1234',
});
return result.user;
};
const confirmPasswordReset = async () => {
await FirebaseAuthentication.confirmPasswordReset({
oobCode: '1234',
newPassword: '4321',
});
};
const deleteUser = async () => {
await FirebaseAuthentication.deleteUser();
};
const fetchSignInMethodsForEmail = async () => {
const result = await FirebaseAuthentication.fetchSignInMethodsForEmail({
email: 'mail@example.tld',
});
return result.signInMethods;
};
const getCurrentUser = async () => {
const result = await FirebaseAuthentication.getCurrentUser();
return result.user;
};
const getPendingAuthResult = async () => {
const result = await FirebaseAuthentication.getPendingAuthResult();
return result.user;
};
const getIdToken = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
const result = await FirebaseAuthentication.getIdToken();
return result.token;
};
const getPendingAuthResult = async () => {
const result = await FirebaseAuthentication.getPendingAuthResult();
return result.user;
};
const sendEmailVerification = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.sendEmailVerification();
};
const sendPasswordResetEmail = async () => {
await FirebaseAuthentication.sendPasswordResetEmail({
email: 'mail@example.com',
});
};
const sendSignInLinkToEmail = async () => {
const email = 'mail@example.com';
await FirebaseAuthentication.sendSignInLinkToEmail({
email,
actionCodeSettings: {
// URL you want to redirect back to. The domain (www.example.com) for this
// URL must be in the authorized domains list in the Firebase Console.
url: 'https://www.example.com/finishSignUp?cartId=1234',
// This must be true.
handleCodeInApp: true,
iOS: {
bundleId: 'com.example.ios',
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12',
},
dynamicLinkDomain: 'example.page.link',
},
});
// The link was successfully sent. Inform the user.
// Save the email locally so you don't need to ask the user for it again
// if they open the link on the same device.
window.localStorage.setItem('emailForSignIn', email);
};
const setLanguageCode = async () => {
await FirebaseAuthentication.setLanguageCode({ languageCode: 'en-US' });
};
const signInAnonymously = async () => {
const result = await FirebaseAuthentication.signInAnonymously();
return result.user;
};
const signInWithApple = async () => {
const result = await FirebaseAuthentication.signInWithApple();
return result.user;
};
const signInWithCustomToken = async () => {
const result = await FirebaseAuthentication.signInWithCustomToken({
token: '1234',
});
return result.user;
};
const signInWithEmailAndPassword = async () => {
const result = await FirebaseAuthentication.signInWithEmailAndPassword({
email: 'mail@example.com',
password: '1234',
});
return result.user;
};
const signInWithEmailLink = async () => {
// Get the email if available. This should be available if the user completes
// the flow on the same device where they started it.
const emailLink = window.location.href;
// Confirm the link is a sign-in with email link.
const { isSignInWithEmailLink } =
await FirebaseAuthentication.isSignInWithEmailLink({
emailLink,
});
if (!isSignInWithEmailLink) {
return;
}
let email = window.localStorage.getItem('emailForSignIn');
if (!email) {
// User opened the link on a different device. To prevent session fixation
// attacks, ask the user to provide the associated email again.
email = window.prompt('Please provide your email for confirmation.');
}
// The client SDK will parse the code from the link for you.
const result = await FirebaseAuthentication.signInWithEmailLink({
email,
emailLink,
});
// Clear email from storage.
window.localStorage.removeItem('emailForSignIn');
return result.user;
};
const signInWithFacebook = async () => {
const result = await FirebaseAuthentication.signInWithFacebook();
return result.user;
};
const signInWithGameCenter = async () => {
const result = await FirebaseAuthentication.signInWithGameCenter();
return result.user;
};
const signInWithGithub = async () => {
const result = await FirebaseAuthentication.signInWithGithub();
return result.user;
};
const signInWithGoogle = async () => {
const result = await FirebaseAuthentication.signInWithGoogle();
return result.user;
};
const signInWithMicrosoft = async () => {
const result = await FirebaseAuthentication.signInWithMicrosoft();
return result.user;
};
const signInWithOpenIdConnect = async () => {
const result = await FirebaseAuthentication.signInWithOpenIdConnect({
providerId: 'oidc.example.com',
});
return result.user;
};
const signInWithPlayGames = async () => {
const result = await FirebaseAuthentication.signInWithPlayGames();
return result.user;
};
const signInWithPhoneNumber = async () => {
return new Promise(async resolve => {
// Attach phoneCodeSent listener to be notified as soon as the SMS is sentphoneVerificationCompleted
await FirebaseAuthentication.addListener('phoneCodeSent', async event => {
// Ask the user for the SMS code
const verificationCode = window.prompt(
'Please enter the verification code that was sent to your mobile device.',
);
// Confirm the verification code
const result = await FirebaseAuthentication.confirmVerificationCode({
verificationId: event.verificationId,
verificationCode,
});
resolve(result.user);
});
// Attach listener to be notified if phone verification could be finished automatically
await FirebaseAuthentication.addListener(
'phoneVerificationCompleted',
async event => {
resolve(event.result.user);
},
);
// Start sign in with phone number and send the SMS
await FirebaseAuthentication.signInWithPhoneNumber({
phoneNumber: '123456789',
});
});
};
const signInWithTwitter = async () => {
const result = await FirebaseAuthentication.signInWithTwitter();
return result.user;
};
const signInWithYahoo = async () => {
const result = await FirebaseAuthentication.signInWithYahoo();
return result.user;
};
const signOut = async () => {
await FirebaseAuthentication.signOut();
};
const updateEmail = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.updateEmail({
newEmail: 'new.mail@example.com',
});
};
const updatePassword = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.updatePassword({
newPassword: '4321',
});
};
const useAppLanguage = async () => {
await FirebaseAuthentication.useAppLanguage();
};
const useEmulator = async () => {
await FirebaseAuthentication.useEmulator({
host: '10.0.2.2',
port: 9099,
});
};
const verifyBeforeUpdateEmail = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.verifyBeforeUpdateEmail({
newEmail: 'new.mail@example.com',
actionCodeSettings: {
url: 'https://www.example.com/cart?email=user@example.com&cartId=123',
iOS: {
bundleId: 'com.example.ios'
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12'
},
handleCodeInApp: true
}
});
};
`
* applyActionCode(...)
* confirmPasswordReset(...)
* confirmVerificationCode(...)
* createUserWithEmailAndPassword(...)
* deleteUser()
* fetchSignInMethodsForEmail(...)
* getCurrentUser()
* getPendingAuthResult()
* getIdToken(...)
* getIdTokenResult(...)
* getRedirectResult()
* getTenantId()
* isSignInWithEmailLink(...)
* linkWithApple(...)
* linkWithEmailAndPassword(...)
* linkWithEmailLink(...)
* linkWithFacebook(...)
* linkWithGameCenter(...)
* linkWithGithub(...)
* linkWithGoogle(...)
* linkWithMicrosoft(...)
* linkWithOpenIdConnect(...)
* linkWithPhoneNumber(...)
* linkWithPlayGames(...)
* linkWithTwitter(...)
* linkWithYahoo(...)
* reload()
* revokeAccessToken(...)
* sendEmailVerification(...)
* sendPasswordResetEmail(...)
* sendSignInLinkToEmail(...)
* setLanguageCode(...)
* setPersistence(...)
* setTenantId(...)
* signInAnonymously()
* signInWithApple(...)
* signInWithCustomToken(...)
* signInWithEmailAndPassword(...)
* signInWithEmailLink(...)
* signInWithFacebook(...)
* signInWithGameCenter(...)
* signInWithGithub(...)
* signInWithGoogle(...)
* signInWithMicrosoft(...)
* signInWithOpenIdConnect(...)
* signInWithPhoneNumber(...)
* signInWithPlayGames(...)
* signInWithTwitter(...)
* signInWithYahoo(...)
* signOut()
* unlink(...)
* updateEmail(...)
* updatePassword(...)
* updateProfile(...)
* useAppLanguage()
* useEmulator(...)
* verifyBeforeUpdateEmail(...)
* checkAppTrackingTransparencyPermission()
* requestAppTrackingTransparencyPermission()
* addListener('authStateChange', ...)
* addListener('idTokenChange', ...)
* addListener('phoneVerificationCompleted', ...)
* addListener('phoneVerificationFailed', ...)
* addListener('phoneCodeSent', ...)
* removeAllListeners()
* Interfaces
* Type Aliases
* Enums
`typescript`
applyActionCode(options: ApplyActionCodeOptions) => Promise
Applies a verification code sent to the user by email.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | ApplyActionCodeOptions |
Since: 0.2.2
--------------------
`typescript`
confirmPasswordReset(options: ConfirmPasswordResetOptions) => Promise
Completes the password reset process.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------- |
| options | ConfirmPasswordResetOptions |
Since: 0.2.2
--------------------
`typescript`
confirmVerificationCode(options: ConfirmVerificationCodeOptions) => Promise
Finishes the phone number verification process.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
| options | ConfirmVerificationCodeOptions |
Returns: Promise<SignInResult>
Since: 5.0.0
--------------------
`typescript`
createUserWithEmailAndPassword(options: CreateUserWithEmailAndPasswordOptions) => Promise
Creates a new user account with email and password.
If the new account was created, the user is signed in automatically.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------------- |
| options | CreateUserWithEmailAndPasswordOptions |
Returns: Promise<SignInResult>
Since: 0.2.2
--------------------
`typescript`
deleteUser() => Promise
Deletes and signs out the user.
Since: 1.3.0
--------------------
`typescript`
fetchSignInMethodsForEmail(options: FetchSignInMethodsForEmailOptions) => Promise
Fetches the sign-in methods for an email address.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------- |
| options | FetchSignInMethodsForEmailOptions |
Returns: Promise<FetchSignInMethodsForEmailResult>
Since: 6.0.0
--------------------
`typescript`
getCurrentUser() => Promise
Fetches the currently signed-in user.
Returns: Promise<GetCurrentUserResult>
Since: 0.1.0
--------------------
`typescript`
getPendingAuthResult() => Promise
Returns the SignInResult if your app launched a web sign-in flow and the OS cleans up the app while in the background.
Only available for Android.
Returns: Promise<SignInResult>
Since: 6.0.0
--------------------
`typescript`
getIdToken(options?: GetIdTokenOptions | undefined) => Promise
Fetches the Firebase Auth ID Token for the currently signed-in user.
| Param | Type |
| ------------- | --------------------------------------------------------------- |
| options | GetIdTokenOptions |
Returns: Promise<GetIdTokenResult>
Since: 0.1.0
--------------------
`typescript`
getIdTokenResult(options?: GetIdTokenResultOptions | undefined) => Promise
Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.
| Param | Type |
| ------------- | --------------------------------------------------------------------------- |
| options | GetIdTokenResultOptions |
Returns: Promise<GetIdTokenResultResult>
Since: 7.4.0
--------------------
`typescript`
getRedirectResult() => Promise
Returns the SignInResult from the redirect-based sign-in flow.
If sign-in was unsuccessful, fails with an error.
If no redirect operation was called, returns a SignInResult with a null user.
Only available for Web.
Returns: Promise<SignInResult>
Since: 1.3.0
--------------------
`typescript`
getTenantId() => Promise
Get the tenant id.
Returns: Promise<GetTenantIdResult>
Since: 1.1.0
--------------------
`typescript`
isSignInWithEmailLink(options: IsSignInWithEmailLinkOptions) => Promise
Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| options | IsSignInWithEmailLinkOptions |
Returns: Promise<IsSignInWithEmailLinkResult>
Since: 1.1.0
--------------------
`typescript`
linkWithApple(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Apple authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithEmailAndPassword(options: LinkWithEmailAndPasswordOptions) => Promise
Links the user account with Email authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------- |
| options | LinkWithEmailAndPasswordOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithEmailLink(options: LinkWithEmailLinkOptions) => Promise
Links the user account with Email authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------- |
| options | LinkWithEmailLinkOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithFacebook(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Facebook authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithGameCenter(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Game Center authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
Only available for iOS.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.3.0
--------------------
`typescript`
linkWithGithub(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with GitHub authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithGoogle(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Google authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithMicrosoft(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Microsoft authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithOpenIdConnect(options: LinkWithOpenIdConnectOptions) => Promise
Links the user account with an OpenID Connect provider.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
| options | SignInWithOpenIdConnectOptions |
Returns: Promise<SignInResult>
Since: 6.1.0
--------------------
`typescript`
linkWithPhoneNumber(options: LinkWithPhoneNumberOptions) => Promise
Links the user account with Phone Number authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
Use the phoneVerificationCompleted listener to be notified when the verification is completed.phoneVerificationFailed
Use the listener to be notified when the verification is failed.phoneCodeSent
Use the listener to get the verification id.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| options | SignInWithPhoneNumberOptions |
Since: 1.1.0
--------------------
`typescript`
linkWithPlayGames(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Play Games authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
Only available for Android.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithTwitter(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Twitter authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
linkWithYahoo(options?: SignInWithOAuthOptions | undefined) => Promise
Links the user account with Yahoo authentication provider.
The user must be logged in on the native layer.
The skipNativeAuth configuration option has no effect here.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
reload() => Promise
Reloads user account data, if signed in.
Since: 1.3.0
--------------------
`typescript`
revokeAccessToken(options: RevokeAccessTokenOptions) => Promise
Revokes the given access token. Currently only supports Apple OAuth access tokens.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------- |
| options | RevokeAccessTokenOptions |
Since: 6.1.0
--------------------
`typescript`
sendEmailVerification(options?: SendEmailVerificationOptions | undefined) => Promise
Sends a verification email to the currently signed in user.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| options | SendEmailVerificationOptions |
Since: 0.2.2
--------------------
`typescript`
sendPasswordResetEmail(options: SendPasswordResetEmailOptions) => Promise
Sends a password reset email.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------- |
| options | SendPasswordResetEmailOptions |
Since: 0.2.2
--------------------
`typescript`
sendSignInLinkToEmail(options: SendSignInLinkToEmailOptions) => Promise
Sends a sign-in email link to the user with the specified email.
To complete sign in with the email link, call signInWithEmailLink with the email address and the email link supplied in the email sent to the user.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| options | SendSignInLinkToEmailOptions |
Since: 1.1.0
--------------------
`typescript`
setLanguageCode(options: SetLanguageCodeOptions) => Promise
Sets the user-facing language code for auth operations.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SetLanguageCodeOptions |
Since: 0.1.0
--------------------
`typescript`
setPersistence(options: SetPersistenceOptions) => Promise
Sets the type of persistence for the currently saved auth session.
Only available for Web.
| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options | SetPersistenceOptions |
Since: 5.2.0
--------------------
`typescript`
setTenantId(options: SetTenantIdOptions) => Promise
Sets the tenant id.
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | SetTenantIdOptions |
Since: 1.1.0
--------------------
`typescript`
signInAnonymously() => Promise
Signs in as an anonymous user.
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
signInWithApple(options?: SignInWithOAuthOptions | undefined) => Promise
Starts the Apple sign-in flow.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithCustomToken(options: SignInWithCustomTokenOptions) => Promise
Starts the Custom Token sign-in flow.
This method cannot be used in combination with skipNativeAuth on Android and iOS.signInWithCustomToken
In this case you have to use the interface of the Firebase JS SDK directly.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| options | SignInWithCustomTokenOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithEmailAndPassword(options: SignInWithEmailAndPasswordOptions) => Promise
Starts the sign-in flow using an email and password.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------- |
| options | SignInWithEmailAndPasswordOptions |
Returns: Promise<SignInResult>
Since: 0.2.2
--------------------
`typescript`
signInWithEmailLink(options: SignInWithEmailLinkOptions) => Promise
Signs in using an email and sign-in email link.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------- |
| options | SignInWithEmailLinkOptions |
Returns: Promise<SignInResult>
Since: 1.1.0
--------------------
`typescript`
signInWithFacebook(options?: SignInWithFacebookOptions | undefined) => Promise
Starts the Facebook sign-in flow.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| options | SignInWithFacebookOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithGameCenter(options?: SignInWithOAuthOptions | SignInOptions | undefined) => Promise
Starts the Game Center sign-in flow.
Only available for iOS.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions \| SignInOptions |
Returns: Promise<SignInResult>
Since: 1.3.0
--------------------
`typescript`
signInWithGithub(options?: SignInWithOAuthOptions | undefined) => Promise
Starts the GitHub sign-in flow.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithGoogle(options?: SignInWithGoogleOptions | undefined) => Promise
Starts the Google sign-in flow.
| Param | Type |
| ------------- | --------------------------------------------------------------------------- |
| options | SignInWithGoogleOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithMicrosoft(options?: SignInWithOAuthOptions | undefined) => Promise
Starts the Microsoft sign-in flow.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithOpenIdConnect(options: SignInWithOpenIdConnectOptions) => Promise
Starts the OpenID Connect sign-in flow.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
| options | SignInWithOpenIdConnectOptions |
Returns: Promise<SignInResult>
Since: 6.1.0
--------------------
`typescript`
signInWithPhoneNumber(options: SignInWithPhoneNumberOptions) => Promise
Starts the sign-in flow using a phone number.
Use the phoneVerificationCompleted listener to be notified when the verification is completed.phoneVerificationFailed
Use the listener to be notified when the verification is failed.phoneCodeSent
Use the listener to get the verification id.
Only available for Android and iOS.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| options | SignInWithPhoneNumberOptions |
Since: 0.1.0
--------------------
`typescript`
signInWithPlayGames(options?: SignInWithOAuthOptions | undefined) => Promise
Starts the Play Games sign-in flow.
Only available for Android.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithTwitter(options?: SignInWithOAuthOptions | undefined) => Promise
Starts the Twitter sign-in flow.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signInWithYahoo(options?: SignInWithOAuthOptions | undefined) => Promise
Starts the Yahoo sign-in flow.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | SignInWithOAuthOptions |
Returns: Promise<SignInResult>
Since: 0.1.0
--------------------
`typescript`
signOut() => Promise
Starts the sign-out flow.
Since: 0.1.0
--------------------
`typescript`
unlink(options: UnlinkOptions) => Promise
Unlinks a provider from a user account.
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | UnlinkOptions |
Returns: Promise<UnlinkResult>
Since: 1.1.0
--------------------
`typescript`
updateEmail(options: UpdateEmailOptions) => Promise
Updates the email address of the currently signed in user.
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | UpdateEmailOptions |
Since: 0.1.0
--------------------
`typescript`
updatePassword(options: UpdatePasswordOptions) => Promise
Updates the password of the currently signed in user.
| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options | UpdatePasswordOptions |
Since: 0.1.0
--------------------
`typescript`
updateProfile(options: UpdateProfileOptions) => Promise
Updates a user's profile data.
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| options | UpdateProfileOptions |
Since: 1.3.0
--------------------
`typescript`
useAppLanguage() => Promise
Sets the user-facing language code to be the default app language.
Since: 0.1.0
--------------------
`typescript`
useEmulator(options: UseEmulatorOptions) => Promise
Instrument your app to talk to the Authentication emulator.
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | UseEmulatorOptions |
Since: 0.2.0
--------------------
`typescript`
verifyBeforeUpdateEmail(options: VerifyBeforeUpdateEmailOptions) => Promise
Verifies the new email address before updating the email address of the currently signed in user.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------- |
| options | VerifyBeforeUpdateEmailOptions |
Since: 6.3.0
--------------------
`typescript`
checkAppTrackingTransparencyPermission() => Promise
Checks the current status of app tracking transparency.
Only available on iOS.
Returns: Promise<CheckAppTrackingTransparencyPermissionResult>
Since: 7.2.0
--------------------
`typescript`
requestAppTrackingTransparencyPermission() => Promise
Opens the system dialog to authorize app tracking transparency.
Attention: The user may have disabled the tracking request in the device settings, see Apple's documentation.
Only available on iOS.
Returns: Promise<CheckAppTrackingTransparencyPermissionResult>
Since: 7.2.0
--------------------
`typescript`
addListener(eventName: 'authStateChange', listenerFunc: AuthStateChangeListener) => Promise
Listen for the user's sign-in state changes.
Attention: This listener is not triggered when the skipNativeAuth is used. Use the Firebase JavaScript SDK instead.
| Param | Type |
| ------------------ | --------------------------------------------------------------------------- |
| eventName | 'authStateChange' |
| listenerFunc | AuthStateChangeListener |
Returns: Promise<PluginListenerHandle>
Since: 0.1.0
--------------------
`typescript`
addListener(eventName: 'idTokenChange', listenerFunc: IdTokenChangeListener) => Promise
Listen to ID token changes for the currently signed-in user.
Attention: This listener is not triggered when the skipNativeAuth is used. Use the Firebase JavaScript SDK instead.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------- |
| eventName | 'idTokenChange' |
| listenerFunc | IdTokenChangeListener |
Returns: Promise<PluginListenerHandle>
Since: 6.3.0
--------------------
`typescript`
addListener(eventName: 'phoneVerificationCompleted', listenerFunc: PhoneVerificationCompletedListener) => Promise
Listen for a completed phone verification.
This listener only fires in two situations:
1. Instant verification: In some cases the phone number can be instantly
verified without needing to send or enter a verification code.
2. Auto-retrieval: On some devices Google Play services can automatically
detect the incoming verification SMS and perform verification without
user action.
Only available for Android.
| Param | Type |
| ------------------ | ------------------------------------------------------------------------------------------------- |
| eventName | 'phoneVerificationCompleted' |
| listenerFunc | PhoneVerificationCompletedListener |
Returns: Promise<PluginListenerHandle>
Since: 1.3.0
--------------------
`typescript`
addListener(eventName: 'phoneVerificationFailed', listenerFunc: PhoneVerificationFailedListener) => Promise
Listen for a failed phone verification.
| Param | Type |
| ------------------ | ------------------------------------------------------------------------------------------- |
| eventName | 'phoneVerificationFailed' |
| listenerFunc | PhoneVerificationFailedListener |
Returns: Promise<PluginListenerHandle>
Since: 1.3.0
--------------------
`typescript`
addListener(eventName: 'phoneCodeSent', listenerFunc: PhoneCodeSentListener) => Promise
Listen for a phone verification code.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------- |
| eventName | 'phoneCodeSent' |
| listenerFunc | PhoneCodeSentListener |
Returns: Promise<PluginListenerHandle>
Since: 1.3.0
--------------------
`typescript`
removeAllListeners() => Promise
Remove all listeners for this plugin.
Since: 0.1.0
--------------------
#### ApplyActionCodeOptions
| Prop | Type | Description | Since |
| ------------- | ------------------- | ------------------------------------- | ----- |
| oobCode | string | A verification code sent to the user. | 0.2.2 |
#### ConfirmPasswordResetOptions
| Prop | Type | Description | Since |
| ----------------- | ------------------- | ------------------------------------- | ----- |
| oobCode | string | A verification code sent to the user. | 0.2.2 |
| newPassword | string | The new password. | 0.2.2 |
#### SignInResult
| Prop | Type | Description | Since |
| ------------------------ | ------------------------------------------------------------------------- | --------------------------------------------------------------- | ----- |
| user | User \| null | The currently signed-in user, or null if there isn't any. | 0.1.0 |
| credential | AuthCredential \| null | Credentials returned by an auth provider. | 0.1.0 |
| additionalUserInfo | AdditionalUserInfo \| null | Additional user information from a federated identity provider. | 0.5.1 |
#### User
| Prop | Type | Description | Since |
| ------------------- | ----------------------------------------------------- | -------------------------------------------------------------------- | ----- |
| displayName | string \| null | | 0.1.0 |
| email | string \| null | | 0.1.0 |
| emailVerified | boolean | | 0.1.0 |
| isAnonymous | boolean | | 0.1.0 |
| metadata | UserMetadata | The user's metadata. | 5.2.0 |
| phoneNumber | string \| null | | 0.1.0 |
| photoUrl | string \| null | | 0.1.0 |
| providerData | UserInfo[] | Additional per provider such as displayName and profile information. | 5.2.0 |
| providerId | string | | 0.1.0 |
| tenantId | string \| null | | 0.1.0 |
| uid | string | | 0.1.0 |
#### UserMetadata
| Prop | Type | Description | Since |
| -------------------- | ------------------- | ------------------------------------------------------------- | ----- |
| creationTime | number | Time the user was created in milliseconds since the epoch. | 5.2.0 |
| lastSignInTime | number | Time the user last signed in in milliseconds since the epoch. | 5.2.0 |
#### UserInfo
| Prop | Type | Description | Since |
| ----------------- | --------------------------- | ----------------------------------------------------------------------------------------- | ----- |
| displayName | string \| null | The display name of the user. | 5.2.0 |
| email | string \| null | The email of the user. | 5.2.0 |
| phoneNumber | string \| null | The phone number normalized based on the E.164 standard (e.g. +16505550101) for the user. | 5.2.0 |
| photoUrl | string \| null | The profile photo URL of the user. | 5.2.0 |
| providerId | string | The provider used to authenticate the user. | 5.2.0 |
| uid | string | The user's unique ID. | 5.2.0 |
#### AuthCredential
| Prop | Type | Description | Since |
| ----------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| accessToken | string | The OAuth access token associated with the credential if it belongs to an OAuth provider. | 0.1.0 |
| authorizationCode` | string