gpt4 book ai didi

ios - 无法在 iOS 上实现 Firebase Phone Auth

转载 作者:行者123 更新时间:2023-11-28 17:30:59 27 4
gpt4 key购买 nike

嘿,所以我有一个功能 Firebase/iOS 应用程序,我正在尝试实现手机身份验证。

  • 已安装 pod
  • APNs 身份验证 key 上传到 Firebase
  • 在 Xcode 中启用推送通知
  • 调用这个方法

    PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil) { (verificationID, error) 在
    如果让错误=错误{
    self.showMessagePrompt(error.localizedDescription)
    返回
    }
    //使用 verificationID 和发送给用户的代码登录
    //...
    }

在 View Controller 中传递一个有效数字。

我收到这个错误 ->

The UIApplicationDelegate must handle remote notification for phone number authentication to work.

Error Domain=FIRAuthErrorDomain Code=17054 "If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method." UserInfo={NSLocalizedDescription=If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method., error_name=ERROR_NOTIFICATION_NOT_FORWARDED}

据我所知,

Swizzling 未被禁用。委托(delegate)没有太多进展,但本演练 https://firebase.google.com/docs/auth/ios/phone-auth没有提到它。

我没有收到我假设的静默通知,也没有收到短信。

谢谢。

最佳答案

请在您的 AppDelegate 中添加以下代码:

func application(_ application: UIApplication,
didReceiveRemoteNotification notification: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

if Auth.auth().canHandleNotification(notification) {
completionHandler(.noData)
return
}
// This notification is not auth related, developer should handle it.
handleNotification(notification)
}

关于ios - 无法在 iOS 上实现 Firebase Phone Auth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52561998/

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