On Android, connecting to Facebook once works fine but following attempts fail. So it fails when the facebook activity remembers the credentials, skips the prompt and only displays the confirmation screen. flutter_facebook_login fails by reporting a "cancelledByUser" status instead of "loggedIn".
On iOS, everything works great, whether credentials are prompted or not.
I've tested this on an emulator running on Android 9.0, and on a real device on 7.1.1. Neither of these have the Facebook app installed.
I'm using flutter_facebook_login 1.1.1.
Doctor summary (to see all details, run flutter doctor -v):
[鉁揮 Flutter (Channel dev, v0.5.8, on Mac OS X 10.13.6 17G65, locale en-KR)
[鉁揮 Android toolchain - develop for Android devices (Android SDK 27.0.3)
[鉁揮 iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[鉁揮 Android Studio (version 3.1)
[鉁揮 VS Code (version 1.25.1)
[鉁揮 Connected devices (4 available)
Same thing here
I confirmed this
Possible workaround: Call logout function before login.
// Logout user before login
await facebookSignIn.logOut();
var result = await facebookSignIn.logInWithReadPermissions(['email']);
You should not trigger the logInWithReadPermissions (or loginWithPublishPermissions) multiple times:
logout() on the Facebook Login plugin.If above is not possible, before calling the login methods, you could do something like this:
final existingToken = await facebookLogin.currentAccessToken;
if (existingToken != null) {
// Reuse existing access token, no need to sign in just now
} else {
// Not logged in yet
facebookLogin.logInWithReadPermissions(['email']);
}
Most helpful comment
Possible workaround: Call logout function before login.