gpt4 book ai didi

swift - iOS : Firebase phone Authenication

转载 作者:行者123 更新时间:2023-11-28 14:14:26 25 4
gpt4 key购买 nike

我开发了一个使用 firebase 电话身份验证的 iOS 应用程序,我遵循了谷歌文档,但我总是遇到以下错误:

If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.

和我的 appDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{

FirebaseApp.configure()
return true
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox)
}


func application(_ application: UIApplication , didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
{
if Auth.auth().canHandleNotification(notification)
{
completionHandler(UIBackgroundFetchResult.noData);
return
}
}

那我该如何解决呢?

最佳答案

如果 swizzling 被禁用,你需要做两件事来让电话号码授权工作:

使用您的 APNs token 在 FIRAuth 实例上设置 APNSToken。这与为 FCM 设置 APNs token 无关(使用电话号码身份验证不需要使用 FCM 客户端 SDK)。使用您从 UIApplicationDelegate 实例上的 application:didReceiveRemoteNotification:fetchCompletionHandler: 方法收到的远程通知,在 FIRAuth 实例上调用 canHandleNotification。这也与通知 FCM 无关。 It's documented in under section "Receive notifications without swizzling" .

关于swift - iOS : Firebase phone Authenication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52262318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com