Previously posted on Stack Overflow
https://stackoverflow.com/questions/52547951/firebase-authentication-ios-12-invalid-token
I have an App that makes use of Firebase Authentication using phone SMS verification and recaptcha (no APNS)
The App works fine with the Authentication process if you are using iOS 11.4.1
However, if you are on iOS 12, then the Authentication process leads to an invalid token message
Error Domain=FIRAuthErrorDomain Code=17048 "Invalid token." UserInfo={NSLocalizedDescription=Invalid token., error_name=INVALID_APP_CREDENTIAL}
currently using latest firebase ios SDK 5.9.0
latest version of xcode 10
latest iOS 12
latest Mac OS Mojave 10.14
Any news on this? Seems like a pretty substantial bug.
Hi @sharpwitz @chadkouse, could you provide the steps to reproduce the issue?
First, we initialize Firebase on - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
in the appDelegate, using [FIRApp configure];
then we call this function
[[FIRPhoneAuthProvider provider] verifyPhoneNumber:@"+13335551234"
UIDelegate:nil
completion:^(NSString * _Nullable verificationID, NSError * _Nullable error) {
NSLog(@"%@",verificationID);
}];
this always returns an Invalid Token
We do use a valid phone number (not the sample number above)
Same problem here. Since iOS 12 we started having user not able to login and same issue happens to me on my device (iPhone 7 Plus with iOS12), simulator is working well and also one of my partner device with iOS12 works well.
I don't know if it could cause the issue but I'm manually initializing firebase providing the correct plist
let firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info-dev", ofType: "plist")
let firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")
guard let options = FirebaseOptions(contentsOfFile: firebaseConfig!) else {
fatalError("Invalid Firebase configuration file.")
}
FirebaseApp.configure(options: options)
Hi everyone, could you please try generating a new APNs key and upload it to your Firebase project. (go Project Settings -> Cloud Messaging -> iOS app configuration). Or use an APNs Certificate instead.
Please let me know if it works for you.
Looks like it worked! I'll ask the users complaining about that to try again
Thank you
We use recaptcha instead of APNS because it is a headache to renew the APNS annually. So anyone using recaptcha is still stuck with the current bug unfortunately.
@sharpwitz I wasn't able to reproduce your issue. Will the recaptcha view appear? or it throws error immediately?
I could not get to the recaptcha screen. Which I have in the past.
@sharpwitz are there any errors when you try to navigate to the recaptcha screen, or do you just get a blank screen?
I get the invalid token error before the recaptcha view appears.
Using latest crashlytics 3.10.9
I created a MPOC (minimal proof of concept) and that had no issues with SMS Auth.
Perhaps a library conflict?

I'm unable to tell from your shared dependencies. At first glance none of them should (or are known to) conflict with Firebase Auth.
Can anyone who's running into this issue share their project?
I've got the same error and it's not related to APNS.
Tried both solutions in https://github.com/firebase/firebase-ios-sdk/issues/1896#issuecomment-428084090 and it's not working.
I also can't access the recaptha, I just got an error on the PhoneAuthProvider.provider().verifyPhoneNumber method
@gautier-gdx can you share your project?
@morganchen12 I can't unfortunately.
This bug is really tricky to reproduce, this is appearing randomly for now and only on iOS 12 devices.
Even the Apple App Store review team had the problem yesterday so they rejected our app, after telling them to reinstall the same build, it worked directly with the same phone number...
I'll continue to investigate
@morganchen12 I can't unfortunately.
This bug is really tricky to reproduce, this is appearing randomly for now and only on iOS 12 devices.
Even the Apple App Store review team had the problem yesterday so they rejected our app, after telling them to reinstall the same build, it worked directly with the same phone number...
I'll continue to investigate
Hi, do you happen to have an update on this? I'm facing the same problem, where it doesn't access the recaptcha view and it gives the Invalid token on the VerifyPhoneNumber method instead.
do you have a workaround for this? I can't reproduce it in iOS 12.1 (maybe related)
having same issue on iOS 11.3.1 device as well. other devices are working fine. but one specific device always having this error even after delete and reinstall. there must be something to do with the token generated on that device. getting users complains more and more on this issue.
Hey everyone, looks like there's several issues being reported here.
@sharpwitz, please file a support ticket and we'll be able to take a look at your project specifically to see what's wrong.
For other people who have APNs integrated but are running into invalid token errors, please check that you're able to send notifications through APNs/FCM without issue. If you're not, please file a new issue on this repository with your project information.
The issue can be resolved with apns key.
It appears the latest SDK uses new code
To fix the above problem
we are using "signInAndRetrieveDataWithCredential" instead of "signInWithCredential"
also, if your app has PUSH notification enabled even though you don't make use of PUSH, then it can throw the SDK off. so disable PUSH if your app does not make use of PUSH.
It appears the latest SDK uses new code
To fix the above problem
we are using "signInAndRetrieveDataWithCredential" instead of
"signInWithCredential"
also, if your app has PUSH notification enabled even though you don't make
use of PUSH, then it can throw the SDK off.
so disable PUSH if your app does not make use of PUSH.
On Thu, Oct 4, 2018 at 2:07 PM Chad Kouse notifications@github.com wrote:
Any news on this? Seems like a pretty substantial bug.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-ios-sdk/issues/1896#issuecomment-427115983,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAg3Rc5G-HFY8pUcDKJLb_68yScufkrPks5uhk5agaJpZM4XC6bz
.
I am also facing the same issue...please give a proper solution for this issue...
I am from India, am working on an ios app, In this the Indian mobile numbers are successfully getting OTP from the firebase where the international mobile numbers that are used in physical devices in their respective countries are not getting OTP. I tried using the international numbers from India for authentication then they are getting OTP in their country, But when they are testing app from their country the OTP not receiving for international numbers in their physical devices.( In my firebase iOS app configuration I used APNS Certificate(.p12) *, not uploaded *APNs Authentication Key).
currently using latest firebase ios SDK 5.17.0
the latest version of Xcode 10
latest iOS 12
@balashekar3 This seems not a SDK issue. Please file a ticket on https://firebase.google.com/support/ so your case can be inspected with more details.
issue solved.
@balashekar3 I am still facing this issue. How did you resolved it. can you please guide. TIA
Our app did not use push notification, but in the app somewhere we had
enabled PUSH. Once we disabled PUSH, it resolved the issue.
On Mon, Mar 18, 2019 at 11:43 AM hardik anavadia notifications@github.com
wrote:
@balashekar3 https://github.com/balashekar3 I am still facing this
issue. How did you resolved it. can you please guide. TIA—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-ios-sdk/issues/1896#issuecomment-473967139,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAg3RcGC8_gvN9--z4z-I_h3rG0DDzHpks5vX7QjgaJpZM4XC6bz
.
@hardikanavadia after uploading APNs Auth Key in firebase iOS app configuration it is solved.if it does not solve the issue to you contact firebase support team they will guide you because I did like this only.
If you're using APNs certificates then please login to Firebase console and remove that user from users list under Authentication section. For APNs Auth Key you should configure the Auth Key in Firebase configuration section.
It will work.
Please login to Firebase console and remove that user from users list under Authentication section.
It will work.
Didn't work for me. The @balashekar3 's answer did the job.
I was integrating this with ReactNative (using library /react-native-firebase) and uploading APNs Authentication Key was not working. I have uploaded APNs Certificates and this error was resolved.
Most helpful comment
Hi everyone, could you please try generating a new APNs key and upload it to your Firebase project. (go Project Settings -> Cloud Messaging -> iOS app configuration). Or use an APNs Certificate instead.
Please let me know if it works for you.