'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 iOS 12 latest Mac OS Mojave 10.14

I saw an earlier issue in June 2018 ( 3 months ago ) but not sure if it relates to our project https://github.com/firebase/firebase-js-sdk/issues/916

https://github.com/firebase/firebase-ios-sdk

Is there a solution around this or is this a Firebase iOS SDK bug?



Solution 1:[1]

It seems like there's a problem while using the .p12 file for APNs in Firebase. I was facing the same problem and solved it changing the .p12 certificate for the .p8 instantly changing this, my app receives the SMS.

You can generate the .p8 file in your Apple Developer account in the section Keys download the file and save it in a safe place. This new key also generates a KeyId that could be needed in the Firebase settings. Finally you would need the TeamId that corresponds to your Apple Developer account, you can found it in the Profile settings.

Hope this can help you.

Solution 2:[2]

Same Here! I had the exact same problem, turned out that I forgot to set the Identifier to Client in the "URL Types" in the Info of the project.

enter image description here

Hopefully it would work for you.

Solution 3:[3]

I am also using same configuration that you describe in your question, and I am using this firebase methods it's perfectly running. so you can check your credential that you are using. Also check firebase docs.

Auth.auth().signIn(withEmail: email, password: password) { (result, error) in

    if error == nil {

        guard let user = result?.user else {
            return
        }
        // do your stuff
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 sajede Nouri
Solution 3 Haresh Gediya