NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
189 stars 107 forks source link

Facebook login not closing (delegate issue?) #349

Open Oshr1 opened 1 year ago

Oshr1 commented 1 year ago

Facebook login + firebasr not working properly, FB app opens and after successfully submitting Facebook login the app stays open and not returning to my app

souriscloud commented 1 year ago

this is what I experience now too

res0 commented 9 months ago

me too :/ did you guys find a solution for this?

CatchABus commented 9 months ago

Title refers to a delegate, so I guess it's an iOS-specific problem? Does anyone experience the same problem on android?

res0 commented 9 months ago

@CatchABus yeah it's iOS specific, it works on iOS Simulator though (as there's no FB app), but it doesn't work on real iOS device where the Facebook app is installed. It opens a window with a button which says Log In With the Facebook App, which when clicked opens the Facebook App where I can tap on Log in. Then it goes back to that window without closing and resolving.

LewisSmallwood commented 6 months ago

I am also having this problem. It's like the NSCFacebookUIAppDelegateExt isn't being used.

I tested this with the new addDelegateHandler and I can see the events when the user returns from the Facebook app.

const Application = require("@nativescript/core").Application;

if (Application.ios) {
    Application.ios.addDelegateHandler('applicationOpenURLOptions', (app, url, options) => {
        console.log("HANDLE RETURN FROM FACEBOOK.");
    });
 }

No idea how to link this up though...

LewisSmallwood commented 6 months ago

I did some more digging, and have found a fix that utilizes the new addDelegateHandler added in v8.6.0.

It would be useful if this could be merged into the plugin's init method so we don't have to add this too...

But to get it working, just add this code after the LoginManager.init(); call:

if (Application.ios) {
    // Hook the launch event up with the Facebook SDK delegate.
    Application.ios.addDelegateHandler("applicationDidFinishLaunchingWithOptions", (app, launchOptions) => {
        return FBSDKApplicationDelegate.sharedInstance.applicationDidFinishLaunchingWithOptions(app, launchOptions);
    });

    // Hook up the application launch from URL.
    Application.ios.addDelegateHandler('applicationOpenURLOptions', (app, url, options) => {
        if (url && url.scheme.startsWith("fb")) {
            FBSDKApplicationDelegate.sharedInstance.applicationOpenURLSourceApplicationAnnotation(app, url, options.valueForKey(UIApplicationOpenURLOptionsSourceApplicationKey), options.valueForKey(UIApplicationOpenURLOptionsAnnotationKey));
        }
    });
}
res0 commented 6 months ago

@LewisSmallwood thanks for looking at this :) I tried it now, however I get this error when I get back from the Facebook app: TypeError: FBSDKApplicationDelegate.sharedInstance.applicationOpenURLSourceApplicationAnnotation is not a function Do you know what can be the problem on my side?

res0 commented 5 months ago

@LewisSmallwood do you know if you have development target set to 13+? I'm reading this on Facebook SDK docs(https://developers.facebook.com/docs/facebook-login/ios/)

iOS 13 moved opening URL functionality to the SceneDelegate. If you are using iOS 13, add the following method to your SceneDelegate so that operations like logging in or sharing function as intended

So I'm curious if that could be the problem for me if I have target set to 13?