电容火库认证插件
非官方电容插件 Firebase 验证[^1]
使用大小写
Firebase认证插件一般用于处理一个应用程序的整个登录入流,例如:
- 社会登录:在本地用户中与Apple,Google,Facebook,微软,GitHub,Twitter,Yahoo,Play Games,或Game Center签名.
- 基于电子邮件的认证:用电子邮件和密码在用户中注册和签名,或发给他们无密码的登录链接.
- 电话号码登录:用发送到电话号码的短信码验证用户.
- 来宾出入: 让用户用匿名签名尝试您的应用程序, 并在稍后链接一个永久账户 .
- 自定义后端:用自定义的符号或OpenID Connection签名并取回ID符来认证请求到自己的后端.
兼容性
| 插件版本 | 电容版本 | 状态 |
|---|---|---|
| 8.x.x (英语) | >=8.x.x | 积极支持 |
| 7.x.x (中文(简体) ) | 7.x.x (中文(简体) ) | 折旧 |
| 6.x.x (中文(简体) ) | 6.x.x (中文(简体) ) | 折旧 |
| 5.x.x (中文(简体) ) | 5.x.x (中文(简体) ) | 折旧 |
| 1.x.x (中文(简体) ) | 4.x.x (中文(简体) ) | 折旧 |
指南
- Capacitor 的防火基地认证: 设置和最佳做法: 此插件的登录流设置和最佳做法 .
- 如何在电容App中使用火把:为什么签入通常是首个Firebase被接上电线的作品,以及它所生产的用户ID的基础上发展出来的.
安装
你可以用我们的 AI 辅助设置 以安装插件. 添加数据 超级技能 至您的 AI 工具,使用以下命令:
npx skills add capawesome-team/skills --skill capacitor-plugins
然后使用下列提示:
Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capacitor-firebase/authentication` plugin in my project.
如果你喜欢 手动设置,通过运行以下命令来安装插件,并遵循下面的平台特定指令:
npm install @capacitor-firebase/authentication firebase
npx cap sync
如果您还没有将 Firebase 添加到您的项目中(机器人 编号 : iOS系统 编号 : 网页) (中文(简体) ).
打开 iOS系统,验证此功能是否包含在您的应用程序中 AppDelegate.swift数字 :
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
请注意: 如果您在其中使用此插件 iOS系统 结合 @capacitor-firebase/messaging,然后在应用程序中添加以下内容: AppDelegate.swift数字 :
+ 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)
}
进一步的安装步骤取决于选定的认证方法:
请注意:请注意,这个插件使用第三方SDK来提供本地登录. 这些SDK可以自行初始化并收集各种数据. 更多信息见 第三方 SDKs。 。 。 .
iOS系统
Swift 软件包管理器
在您的 capacitor.config.json (或 capacitor.config.ts) 避免 SwiftPM 软件包识别相撞数字 :
{
"experimental": {
"ios": {
"spm": {
"packageOptions": {
"@capacitor-firebase/authentication": {
"symlink": true
}
}
}
}
}
}
请注意目标 packageOptions 支持需要控制器 CLI 8.4.0+ (中文(简体) )。 。 。 .
软件包特性
GoogleSignIn 和 Facebook SDK 是可选的,默认通过 Google 财务报告和审定财务报表 Facebook 软件包特性。 如果您不使用这些提供者, 请禁用相应的特性, 以使 SDK 不连接到您的应用程序中 :
{
"experimental": {
"ios": {
"spm": {
"swiftToolsVersion": "6.1",
"packageTraits": {
"@capacitor-firebase/authentication": ["Google"]
}
}
}
}
}
列出特征会明确替换默认,所以只启用您列出的特征. 以上例子保留了GoogleSignIn并排除了Facebook SDK. 使用 Lite 将两种情况排除在外:
{
"experimental": {
"ios": {
"spm": {
"swiftToolsVersion": "6.1",
"packageTraits": {
"@capacitor-firebase/authentication": ["Lite"]
}
}
}
}
}
这些特征是相当于 CapacitorFirebaseAuthentication/Google, (中文(简体) ), CapacitorFirebaseAuthentication/Facebook 财务报告和审定财务报表 CapacitorFirebaseAuthentication/Lite 可可宝地亚种. 调用 SDK 被排除的供应商的登录方法 .
请注意: SPM 特性支持需要Capacitor CLI 8.3.0+ (中文(简体) ) 和 X 代码 16.3+ (简体中文) (Swift 6.1+) (英语).
配置
这些配置值是可用的 :
| Prop | 类型 | 说明 | 默认 | 自兹 |
|---|---|---|---|---|
authDomain | string | 配置您要使用的自定义认证域 。 仅供Android和iOS使用. | 7.3.0 (单位:千美元) | |
skipNativeAuth | boolean | 配置插件是否跳过本地认证 。 只有在您想要使用 Firebase JavaScript SDK 时才需要. 此配置选项对 Firebase 账户链接没有影响 . 注意插件可能在各个平台上表现不同. 仅供Android和iOS使用. | false | 0.1.0 (中文(简体) ) |
providers | string[] | 配置由插件加载的供应商 。 可能的数值 : ["apple.com", "facebook.com", "gc.apple.com", "github.com", "google.com", "microsoft.com", "playgames.google.com", "twitter.com", "yahoo.com", "phone"] 仅供Android和iOS使用. | [] | 0.1.0 (中文(简体) ) |
实例
单位 capacitor.config.json数字 :
{
"plugins": {
"FirebaseAuthentication": {
"authDomain": undefined,
"skipNativeAuth": false,
"providers": ["apple.com", "facebook.com"]
}
}
}
单位 capacitor.config.ts数字 :
/// <reference types="@capacitor-firebase/authentication" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
FirebaseAuthentication: {
authDomain: undefined,
skipNativeAuth: false,
providers: ["apple.com", "facebook.com"],
},
},
};
export default config;
火基地 JavaScript SDK
给 您可以找到如何使用 Firebase JS SDK 插件的信息.
演示
这里有一个实例: robingenz/电容器 -- -- 消防基地 -- -- 校正 -- -- 演示
启动模板
以下启动模板可供使用:
使用量
以下例子显示如何用电子邮件和密码签名,社交供应商,电话号码,电子邮件链接,匿名,自定义的代号,以及如何管理当前用户,重置密码,验证和更新电子邮件地址,设置语言,签名,删除用户,并使用Firebase模拟器.
签名并用电子邮件和密码签名
创建一个有电子邮件和密码的新用户账户,并用这些证书签名用户:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const createUserWithEmailAndPassword = async () => {
const result = await FirebaseAuthentication.createUserWithEmailAndPassword({
email: '[email protected]',
password: '1234',
});
return result.user;
};
const signInWithEmailAndPassword = async () => {
const result = await FirebaseAuthentication.signInWithEmailAndPassword({
email: '[email protected]',
password: '1234',
});
return result.user;
};
跟社工签约
在用户中与苹果,谷歌,Facebook,GitHub,微软,Twitter或雅虎等供应商在本地签名. 每一个提供者都要求设置步骤 安装 节。 Game Center的签入仅在iOS上提供,而Play Games的签入仅在Android上提供:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithApple = async () => {
const result = await FirebaseAuthentication.signInWithApple();
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 signInWithPlayGames = async () => {
const result = await FirebaseAuthentication.signInWithPlayGames();
return result.user;
};
const signInWithTwitter = async () => {
const result = await FirebaseAuthentication.signInWithTwitter();
return result.user;
};
const signInWithYahoo = async () => {
const result = await FirebaseAuthentication.signInWithYahoo();
return result.user;
};
用电话号码签名
启动电话号码登录流程,向用户发送短信码,并用 confirmVerificationCode(...)。仅在Android和iOS上提供:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithPhoneNumber = async () => {
return new Promise(async resolve => {
// Attach `phoneCodeSent` listener to be notified as soon as the SMS is sent
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 `phoneVerificationCompleted` 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',
});
});
};
用电子邮件链接签名
向用户的电子邮件地址发送无密码的登录链接, 并在链接打开后完成登录 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const sendSignInLinkToEmail = async () => {
const email = '[email protected]';
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 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;
};
匿名签名
在用户中匿名签名, 例如让用户在创建账户前尝试您的应用程序 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInAnonymously = async () => {
const result = await FirebaseAuthentication.signInAnonymously();
return result.user;
};
用自定义的符号或 OpenID 连接签名
用自定义的符号验证您自己的后端, 或使用任何 OpenID 连接提供者 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithCustomToken = async () => {
const result = await FirebaseAuthentication.signInWithCustomToken({
token: '1234',
});
return result.user;
};
const signInWithOpenIdConnect = async () => {
const result = await FirebaseAuthentication.signInWithOpenIdConnect({
providerId: 'oidc.example.com',
});
return result.user;
};
获取当前用户和标识符
获取当前已签名的用户,他们的ID令牌,或者等待认证操作的结果. 这个 getPendingAuthResult() 方法只在Android上可用:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const getCurrentUser = async () => {
const result = await FirebaseAuthentication.getCurrentUser();
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;
};
发送和确认密码重置
向用户发送密码重置电子邮件,并用收到的出带码确认密码重置:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const sendPasswordResetEmail = async () => {
await FirebaseAuthentication.sendPasswordResetEmail({
email: '[email protected]',
});
};
const confirmPasswordReset = async () => {
await FirebaseAuthentication.confirmPasswordReset({
oobCode: '1234',
newPassword: '4321',
});
};
校验用户的电子邮件地址
向当前登录的用户发送一个验证邮件, 并应用收到的带外代码 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const sendEmailVerification = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.sendEmailVerification();
};
const applyActionCode = async () => {
await FirebaseAuthentication.applyActionCode({ oobCode: '1234' });
};
更新用户的电子邮件或密码
更新当前登录用户的电子邮件地址或密码 。 与 verifyBeforeUpdateEmail(...),新的电子邮件地址在更新前会核实:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const updateEmail = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.updateEmail({
newEmail: '[email protected]',
});
};
const verifyBeforeUpdateEmail = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.verifyBeforeUpdateEmail({
newEmail: '[email protected]',
actionCodeSettings: {
url: 'https://www.example.com/[email protected]&cartId=123',
iOS: {
bundleId: 'com.example.ios'
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12'
},
handleCodeInApp: true
}
});
};
const updatePassword = async () => {
const currentUser = await getCurrentUser();
if (!currentUser) {
return;
}
await FirebaseAuthentication.updatePassword({
newPassword: '4321',
});
};
查找电子邮件的登录方法
获取电子邮件地址可用的登录方法 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const fetchSignInMethodsForEmail = async () => {
const result = await FirebaseAuthentication.fetchSignInMethodsForEmail({
email: '[email protected]',
});
return result.signInMethods;
};
设置语言
设定要使用的语言代码, 或者应用当前应用语言 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const setLanguageCode = async () => {
await FirebaseAuthentication.setLanguageCode({ languageCode: 'en-US' });
};
const useAppLanguage = async () => {
await FirebaseAuthentication.useAppLanguage();
};
签名并删除用户
签名当前用户或永久删除用户账户 :
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signOut = async () => {
await FirebaseAuthentication.signOut();
};
const deleteUser = async () => {
await FirebaseAuthentication.deleteUser();
};
使用火地模拟器
将插件连接到本地端 火地模拟器 开发过程中的实例:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const useEmulator = async () => {
await FirebaseAuthentication.useEmulator({
host: '10.0.2.2',
port: 9099,
});
};
API 密码
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()- 接口
- 类型异名
- 数字
应用动作代码(...)
applyActionCode(options: ApplyActionCodeOptions) => Promise<void>
应用通过电子邮件发送给用户的校验码 .
| 参数 | 类型 |
|---|---|
options | ApplyActionCodeOptions |
自: 0.2.2 (中文(简体) )
确认 Password 重置(...)
confirmPasswordReset(options: ConfirmPasswordResetOptions) => Promise<void>
完成密码重置进程.
| 参数 | 类型 |
|---|---|
options | ConfirmPasswordResetOptions |
自: 0.2.2 (中文(简体) )
确认验证码(...)
confirmVerificationCode(options: ConfirmVerificationCodeOptions) => Promise<SignInResult>
完成电话号码验证程序.
| 参数 | 类型 |
|---|---|
options | ConfirmVerificationCodeOptions |
回返情况: Promise<SignInResult>
自: 5.0.0 (单位:千美元)
创建 UserWith EmailAndPassword (.)
createUserWithEmailAndPassword(options: CreateUserWithEmailAndPasswordOptions) => Promise<SignInResult>
创建一个有电子邮件和密码的新用户账户. 如果创建了新账户,用户会自动签名.
| 参数 | 类型 |
|---|---|
options | CreateUserWithEmailAndPasswordOptions |
回返情况: Promise<SignInResult>
自: 0.2.2 (中文(简体) )
删除用户( )
deleteUser() => Promise<void>
删除并签名出用户.
自: 1.3.0 (单位:千美元)
获取 SignInMethods ForEmail (...)
fetchSignInMethodsForEmail(options: FetchSignInMethodsForEmailOptions) => Promise<FetchSignInMethodsForEmailResult>
获取电子邮件地址的登录方法.
| 参数 | 类型 |
|---|---|
options | FetchSignInMethodsForEmailOptions |
回返情况: Promise<FetchSignInMethodsForEmailResult>
自: 6.0.0 (单位:千美元)
获取当前用户( C)
getCurrentUser() => Promise<GetCurrentUserResult>
获取当前已签名的用户.
回返情况: Promise<GetCurrentUserResult>
自: 0.1.0 (中文(简体) )
获得PendingAuthResult ()
getPendingAuthResult() => Promise<SignInResult>
返回 SignInResult 如果您的应用程序启用了网络登录流, 而操作系统则在背景中清理应用程序 .
仅供Android使用.
回返情况: Promise<SignInResult>
自: 6.0.0 (单位:千美元)
获取 IdToken (...)
getIdToken(options?: GetIdTokenOptions | undefined) => Promise<GetIdTokenResult>
为当前登录的用户获取 Firebase Auth ID Token .
| 参数 | 类型 |
|---|---|
options | GetIdTokenOptions |
回返情况: Promise<GetIdTokenResult>
自: 0.1.0 (中文(简体) )
获取 IdToken Result (...)
getIdTokenResult(options?: GetIdTokenResultOptions | undefined) => Promise<GetIdTokenResultResult>
返回用于识别用户身份的已解编的JSON Web Token(JWT)到Firebase服务.
| 参数 | 类型 |
|---|---|
options | GetIdTokenResultOptions |
回返情况: Promise<GetIdTokenResultResult>
自: 7.4.0 (单位:千美元)
获取直接结果( C)
getRedirectResult() => Promise<SignInResult>
返回 SignInResult 从基于方向的登录流.
如果登录失败, 则出现出错 .
如果没有调试方向操作, 请返回 a SignInResult 与无效用户.
仅供Web使用.
回返情况: Promise<SignInResult>
自: 1.3.0 (单位:千美元)
获取 TenantId ()
getTenantId() => Promise<GetTenantIdResult>
拿房客身份证来.
回返情况: Promise<GetTenantIdResult>
自: 1.1.0 国家
是SignIn With EmailLink (...) 的缩写
isSignInWithEmailLink(options: IsSignInWithEmailLinkOptions) => Promise<IsSignInWithEmailLinkResult>
检查一个进入的链接是否是带有适合的电子邮件链接的登录 signInWithEmailLink。 。 。 .
| 参数 | 类型 |
|---|---|
options | IsSignInWithEmailLinkOptions |
回返情况: Promise<IsSignInWithEmailLinkResult>
自: 1.1.0 国家
链接与 Apple (...)
linkWithApple(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
将用户账户与苹果认证提供者链接.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接与电子邮件AndPassword (...)
linkWithEmailAndPassword(options: LinkWithEmailAndPasswordOptions) => Promise<LinkResult>
将用户账户与电子邮件认证提供者链接.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | LinkWithEmailAndPasswordOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接与电子邮件链接(...)
linkWithEmailLink(options: LinkWithEmailLinkOptions) => Promise<LinkResult>
将用户账户与电子邮件认证提供者链接.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | LinkWithEmailLinkOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接到脸书(...)
linkWithFacebook(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
链接用户账户与 Facebook 认证提供者 .
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接到 GameCenter (...)
linkWithGameCenter(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
将用户账户链接到游戏中心认证提供者.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
仅供iOS使用.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.3.0 (单位:千美元)
链接到 Github (...)
linkWithGithub(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
将用户账户链接到 GitHub 认证提供者 .
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接到 Google (...)
linkWithGoogle(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
将用户账户与Google认证提供者链接.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接微软(...)
linkWithMicrosoft(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
将用户账户与微软认证提供者链接.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接与 OpenIdConnect (...)
linkWithOpenIdConnect(options: LinkWithOpenIdConnectOptions) => Promise<LinkResult>
用 OpenID 连接提供者链接用户账户.
| 参数 | 类型 |
|---|---|
options | SignInWithOpenIdConnectOptions |
回返情况: Promise<SignInResult>
自: 6.1.0 (中文(简体) )
链接与 Phone 数字(...)
linkWithPhoneNumber(options: LinkWithPhoneNumberOptions) => Promise<void>
连接用户账户与电话号码认证提供者.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
使用 phoneVerificationCompleted 核查结束后通知听众.
使用 phoneVerificationFailed 当验证失败时, 要通知的听众 .
使用 phoneCodeSent 监听者获取验证码.
| 参数 | 类型 |
|---|---|
options | SignInWithPhoneNumberOptions |
自: 1.1.0 国家
链接与 PlayGames (...)
linkWithPlayGames(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
链接用户账户与 PlayGames 认证提供者.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
仅供Android使用.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接到 Twitter (...)
linkWithTwitter(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
链接用户账户与Twitter认证提供者.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
链接与 Yahoo (...)
linkWithYahoo(options?: SignInWithOAuthOptions | undefined) => Promise<LinkResult>
链接用户账户与 Yahoo 认证提供者.
用户必须在原地层登录.
这个 skipNativeAuth 配置选项在此没有效果 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
重新装入( c)
reload() => Promise<void>
重新装入用户账户数据, 如果签名的话 .
自: 1.3.0 (单位:千美元)
撤销 AccessToken (...)
revokeAccessToken(options: RevokeAccessTokenOptions) => Promise<void>
撤销给定的访问符 。 目前只支持Apple OAuth访问符.
| 参数 | 类型 |
|---|---|
options | RevokeAccessTokenOptions |
自: 6.1.0 (中文(简体) )
发送电子邮件验证(...)
sendEmailVerification(options?: SendEmailVerificationOptions | undefined) => Promise<void>
向当前在用户中签名的用户发送验证邮件 .
| 参数 | 类型 |
|---|---|
options | SendEmailVerificationOptions |
自: 0.2.2 (中文(简体) )
发送 Password 重置邮件(...)
sendPasswordResetEmail(options: SendPasswordResetEmailOptions) => Promise<void>
发送密码重置邮件 .
| 参数 | 类型 |
|---|---|
options | SendPasswordResetEmailOptions |
自: 0.2.2 (中文(简体) )
发送SignInLink To电子邮件(...)
sendSignInLinkToEmail(options: SendSignInLinkToEmailOptions) => Promise<void>
用指定的电子邮件向用户发送签名电子邮件链接 .
要完成电子邮件链接的签名, 请打电话 signInWithEmailLink 的电子邮件地址和电子邮件链接.
| 参数 | 类型 |
|---|---|
options | SendSignInLinkToEmailOptions |
自: 1.1.0 国家
语言代码(...)
setLanguageCode(options: SetLanguageCodeOptions) => Promise<void>
设置用于认证操作的用户界面语言代码.
| 参数 | 类型 |
|---|---|
options | SetLanguageCodeOptions |
自: 0.1.0 (中文(简体) )
设置持续(...)
setPersistence(options: SetPersistenceOptions) => Promise<void>
设置当前保存的认证会话的持久性类型 .
仅供Web使用.
| 参数 | 类型 |
|---|---|
options | SetPersistenceOptions |
自: 5.2.0 (中文(简体) )
设置 TenantId (...)
setTenantId(options: SetTenantIdOptions) => Promise<void>
确定租户身份.
| 参数 | 类型 |
|---|---|
options | SetTenantIdOptions |
自: 1.1.0 国家
匿名签名 ()
signInAnonymously() => Promise<SignInResult>
作为匿名用户签名.
回返情况: Promise<SignInResult>
自: 1.1.0 国家
签名InWithApple (...)
signInWithApple(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>
启动 Apple 登录流量 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
签名 InWithCustom Token (...)
signInWithCustomToken(options: SignInWithCustomTokenOptions) => Promise<SignInResult>
启动自定义托肯签名流程.
这种方法不能与 skipNativeAuth (原始内容存档于2019-10-12). Android and iOS.
在这种情况下,你必须使用 signInWithCustomToken 直接使用 Firebase JS SDK 接口.
| 参数 | 类型 |
|---|---|
options | SignInWithCustomTokenOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
在电子邮件中签名 AndPassword (...)
signInWithEmailAndPassword(options: SignInWithEmailAndPasswordOptions) => Promise<SignInResult>
使用电子邮件和密码启动登录流程.
| 参数 | 类型 |
|---|---|
options | SignInWithEmailAndPasswordOptions |
回返情况: Promise<SignInResult>
自: 0.2.2 (中文(简体) )
在电子邮件链接中签名(...)
signInWithEmailLink(options: SignInWithEmailLinkOptions) => Promise<SignInResult>
使用电子邮件和签名电子邮件链接签名 .
| 参数 | 类型 |
|---|---|
options | SignInWithEmailLinkOptions |
回返情况: Promise<SignInResult>
自: 1.1.0 国家
使用脸书签名(...)
signInWithFacebook(options?: SignInWithFacebookOptions | undefined) => Promise<SignInResult>
启动脸书登录流程 .
| 参数 | 类型 |
|---|---|
options | SignInWithFacebookOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
签入 Game 中心(...)
signInWithGameCenter(options?: SignInWithOAuthOptions | SignInOptions | undefined) => Promise<SignInResult>
启动游戏中心的登录流程.
仅供iOS使用.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions | SignInOptions |
回返情况: Promise<SignInResult>
自: 1.3.0 (单位:千美元)
签名 InWithub (...)
signInWithGithub(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>
启动 GitHub 登录流量 .
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
使用 Google 签名(...)
signInWithGoogle(options?: SignInWithGoogleOptions | undefined) => Promise<SignInResult>
启动Google登录流量.
| 参数 | 类型 |
|---|---|
options | SignInWithGoogleOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
签名InWith Microsoft (...)
signInWithMicrosoft(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>
启动微软的登录流.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
在 OpenIdConnect 中签名(...)
signInWithOpenIdConnect(options: SignInWithOpenIdConnectOptions) => Promise<SignInResult>
启动 OpenID 连接签名流.
| 参数 | 类型 |
|---|---|
options | SignInWithOpenIdConnectOptions |
回返情况: Promise<SignInResult>
自: 6.1.0 (中文(简体) )
签名 InWithPhone 数字(...)
signInWithPhoneNumber(options: SignInWithPhoneNumberOptions) => Promise<void>
使用电话号码启动登录流.
使用 phoneVerificationCompleted 核查结束后通知听众.
使用 phoneVerificationFailed 当验证失败时, 要通知的听众 .
使用 phoneCodeSent 监听者获取验证码.
仅供Android和iOS使用.
| 参数 | 类型 |
|---|---|
options | SignInWithPhoneNumberOptions |
自: 0.1.0 (中文(简体) )
签入 PlayGames (...)
signInWithPlayGames(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>
启动游戏游戏的登录流程.
仅供Android使用.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
签名 With Twitter (...)
signInWithTwitter(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>
启动推特登录流量.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
签入 Yahoo (...)
signInWithYahoo(options?: SignInWithOAuthOptions | undefined) => Promise<SignInResult>
启动"雅虎"的签入流.
| 参数 | 类型 |
|---|---|
options | SignInWithOAuthOptions |
回返情况: Promise<SignInResult>
自: 0.1.0 (中文(简体) )
符号输出( C)
signOut() => Promise<void>
启动出牌流.
自: 0.1.0 (中文(简体) )
取消链接(...)
unlink(options: UnlinkOptions) => Promise<UnlinkResult>
从用户账户中取消一个提供者的链接.
| 参数 | 类型 |
|---|---|
options | UnlinkOptions |
回返情况: Promise<UnlinkResult>
自: 1.1.0 国家
更新电子邮件(...)
updateEmail(options: UpdateEmailOptions) => Promise<void>
更新当前用户签名的电子邮件地址.
| 参数 | 类型 |
|---|---|
options | UpdateEmailOptions |
自: 0.1.0 (中文(简体) )
更新 Password (.)
updatePassword(options: UpdatePasswordOptions) => Promise<void>
更新当前用户签名的密码.
| 参数 | 类型 |
|---|---|
options | UpdatePasswordOptions |
自: 0.1.0 (中文(简体) )
更新Profile (...)
updateProfile(options: UpdateProfileOptions) => Promise<void>
更新用户的配置数据.
| 参数 | 类型 |
|---|---|
options | UpdateProfileOptions |
自: 1.3.0 (单位:千美元)
使用 AppLangage () 语言
useAppLanguage() => Promise<void>
设定用户界面语言代码为默认的app语言.
自: 0.1.0 (中文(简体) )
使用计算器(...)
useEmulator(options: UseEmulatorOptions) => Promise<void>
您的应用程序可以和认证模拟器交谈 .
| 参数 | 类型 |
|---|---|
options | UseEmulatorOptions |
自: 0.2.0 (中文(简体) )
校验更新前的电子邮件(...)
verifyBeforeUpdateEmail(options: VerifyBeforeUpdateEmailOptions) => Promise<void>
在更新当前用户签名的电子邮件地址之前验证新的电子邮件地址 .
| 参数 | 类型 |
|---|---|
options | VerifyBeforeUpdateEmailOptions |
自: 6.3.0 (单位:千美元)
追踪透明性
checkAppTrackingTransparencyPermission() => Promise<CheckAppTrackingTransparencyPermissionResult>
检查应用程序跟踪透明度的现状.
仅在iOS上可用.
回返情况: Promise<CheckAppTrackingTransparencyPermissionResult>
自: 7.2.0 联合国
追踪透明性
requestAppTrackingTransparencyPermission() => Promise<RequestAppTrackingTransparencyPermissionResult>
打开系统对话框以授权应用跟踪透明度 .
请注意: 用户可能已禁用设备设置中的跟踪请求,参见 苹果的文档。 。 。 .
仅在iOS上可用.
回返情况: Promise<CheckAppTrackingTransparencyPermissionResult>
自: 7.2.0 联合国
添加倾听器( “ 自动状态变化 ” ,...)
addListener(eventName: 'authStateChange', listenerFunc: AuthStateChangeListener) => Promise<PluginListenerHandle>
聆听用户的登录状态变化 .
请注意: 此听器不会在 skipNativeAuth 已使用。 取而代之的是火地JavaScript SDK.
| 参数 | 类型 |
|---|---|
eventName | 'authStateChange' |
listenerFunc | AuthStateChangeListener |
回返情况: Promise<PluginListenerHandle>
自: 0.1.0 (中文(简体) )
添加倾听器( “ id TokenChange ” ,...)
addListener(eventName: 'idTokenChange', listenerFunc: IdTokenChangeListener) => Promise<PluginListenerHandle>
听当前登录用户的 ID 令牌更改 .
请注意: 此听器不会在 skipNativeAuth 已使用。 取而代之的是火地JavaScript SDK.
| 参数 | 类型 |
|---|---|
eventName | 'idTokenChange' |
listenerFunc | IdTokenChangeListener |
回返情况: Promise<PluginListenerHandle>
自: 6.3.0 (单位:千美元)
添加聆听器( “ 手机验证完成 ” ,...)
addListener(eventName: 'phoneVerificationCompleted', listenerFunc: PhoneVerificationCompletedListener) => Promise<PluginListenerHandle>
听电话检查完毕.
这个听众只在两种情况下开火:
- 即时核查: 在某些情况下,可以立即拨打电话号码 不需要发送或输入核查代码.
- 自动检索: 在一些设备上,Google Play服务可以自动 检测进入的核查短消息,并在不进行核查的情况下进行核查 用户动作.
仅供Android使用.
| 参数 | 类型 |
|---|---|
eventName | 'phoneVerificationCompleted' |
listenerFunc | PhoneVerificationCompletedListener |
回返情况: Promise<PluginListenerHandle>
自: 1.3.0 (单位:千美元)
添加倾听器( “ 电话验证失败 ” ,...)
addListener(eventName: 'phoneVerificationFailed', listenerFunc: PhoneVerificationFailedListener) => Promise<PluginListenerHandle>
听电话验证失败.
| 参数 | 类型 |
|---|---|
eventName | 'phoneVerificationFailed' |
listenerFunc | PhoneVerificationFailedListener |
回返情况: Promise<PluginListenerHandle>
自: 1.3.0 (单位:千美元)
添加倾听器( “ 手机代码Sent' ,...)
addListener(eventName: 'phoneCodeSent', listenerFunc: PhoneCodeSentListener) => Promise<PluginListenerHandle>
听电话验证码.
| 参数 | 类型 |
|---|---|
eventName | 'phoneCodeSent' |
listenerFunc | PhoneCodeSentListener |
回返情况: Promise<PluginListenerHandle>
自: 1.3.0 (单位:千美元)
删除所有收听器( )
removeAllListeners() => Promise<void>
删除此插件的所有听众 .
自: 0.1.0 (中文(简体) )
接口
应用动作代码选项
| Prop | 类型 | 说明 | 自兹 |
|---|---|---|---|
oobCode | string | 发给用户的验证码 . | 0.2.2 (中文(简体) ) |
确认 Password 重置选项
| Prop | 类型 | 说明 | 自兹 |
|---|---|---|---|
oobCode | string | 发给用户的验证码 . | 0.2.2 (中文(简体) ) |
newPassword | string | 新密码. |