跳过内容

Supabase Apple Login on iOS Setup

GitHub

本指南将帮助您在 iOS 上将 Apple Sign-In 与 Supabase Authentication 集成。假设您已经完成:

The complete implementation is available in the example app’s supabaseAuthUtils.ts file. This guide explains the key concepts and how to use it.

The authenticateWithAppleSupabase function handles the entire authentication flow:

import { authenticateWithAppleSupabase } from './supabaseAuthUtils';
const result = await authenticateWithAppleSupabase();
if (result.success) {
console.log('Signed in:', result.user);
// Navigate to your authenticated area
} else {
console.error('Error:', result.error);
}

在 iOS 上,Apple Sign-In 使用原生实现:

  1. 初始化: 插件会自动使用您的应用程序的包 ID (无需 clientId 原生登录
  2. : 使用 Apple 原生登录按钮和身份验证流程身份令牌
  3. : Apple 返回包含用户信息的身份令牌 (JWT)Supabase 身份验证
  4. : 将身份令牌发送到 Supabase助手函数会自动检测 iOS 平台并配置所有内容 signInWithIdToken()

重要注意事项

标题为“重要注意事项”的部分

__CAPGO_KEEP_0__

Bundle ID 配置

Bundle ID 配置
  • iOS 会自动使用您的应用程序的 Bundle ID 进行 Apple Sign-In
  • 确保您的 Bundle ID 与 Apple Developer Portal 中配置的匹配
  • Bundle ID 应该启用 "Sign in with Apple" 功能

Client ID

  • 您的 iOS App ID(Bundle ID)- 例如如果您还使用 Android/Web,则需要在 Supabase 的 Client ID 字段中提供 App ID 和 Service ID(用逗号分隔) app.capgo.plugin.SocialLogin

故障排除

iOS 会自动使用您的应用程序的 Bundle ID 进行 Apple Sign-In。

Troubleshooting

如果身份验证失败:

  • 包ID不匹配: 确保在 Xcode 和 Apple Developer Portal 中的包 ID 匹配
  • 能力未启用: 确保在 Xcode 中启用了“使用 Apple 登录”能力
  • Supabase 配置: 确保在 Supabase Apple 提供商设置中正确配置了 App ID
  • 令牌验证失败: 检查 Apple 是否向您发送身份令牌
  • 查看示例应用程序 __CAPGO_KEEP_0__ example app code for reference

从 Supabase Apple Login on iOS Setup 中继续

Section titled “从 Supabase Apple Login on iOS Setup 中继续”

如果您正在使用 Supabase Apple Login on iOS Setup 来规划认证和账户流程,连接它到 使用 @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的实现细节 双因素认证 查看双因素认证的实现细节