简体   繁体   中英

Failing to implement Firebase Phone Auth on iOS

hey so I have a function Firebase/iOS app and am trying to implement phone auth.

  • pods are installed
  • APNs authentication key uploaded to Firebase
  • Push notifs enabled in Xcode
  • calling this method

    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 // ... }

in the view controller and passing a valid number.

I get this error ->

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 is not disabled not that I know of. Delegate doesn't have much goin on but this walkthrough https://firebase.google.com/docs/auth/ios/phone-auth didn't mention it.

I'm not getting the silent notification I assume and def not receiving an SMS.

Thanks.

Please add following code in your 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)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM