Function SignInWithFacebook doesn't exist in Firebase Auth SDK for Flutter in macOS, but in Windows it exists
Solution 1
signInWithFacebook is no longer exist. This is work perfectly! flutter_facebook_login 3.0.0
final FacebookLoginResult facebookLoginResult = await facebookLogin.logIn(['email', 'public_profile']);
FacebookAccessToken facebookAccessToken = facebookLoginResult.accessToken;
AuthCredential authCredential = FacebookAuthProvider.getCredential(accessToken: facebookAccessToken.token);
FirebaseUser fbUser;
fbUser = (await _firebaseAuth.signInWithCredential(authCredential)).user;
Solution 2
Yes, the method signInWithFacebook
is gone from FirebaseAuth
now we do this work with signInWithCredential
method with AuthCredential
and FacebookAuthProvider
classes to make autentication process. I will put a snipet with some comments just to illustrate how to do auth in firebase with facebook credentials. I hope it helps...
/// in some point of your code you will get facebookLoginResult
final facebookLoginResult = await facebookLogin
.logInWithReadPermissions(['email', 'public_profile']);
FacebookAccessToken myToken = facebookLoginResult.accessToken;
///assuming sucess in FacebookLoginStatus.loggedIn
/// we use FacebookAuthProvider class to get a credential from accessToken
/// this will return an AuthCredential object that we will use to auth in firebase
AuthCredential credential= FacebookAuthProvider.getCredential(accessToken: myToken.token);
// this line do auth in firebase with your facebook credential.
FirebaseUser firebaseUser = (
await FirebaseAuth.instance.signInWithCredential(credential)
).user;
/// ... do your things
Solution 3
It looks like signInWithFacebook
was removed in 0.7.0
and signInWithCredential
was added instead.
The change log could have been more clear about the change: https://pub.dartlang.org/packages/firebase_auth#070
See also: https://github.com/flutter/plugins/commit/a444ad120418d622c4dea2882190968722abbcfe
If you update to a newer plugin version you probably also will https://flutter.io/docs/development/packages-and-plugins/androidx-compatibility
Solution 4
Unfortunately flutter_facebook_login 3.0.0 broken in Flutter 1.17.
Gabriele Guccione
Hi, I am student attending the last year of secondary school called 'ITI' (literally Industrial Technical Institute). I have passed a contest and now I am working for a ICT company with the role of mobile developer.
Updated on December 09, 2022Comments
-
Gabriele Guccione over 1 year
I have started using Flutter this year, so I am not an expert. I am trying to develop an app for both Android and iOS that includes login with Google and Facebook using Firebase Auth.
First I wrote the code in Android Studio in Windows and it works, but when I write it in Android Studio in macOS some lines of code don't work properly. I have configured the iOS project on the Firebase console and on Facebook for developers 'console'. I didn't use CocoaPods to add the frameworks, but I did it manually on Xcode.
Basically, the error is:
The method 'signInWithFacebook' isn't defined for the class 'FirebaseAuth'.