Flutter_facebook_login: no login dialog on iOS; works fine on Android

Created on 4 Feb 2020  路  2Comments  路  Source: roughike/flutter_facebook_login

I have ^2.0.1 of flutter_facebook_login plugin in pubspec.yml.

I've registered my app with Facebook according to the FB developer iOS docs, following steps 1, 3 & 4.

I enabled Facebook signin on Firebase, adding the OAuth Redirect URI from Firebase to the Facebook Login settings in the Facebook dashboard for the app.

My auth code when clicking the FB login button:
@override Future<User> signInWithFacebook() async { final facebookLogin = FacebookLogin(); final result = await facebookLogin.logInWithReadPermissions( ['public_profile'], ); if (result.accessToken != null) { final authResult = await _firebaseAuth.signInWithCredential( FacebookAuthProvider.getCredential( accessToken: result.accessToken.token, ), ); return _userFromFirebase(authResult.user); } else { throw PlatformException( code: 'ERROR_ABORTED_BY_USER', message: 'Sign in aborted by user', ); } }

Here is my Info.plist:
Screen Shot 2020-02-04 at 12 39 21 AM

When I run an iOS simulator on Android Studio and click the login button, I do not get the login dialog, and I get this console message:
Falling back to storing access token in NSUserDefaults because of simulator bug [C5.1 F2C14466-F344-4ACC-9E0B-E7FD60D2AC5A 2605:6000:1525:880d:1501:5d0c:1d99:b5d.61158<->2a03:2880:f034:112:face:b00c:0:2.443] Connected Path: satisfied (Path is satisfied), interface: en0 Duration: 0.169s, DNS @0.000s took 0.004s, TCP @0.004s took 0.037s, TLS took 0.040s bytes in/out: 3938/2890, packets in/out: 8/10, rtt: 0.052s, retransmitted packets: 0, out-of-order packets: 0

When I run in XCode, I do not get the login dialog and I get these console messages:
2020-02-04 01:36:12.420411-0600 Runner[78781:7303740] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn鈥檛 be completed. (OSStatus error -10814.)" 2020-02-04 01:36:12.420705-0600 Runner[78781:7303740] Falling back to storing access token in NSUserDefaults because of simulator bug 2020-02-04 01:36:12.422583-0600 Runner[78781:7303740] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn鈥檛 be completed. (OSStatus error -10814.)"

When I try to login to Facebook on Android, no problems.

Please help!

Most helpful comment

Latest version 3.0.0 solved your problem

For version 2.0.1

As per the issue list for the plugin this is a bug for iOS 13 (https://github.com/roughike/flutter_facebook_login/issues/195)

Use the device_info package and you can put the following check for the iOS 13 device so the rest of the world enjoys the native view

 if (Platform.isIOS){
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
  String iosSystemVersion = iosInfo.systemVersion;

  if (iosSystemVersion.startsWith('13')){
     print('Running on IOS version $iosSystemVersion. Forcing facebook login to be 
webViewOnly');
     _facebookSignIn.loginBehavior = FacebookLoginBehavior.webViewOnly;
  }
}

All 2 comments

Latest version 3.0.0 solved your problem

For version 2.0.1

As per the issue list for the plugin this is a bug for iOS 13 (https://github.com/roughike/flutter_facebook_login/issues/195)

Use the device_info package and you can put the following check for the iOS 13 device so the rest of the world enjoys the native view

 if (Platform.isIOS){
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
  String iosSystemVersion = iosInfo.systemVersion;

  if (iosSystemVersion.startsWith('13')){
     print('Running on IOS version $iosSystemVersion. Forcing facebook login to be 
webViewOnly');
     _facebookSignIn.loginBehavior = FacebookLoginBehavior.webViewOnly;
  }
}

Thank you very much, @Gursewak-Uppal. I saw that issue you referred to but didn't think it applied to my situation.

Was this page helpful?
0 / 5 - 0 ratings