//Here is my main.dart code
signIn() {
FirebaseAuth.instance
.signInWithPhoneNumber(verificationId: verificationId, smsCode: smsCode)
.then((user) {
Navigator.of(context).pushReplacementNamed('/homepage');
}).catchError((e) {
print(e);
});
}
//Here is my pubspec.yaml code
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
firebase_auth:
//Here is my logcat
Error: The method 'signInWithPhoneNumber' isn't defined for the class 'FirebaseAuth'.
Try correcting the name to the name of an existing method, or defining a method named 'signInWithPhoneNumber'.
I am implementing phone number login in my flutter app.I installed all the dependencies and also i pasted google_services.json file in my project.
Firebase Auth provides many methods and utilities for enabling you to integrate secure authentication into your new or existing Flutter application. In many cases, you will need to know about the authentication state of your user, such as whether they're logged in or logged out.
FlutterFire provides two individual ways to sign a user in with their phone number. Native (e.g. Android & iOS) platforms provide different functionality to validating a phone number than the web, therefore two methods exist for each platform exclusively: Native Platform: verifyPhoneNumber.
Phone authentication allows users to sign in to Firebase using their phone as the authenticator. An SMS message is sent to the user (using the provided phone number) containing a unique code. Once the code has been authorized, the user is able to sign into Firebase.
On the Firebase Console, select the "Phone" authentication provider and click on the "Phone numbers for testing" dropdown. Enter a new phone number (e.g. +44 7444 555666) and a test code (e.g. 123456 ). If providing a test phone number to either the verifyPhoneNumber or signInWithPhoneNumber methods, no SMS will actually be sent.
Ran into the same issue. I believe its been replaced:
final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: _verificationId,
smsCode: _smsController.text,
);
final FirebaseUser user = await _auth.signInWithCredential(credential);
https://github.com/flutter/plugins/blob/master/packages/firebase_auth/example/lib/signin_page.dart#L423-L427
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With