roughike / flutter_facebook_login

A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.
BSD 2-Clause "Simplified" License
405 stars 331 forks source link

FacebookLoginBehavior.nativeWithFallback not working with iOS #195

Open lmordell opened 4 years ago

lmordell commented 4 years ago

I'm using version 2.0.1 of flutter_facebook_login.

When I attempt to perform a facebook login on iOS, the modal never appears and the result status is 'FacebookLoginStatus.cancelledByUser'. This issue does not occur on Android.

As a workaround, I conditionally set the FacebookLoginBehavior to 'webViewOnly' for iOS. With this behavior, I can see the Facebook login modal.

final facebookLogin = FacebookLogin();

facebookLogin.loginBehavior = Platform.isIOS
    ? FacebookLoginBehavior.webViewOnly
    : FacebookLoginBehavior.nativeWithFallback;

final result = await facebookLogin.logInWithReadPermissions(['email']);
opringle commented 4 years ago

I am also experiencing this issue on iOS 13 devices only.If you want to minimize the number of users you annoy, you can detect device iOS version with the device_info package:

// TODO: remove this when issue fixed  so IOS 13 users can login through the native facebook app
// https://github.com/roughike/flutter_facebook_login/issues/195
 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;
   }
}
anjrew commented 4 years ago

Me too. Thanks, @Imordell ! that fixed it for me. Hours wasted on that before I got your answer

yashdabi commented 4 years ago

@lmordell Thanks for facebookLogin.loginBehavior = Platform.isIOS ? FacebookLoginBehavior.webViewOnly : FacebookLoginBehavior.nativeWithFallback;

KaungKhantHtun commented 4 years ago

Thanks, @Imordell !

joserocha3 commented 4 years ago

I am doing this as well and just received an email from Facebook saying I am in violation of one of their policies.

I have until 10-31 to correct the issue or my app will face "enforcement".

https://developers.facebook.com/policy#7-2-photo

Android apps should use the default login behavior defined by the SDK, which may use the web-view Login dialog. On iOS, only kiosk apps may use a web-view Login dialog.

buidan commented 3 years ago

I found a working solution by add some extra code to AppDelegate.swift

override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
         if url.scheme == "fbXXXXXXXXX" {
                return ApplicationDelegate.shared.application(app, open: url, options: options)
         }
        .....
    }

Relace XXXXXXXXX with your facebook ID