Flutter_facebook_login: Relogin on Android is considered cancelled by user

Created on 20 Aug 2018  路  4Comments  路  Source: roughike/flutter_facebook_login

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)

Most helpful comment

Possible workaround: Call logout function before login.

// Logout user before login
await facebookSignIn.logOut();

var result = await facebookSignIn.logInWithReadPermissions(['email']);

All 4 comments

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:

  • when the login is in progress, you should disable your facebook login button
  • if the user is logged in, there shouldn't be a way to trigger the login again
  • when the user logs out of your app, you should probably call 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']);
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mis0025033 picture mis0025033  路  8Comments

Ismaeils picture Ismaeils  路  6Comments

zainzafar90 picture zainzafar90  路  6Comments

Sameerkash picture Sameerkash  路  3Comments

nsmith1024 picture nsmith1024  路  6Comments