I am developing an existing flutter project on mac, and when trying to test the phone number authentication provided through Firebase I get the following error message:
FirebaseAuth/PhoneAuthProvider.swift:76: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
and the app crashes.
The phone authentication feature worked in the past when running on an android simulator, and only has popped up when moving to ios. When logging in with a phone number, the following function is called:
void phoneAuthentication(BuildContext context, String phoneNumber) async {
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumber,
verificationCompleted: (PhoneAuthCredential credential) async {
await FirebaseAuth.instance.signInWithCredential(credential);
},
verificationFailed: (e) {
print(e);
showErrorMessage(e.code, context);
},
codeSent: ((String verificationId, int? resendToken) async {
context.push('/seniorPhoneVerification', extra: verificationId);
}),
codeAutoRetrievalTimeout: (String verificationId) {},
);
}
But it appears the app crashes immediately after calling FirebaseAuth.instance.verifyPhoneNumber