I've started to setup Firebase Phone authentication in Flutter based on the official documentation. Unfortunately, no matter how I try, I get a FirebaseAuthException
in the verificationFailed
callback of the verifyPhoneNumber
method with these values:
code: "invalid-app-credential"
credential: null
email: null
message: "Token mismatch"
phoneNumber: null
plugin: "firebase_auth"
stackTrace: null
tenantId: null
I've created a simple repository to reproduce the issue: https://github.com/peternagy1332/basic_phone_auth
flutterfire configure
to add the app to an existing Firebase project and create the IOS application there.firebase_core@2.1.1
and firebase_auth@4.1.1
Push notification
and Background modes
capability with Background fetch
and Remote notifications
options.REVERSED_CLIENT_ID
from GoogleService-Info.plist
as an URL Scheme
.Apple Push Notifications service (APNs) service
and uploaded it as an APNs Authentication Key
to Firebase.The setup section of the official documentation points me to this documentation. This indicates that additional modifications in the Swift code might be needed, but it's really unclear. I'm a Flutter developer and not a native IOS developer, I don't think I actually need to do all that.
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let firebaseAuth = Auth.auth()
firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)
}