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

时间:2015-11-16 14:10:07

标签: swift ios9 openurl

使用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参数(String)设置的内容

2 个答案:

答案 0 :(得分:35)

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 :Xcode 8.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)
}

答案 1 :(得分:5)

以下在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
}