Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

FacebookLoginBehavior.nativeWithFallback not working with iOS #195

Open
lmordell opened this issue Oct 4, 2019 · 6 comments
Open

FacebookLoginBehavior.nativeWithFallback not working with iOS #195

lmordell opened this issue Oct 4, 2019 · 6 comments

Comments

@lmordell
Copy link

lmordell commented Oct 4, 2019

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
Copy link

opringle commented Oct 10, 2019

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
Copy link

anjrew commented Oct 10, 2019

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

@yashdabi
Copy link

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

@KaungKhantHtun
Copy link

Thanks, @Imordell !

@joserocha3
Copy link

joserocha3 commented Oct 25, 2019

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
Copy link

buidan commented Oct 10, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants