When attempting to beta test my application with some external users, none of them could properly enter the app using the phone number sms verification. The developers could all use the application when built directly from Xcode, but anyone who installed via a link could not use it.
Each user attempting to sign in / sign up would get an error readout of Token Mismatch
- with no other info.
I have a valid production APNS certificate, why is this not working??
development
and production
APNS
certificate uploaded to the Firebase Dashboard, under 'Project
Settings' > 'Cloud Messaging'<my app>
.entitlements file, make sure the APS
Environment value is set to either 'development' or 'production',
depending on your testing situation.AppDelegate.swift
and inside the method for
didRegisterForRemoteNotificationsWithDeviceToken
, change the value
from .sandbox
to .prod
, or to .unknown
to let the app
bundle determine which token type to use, based on your provisioning profile.Step 1: import Firebase
2. Add the following to your AppDelegate:-
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let firebaseAuth = Auth.auth()
firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)
}
override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let firebaseAuth = Auth.auth()
if (firebaseAuth.canHandleNotification(userInfo)){
print(userInfo)
return
}
}
At least this worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With