跳过内容

Firebase Google 登录

GitHub

The Capacitor 社交登录插件 不支持Web平台. 对于Web应用程序,您应使用Firebase的内置Google Sign-In直接提供的更可靠的弹出式身份验证流程.

The Capacitor Social Login plugin is designed for native mobile platforms (Android and iOS) where it can leverage platform-specific authentication flows. For web, Firebase’s native signInWithPopup 方法是:

  • ✅ 更可靠且更受支持
  • ✅ 自动处理浏览器会话存储
  • ✅ 提供更好的错误处理
  • ✅ 不需要额外的配置

Setup Steps

设置步骤
  1. 配置 Firebase 项目

    确保您的 Firebase 项目已启用 Google Sign-In:

    • 前往 Firebase 控制台
    • 导航到身份验证 > 登录方法
    • 启用 Google Sign-In 提供者
  2. 添加授权域名

    1. 前往您的项目概览 console.cloud.google.com Firebase 项目概览
    2. 打开 Authentication 菜单 Firebase 认证菜单
    3. 点击 Settings 按钮 Firebase 认证登录方式按钮
    4. 设置 Authorized domains Firebase 认证设置授权域名

示例实现

示例实现部分

查看 authUtils.ts 在示例应用程序中查找完整的实现示例:

  • 使用 Firebase 的 signInWithPopup 适用于 web 平台
  • 使用 Capacitor 社交登录插件(适用于 Android/iOS 平台)
  • 自动检测平台

示例演示如何在 web 平台上使用 Firebase 内置方法,同时在 native 平台上使用插件

从 Firebase Google 登录 (Web) 中继续

标题:从 Firebase Google 登录 (Web) 中继续

如果您正在使用 Firebase Google 登录 (Web) 来规划身份验证和帐户流程,连接它到 使用 @capgo/capacitor-social-login 为在使用 @capgo/capacitor-social-login 中的原生能力 @capgo/capacitor-social-login 为在 @capgo/capacitor-social-login 中的实现细节 @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, and 双因素认证 for the implementation detail in 双因素认证。