簡體   English   中英

無法在iOS上實施Firebase Phone Auth

[英]Failing to implement Firebase Phone Auth on iOS

嘿,所以我有一個功能Firebase / iOS應用程序,正在嘗試實現電話身份驗證。

  • 吊艙已安裝
  • APNs身份驗證密鑰已上傳到Firebase
  • 在Xcode中啟用了推送通知
  • 調用此方法

    PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil) { (verificationID, error) in if let error = error { self.showMessagePrompt(error.localizedDescription) return } // Sign in using the verificationID and the code sent to the user // ... }

在視圖控制器中傳遞有效數字。

我收到此錯誤->

UIApplicationDelegate必須處理遠程通知,電話號碼身份驗證才能正常工作。

錯誤域= FIRAuthErrorDomain代碼= 17054“如果禁用了應用程序委托混亂,則UIApplicationDelegate收到的遠程通知需要轉發到FIRAuth的canHandleNotificaton:方法。” UserInfo = {NSLocalizedDescription =如果禁用了應用程序委托混亂,則需要將UIApplicationDelegate收到的遠程通知轉發到FIRAuth的canHandleNotificaton:方法。,error_name = ERROR_NOTIFICATION_NOT_FORWARDED}

不是我不知道打Sw 委托沒有太多進展,但是本演練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)
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM