跳过内容

在iOS上设置Supabase Apple登录

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

完整的实施可在 文件中找到。 本指南解释了关键概念和如何使用它。 supabaseAuthUtils.ts 使用身份验证助手

复制到剪贴板 authenticateWithAppleSupabase 如何工作

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);
}

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

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

重要注意事项

包ID配置

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

Client ID

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

故障排除

__CAPGO_KEEP_0__

故障排除

如果身份验证失败:

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