Firebase 集成介绍
复制一个包含安装步骤和本插件的完整Markdown指南的设置提示。
Overview
Section titled “Overview”This tutorial will guide you through setting up Firebase Authentication with the Capacitor Social Login plugin. This integration allows you to use native social login providers (Google, Apple, Facebook, Twitter) on mobile platforms while leveraging Firebase Auth for backend authentication and Firestore for data storage.
What You’ll Learn
Section titled “What You’ll Learn”- How to configure Firebase Authentication
- How to integrate Capacitor Social Login plugin with Firebase Auth
- Platform-specific setup for Android, iOS, and Web
What You’ll Need
Section titled “您需要什么”在开始之前,请确保您有:
-
一个 Firebase 项目
- 在 Firebase 控制台中创建一个项目 启用身份验证(电子邮件/密码和 Google 登录)
- 获取您的 Firebase 配置凭证
- Firebase JS __CAPGO_KEEP_0__
-
Firebase JS SDK
- 终端窗口
复制到剪贴板 npm install firebase
- 终端窗口
-
A Capacitor Project
- 一个现有的Capacitor应用
- Capacitor 社交登录插件安装:
终端窗口 npm install @capgo/capacitor-social-loginnpx cap sync
示例应用
标题为“示例应用”的部分完整的工作示例可在仓库中找到:
Code 仓库: 您可以在这里找到code 仓库
示例应用演示:
- 使用 Firebase 的电子邮件/密码身份验证
- Google Sign-In 集成(Android、iOS 和 Web)
- A simple key-value store using Firebase Firestore collections
- 在 Firestore 子集合中存储用户特定数据
关于在 SDK 上使用 Firebase Capacitor
关于在 SDK 上使用 Firebase Capacitor当使用 Firebase JS SDK 在 Capacitor 上进行身份验证时,需要注意在使用身份验证方法时,需要稍微不同地初始化 Firebase Auth 实例。
在 web 平台上,您将使用函数来获取 Firebase Auth 实例。 getAuth 复制到剪贴板
import { initializeApp } from 'firebase/app';import { getAuth } from 'firebase/auth';
const app = initializeApp(firebaseConfig);const auth = getAuth(app);Capacitor __CAPGO_KEEP_1____CAPGO_KEEP_0__ initializeAuth __CAPGO_KEEP_1__
import { initializeApp } from 'firebase/app';import { initializeAuth } from 'firebase/auth';
const app = initializeApp(firebaseConfig);
function whichAuth() { let auth; if (Capacitor.isNativePlatform()) { auth = initializeAuth(app, { persistence: indexedDBLocalPersistence, }); } else { auth = getAuth(app); } return auth;}
export const auth = whichAuth();下一步
下一步继续使用设置指南:
- Firebase 设置 - 配置 Firebase 项目
- Android 设置 - Android 特定配置
- iOS 设置 - iOS 特定配置
- Web 设置 - Web 特定配置
继续使用 Firebase 集成介绍
标题:继续使用 Firebase 集成介绍如果您正在使用 Firebase 集成介绍 来规划身份验证和帐户流程,连接它到 使用 @capgo/capacitor-social-login 为使用 @capgo/capacitor-social-login 的原生能力 @capgo/capacitor-social-login 为 @capgo/capacitor-social-login 的实现细节 @capgo/capacitor-passkey 为 @capgo/capacitor-passkey 的实现细节 @capgo/capacitor-native-biometric 在 @capgo/capacitor-native-biometric 中的实现细节 双因素认证 在双因素认证中实现细节