2
votes

I'm currently implementing firebase phone Authentication, and can successfully implement the phone authentication using the firebase UI without swizzling, but from my research it seems that implementing firebase phone authentication without swizzling requires the user to allow notifications. I know that firebase sends a silent notification that does not need to be approved through allowing notifications but it seems the only way to get that notification without swizzling is to ask the user to allow notification. Does anyone know how or if its possible to do this without swizzling and without asking the user for notification permissions?

I have added to push notification certificates to firebase, and have added all the needed function listed in the firebase phone ui docs.

Without asking the user for to allow notifications this function listed from the phone auth docs does not get called (the user also has to select allow)

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  // Pass device token to auth
  Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenTypeProd)

  // Further handling of the device token if needed by the app
  // ...
}

If this functions is not called the setAPNSToken is not set, I will not get the silent notification to continue with phone auth, and I will get the generic error

Authentication error: There seems to be a problem with your project's Firebase phone number authentication set-up, please make sure to follow the instructions found at https://firebase.google.com/docs/auth/ios/phone-auth

1

1 Answers

5
votes

I went ahead and disabled method swizzling as stated in the Firebase docs and then implemented all the required methods, the solution was that I needed to go the Capabilities of the app and then make sure Background Modes as well as Push Notifications (this was already enabled) were enabled. Then under Background Modes I had to enable Remote notifications.

Then I had to delete the app from my device and reinstall. This solved my issue and called the necessary functions for registering for notifications.