facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.

Home Page:https://developers.facebook.com/docs/ios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Facebook Login Not Working On The First Login

aemreb opened this issue · comments

Checklist before submitting a bug report

Xcode version

15.4

Facebook iOS SDK version

17.0.1

Dependency Manager

SPM

SDK Framework

Core

Goals

I want the Facebook app to redirect back to my app after login process is initialized while logged out on the Facebook app.

Expected results

I want the Facebook app to redirect back to my app.

Actual results

Facebook app stays in place, directs me to the home page.

Steps to reproduce

-Log out of Facebook on web and the mobile app
-Log in using the Facebook Login button placed inside the app
-See that the redirect mechanism back to the main app is broken, but it works fine if the user is already logged in on the FB app

Code samples & details

// INSERT YOUR CODE HERE
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        _ = ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }


    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        guard url.scheme != nil else { return false }
        if url.scheme == "fbxxxxxx" { //Facebook id
            return ApplicationDelegate.shared.application(app, open: url, options: options)
        }

        if url.host == "authorize" {
            Adjust.appWillOpen(url)
            return ApplicationDelegate.shared.application(app, open: url, options: options)
        }
        return true
    }



// ---------

        let facebookLoginButton = FBLoginButton()
        facebookLoginButton.delegate = self
        facebookLoginButton.permissions = ["public_profile", "email"]
        facebookLoginButton.sendActions(for: .touchUpInside)
        facebookSignInCompleted = completion

// ----------