-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Bug report
Describe the bug
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 originally asked the question on stackoverflow, but since another user mentioned that this problem occurs when using email sign in as well, it is probably a bug.
Steps to reproduce
Steps to reproduce the behavior:
- I used
flutterfire configure
to add the app to an existing Firebase project and create the IOS application there. - I've added
firebase_core@2.1.1
andfirebase_auth@4.1.1
- I've enabled the Phone sign-in method on Firebase and added +44 7123 123 456 as a test number, and the code is 000000
- I've added the
Push notification
andBackground modes
capability withBackground fetch
andRemote notifications
options. - I've added the the
REVERSED_CLIENT_ID
fromGoogleService-Info.plist
as anURL Scheme
. - On the Apple Developer page, I've generated a new key with
Apple Push Notifications service (APNs) service
and uploaded it as anAPNs 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.
Expected behavior
The codeSent callback should be called instead of verificationFailed.
Sample project
Additional context
I've created a simple repository to reproduce the issue: https://github.com/peternagy1332/basic_phone_auth
Flutter doctor
Run flutter doctor
and paste the output below:
Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.7, on macOS 13.0 22A380 darwin-arm, locale en-HU)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.73.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 1 category.
I'm focusing on iOS only for now.
Flutter dependencies
Run flutter pub deps -- --style=compact
and paste the output below:
Click To Expand
Dart SDK 2.18.4
Flutter SDK 3.3.7
basic_phone_auth 1.0.0+1
dependencies:
- cupertino_icons 1.0.5
- firebase_auth 4.1.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 2.1.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
dev dependencies:
- flutter_lints 2.0.1 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
transitive dependencies:
- _flutterfire_internals 1.0.7 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.9.0 [collection meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- characters 1.2.1
- clock 1.1.1
- cloud_firestore_platform_interface 5.8.4 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 3.0.4 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.16.0
- fake_async 1.3.1 [clock collection]
- firebase_auth_platform_interface 6.11.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.1.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.0.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- intl 0.17.0 [clock path]
- js 0.6.4
- lints 2.0.1
- matcher 0.12.12 [stack_trace]
- material_color_utilities 0.1.5
- meta 1.8.0
- path 1.8.2
- plugin_platform_interface 2.1.3 [meta]
- sky_engine 0.0.99
- source_span 1.9.0 [collection path term_glyph]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- string_scanner 1.1.1 [source_span]
- term_glyph 1.2.1
- test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.1 [collection]
- vector_math 2.1.2