简体   繁体   中英

Facebook Login not working in iOS 13 in Objective-C

How to make Facebook Login work in iOS 13 in Objective-C? It's working in iOS 12 but not working in iOS 13 (it returns isCancellation true).

if you have created app in xCode 11 please follow me.

IMPORTANT- import FBSDKLoginKit in sceneDelegate file.

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
enter code here
  guard let url = URLContexts.first?.url else { return }
    
  let _ = ApplicationDelegate.shared.application(
        UIApplication.shared,
        open: url,
        sourceApplication: nil,
        annotation: [UIApplication.OpenURLOptionsKey.annotation])
}

Upgrading to the current FBSDK should resolve the problem.

FBSDKCoreKit/FBSDKCoreKit/Internal/BridgeAPI/FBSDKBridgeAPI.m was modified to support iOS 13's requirement to implement ASWebAuthenticationPresentationContextProviding in FBSDKCoreKit 5.4. The current version is 5.8. Versions prior will no longer work.

The needed change is posted here: https://github.com/facebook/facebook-ios-sdk/commit/6b061099f339ef0e8bde2e2c2163ef5a3c1b8340#diff-72593591275d63edfb1bfad837e4c32f

Just add the following code below 'didFinishLaunchingWithOptions' delegate method in AppDelegate. It works with latest Facebook SDK and iOS 13 as well. Comment if anyone gets an error.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM