Zeeshan Ahmed
Zeeshan Ahmed

Reputation: 121

i'm receiving 'invalid token' from firebase when verifying phone number in swift 4

I'm currentty trying to authenticate phone number using firebasephoneauth. It's working absolutely fine in Pakistan, UK and around, but firebase giving 'invalid token' error from firebase when the app user is in US.

func VerfiyPhoneNumber(PhoneNo:String,completionHandler: @escaping ((_ verID: String , _ success: Bool, _ msg: String) -> Void))
        {
            PhoneAuthProvider.provider().verifyPhoneNumber(PhoneNo, uiDelegate: nil) { (verificationID, error) in
                if let error = error {
                    completionHandler("", false, (error.localizedDescription))
                }
                else
                {
                    completionHandler(verificationID!,true, "Operation Successfull\nPhone Number Verified.")
                }
            }
        }




VerfiyPhoneNumber(PhoneNo: number, completionHandler: { (verificationID, status, message) in
                            if status
                            {
                                userPrefrences.setValue(verificationID, forKey: PrefrencesKeys.verificationID)
                                self.present_contact_no_verification()
                            }
                            else
                            {
                                self.alert(message: message)
                            }
                        })

Upvotes: 1

Views: 1017

Answers (1)

Zeeshan Ahmed
Zeeshan Ahmed

Reputation: 121

  • the issue was i had uploaded apple development certificate on firebase console & my application worked fine on all devices which were registered to that Apple Account,but then i uploaded a Apple production Certificate on firebase console.My Application started working perfect on all devices which were not even registered.
  • Now its my advice to everybody you can simply create a .p8 key from Apple developer Website and upload it to firebase console and ignore uploading development & production certificates.

Upvotes: 1

Related Questions