expressLogin method

  1. @override
Future<LoginResult> expressLogin()
override

Express login logs people in with their Facebook account across devices and platform. If a person logs into your app on Android and then changes devices, express login logs them in with their Facebook account, instead of asking for them to select a login method.

This avoid creating duplicate accounts or failing to log in at all. To support the changes in Android 11, first add the following code to the queries element in your /app/manifest/AndroidManifest.xml file. For more info go to https://developers.facebook.com/docs/facebook-login/android

Implementation

@override
Future<LoginResult> expressLogin() async {
  if (isAndroid) {
    try {
      final result = await channel.invokeMethod("expressLogin");
      final token = AccessToken.fromJson(Map<String, dynamic>.from(result));
      return LoginResult(status: LoginStatus.success, accessToken: token);
    } on PlatformException catch (e) {
      return LoginResult.getResultFromException(e);
    }
  }
  return LoginResult(
    status: LoginStatus.failed,
    message: 'Method only allowed on Android',
  );
}