jeduan / cordova-plugin-facebook4

Use the latest Facebook SDK in your Cordova and Ionic projects
Other
765 stars 510 forks source link

Plugin keeps going to web login on iOS 13 #819

Closed snblackout closed 4 years ago

snblackout commented 4 years ago

I'm really sorry if this shouldn't belong here but Stackoverflow history of support on this plugin is very bad (lots of unanswered questions, no official tag) and this is pretty important for our project to fix and hope others can help and maybe are experiencing this too.

Bug or feature request

[X ] I'm reporting a reproducible issue with the code [ ] I'm reporting a feature request

Describe the Bug of feature request

No matter what I do, the plugin only kicks into the web login method and does not use the installed FB app.

What I've tried:

I've checked the "Deep link" option in the Facebook app settings for iOS and Android platforms.

Uninstalling Facebook app, Uninstalling my app Rebooting Re-install Facebook app, Re-install my app

Reverted to AppStore version of my app released in February 2019 and Facebook login with native app (Plugin version 1.7.4) was working at the time of release. Now this published old version, no matter what, goes to the web login method on new iOS 13.

2 different phones on 2 versions of iOS 13. Same result even after uninstall, reboot, then re-install above.

I've let the Facebook settings sit for a while after changing to "propagate" but still nothing.

I've tried to upgrade plugin to 6 but I use Phonegap Build and I believe it doesn't jive with Cocoapods and the build fails. I can only get a build on latest version 5.

Expected Behavior

If the Facebook app is installed on the device, should ask to go into the app to approve login.

WORKING

These two below situations prompted the Facebook native app to login and not the web login method.

iOS 10.3.3 on iPhone 5C with latest release of AppStore app from Apple, plugin 1.7.4 iOS 12.1.3 on iPhone 6S with latest release of AppStore app from Apple, plugin 1.7.4

Plugin version, OS, devices, etc

iOS 13.1.2 on iPhone 11 Pro Max iOS 13.0 on iPhone 6S Plus

Plugin version: 5.0.0

Additional Context

I've tried:

Problem: Calling the login function always opens the web dialog even though the native app is installed on the device.
Solution: Switch "deep linking" to ON in the Facebook developer website settings for your application

Thank you!

peterpeterparker commented 4 years ago

Not so much we could do on the plugin side. Furthermore looks like you are facing your problem. regardless of the plugin version number, therefore. I close this support request as explained in the disclaimer, otherwise difficult to keep track.

That being said you could follow the issue https://github.com/jeduan/cordova-plugin-facebook4/issues/794 for the Phonegap Build issue. Note that since it was discussed more than a month ago, OP didn't get back with more news, so no idea what's the current status.

Regarding Cocoapods, if you are in the mood to hack and if that blocks you, you could of course fork the plugin, remove the Cocoapods references and install manually the Fb SDK dependencies in your project.

Good luck.

snblackout commented 4 years ago

Hi Peter,

I've forked the project. Removed the cocoapods references, added back the old "framework" references. Went to Facebook releases and download the "FacebookSDK_Static.zip" and updated the correct files within my fork.

I removed the 'cordova-plugin-facebook4' plugin from my project.

I've added the below to my config.xml reference:

    <plugin spec="https://github.com/snblackout/cordova-plugin-facebook4#cocoapod-workaround" source="git">
      <variable name="APP_ID" value="XX" />
      <variable name="APP_NAME" value="XX" />
    </plugin>

This builds on Phonegap Build just fine and I can deploy that build to my phone. When I issue 'facebookConnectPlugin.login()' it still opens a WebView and does not go to native app.

I'm at a loss. Could this be a 32bit/64bit app communication issue?

iOS 10: Native app login works iOS 12: Native app login works iOS 13: Webview login only

PhoneGap (iOS / Android / Windows) cli-9.0.0 (5.0.1 / 8.0.0 / 7.0.0)

peterpeterparker commented 4 years ago

First of all, wow, thank you for all the effort, really impressive!

Unfortunately I'm a bit lost too and I'm away and will not have access to an iPhone before a bit, therefore I could not even test your plugin version and don't know much than that neither, as the release notes from Fb are kind of short.

I reopen the issue, if anyone could share his/her thought about it would be cool notably on:

  1. Is that a Fb SDK bug or not? Or is it always Webview login on iOS13?
  2. If not webview and not bug, does it need a modification in the plugin?
snblackout commented 4 years ago

I dove in a bit more to this plugin, setup a new repo with the very basic needed to get a project up and test a Facebook login (link). I was able to setup as my AppStore app and build it and deploy this build on my test devices. The results are the same as my main project and iOS 13 always falls back to WebView Facebook login. iOS or below kicks into the main native app for authentication.

Looking into the plugin code 'FacebookConnectPlugin.m', specifically around:

    FBSDKLoginManagerLoginResultBlock loginHandler = ^void(FBSDKLoginManagerLoginResult *result, NSError *error) {
        if (error) {
            // If the SDK has a message for the user, surface it.
            NSString *errorMessage = error.userInfo[FBSDKErrorLocalizedDescriptionKey] ?: @"There was a problem logging you in.";
            CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
                                                              messageAsString:errorMessage];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
            return;
        } else if (result.isCancelled) {
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
                                                              messageAsString:@"User cancelled."];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        } else {
            CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
                                                          messageAsDictionary:[self responseObject]];
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        }
    };

If I was to cancel the attempt, the 'isCancelled' is caught above. If there is an error, it is caught there. If I continue to login to Facebook in the WebView, FB authentication works and success is returned with a token.

So this looks like an issue within FBSDK 5+ as the internals of the SDK determine if native should fail and kick into WebView. Nothing this plugin can do about that.

I'm not sure who to submit this to or what. But I'm surprised others that use this plugin hasn't noticed that their apps aren't using the native method to login on any new app builds with phonegap cli 9.0.0 and iOS 5.0.1.

Hoping some more can comment here and verify they are experiencing this too.

snblackout commented 4 years ago

Native login has magically just started working on iOS 13... on both my projects AND on the latest of this plugin (with manually added frameworks in my custom repo).

My guess is FB had an issue they may have resolved internally???.. ugh

peterpeterparker commented 4 years ago

Thx @snblackout for the analysis and feedback, super super cool 👍

If it worked magically I would have the same guess, Fb probably solved it. We might never know 😉

As it is solved, I close the issue. Again, cool and thx for the effort!