FBSDKApplicationDelegate 应用程序 openURL:sourceApplication:annotation 已弃用

FBSDKApplicationDelegate application openURL:sourceApplication:annotation deprecated

iOS9 应用程序 openURL:sourceApplication:annotation 已弃用

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
    return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

所以现在我们应该使用;

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {}

FBSDKApplicationDelegate 为 sourceApplication 参数(字符串)设置什么

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool
{
    return FBAppCall.handleOpenURL(url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String)
}

如果您的 SDK 中有注释参数传递为 nil

新SDK

   let sourceApplication: String? = options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String 
   return FBSDKApplicationDelegate.sharedInstance().application(app, openURL: url, sourceApplication: sourceApplication, annotation: nil)

更新 2017/04/06:Xcode8.3,FBSDKCoreKit 4.20.2

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    let sourceApplication: String? = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String
    return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: sourceApplication, annotation: nil)
}

以下内容在 facebook 网站上使用至(2017 年 1 月 1 日)

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        let handled = FBSDKApplicationDelegate.sharedInstance().application(app, 
                      open: url, 
                      sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String?, 
                      annotation: options[UIApplicationOpenURLOptionsKey.annotation])

        return handled
}