简体   繁体   English

Facebook 登录在 iOS 13 中不起作用 Objective-C

[英]Facebook Login not working in iOS 13 in Objective-C

How to make Facebook Login work in iOS 13 in Objective-C?如何使 Facebook 登录在 Objective-C 的 iOS 13 中工作? It's working in iOS 12 but not working in iOS 13 (it returns isCancellation true).它在 iOS 12 中工作,但在 iOS 13 中不起作用(它返回 isCancellation true)。

if you have created app in xCode 11 please follow me.如果您在 xCode 11 中创建了应用程序,请关注我。

IMPORTANT- import FBSDKLoginKit in sceneDelegate file.重要- 在 sceneDelegate 文件中导入 FBSDKLoginKit。

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.升级到当前的 FBSDK 应该可以解决问题。

FBSDKCoreKit/FBSDKCoreKit/Internal/BridgeAPI/FBSDKBridgeAPI.m was modified to support iOS 13's requirement to implement ASWebAuthenticationPresentationContextProviding in FBSDKCoreKit 5.4.修改了 FBSDKCoreKit/FBSDKCoreKit/Internal/BridgeAPI/FBSDKBridgeAPI.m 以支持 iOS 13 在 FBSDKCoreKit 5.4 中实现 ASWebAuthenticationPresentationContextProviding 的要求。 The current version is 5.8.当前版本是 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所需的更改发布在这里: https://github.com/facebook/facebook-ios-sdk/commit/6b061099f339ef0e8bde2e2c2163ef5a3c1b8340#diff-72593591275d63edfb1bfad837e4c32

Just add the following code below 'didFinishLaunchingWithOptions' delegate method in AppDelegate.只需在 AppDelegate 中的“didFinishLaunchingWithOptions”委托方法下方添加以下代码。 It works with latest Facebook SDK and iOS 13 as well.它也适用于最新的 Facebook SDK 和 iOS 13。 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
        )
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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