FBSDKApplicationDelegate application openURL:sourceApplication:annotation deprecated

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 11:47:42

问题


with iOS9 application openURL:sourceApplication:annotation is deprecated

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

so now we should use;

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

FBSDKApplicationDelegate what to set for sourceApplication parameter (String)


回答1:


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

if you have annotation param in your SDK pass as nil

New SDK

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

Update 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)
}



回答2:


The following used on facebook site till (Jan 1, 2017)

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
}


来源:https://stackoverflow.com/questions/33737403/fbsdkapplicationdelegate-application-openurlsourceapplicationannotation-deprec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!