应用程序的实现:openURL:sourceApplication:annotation

时间:2016-10-12 15:12:53

标签: ios swift facebook xcode8 appdelegate

我在Xcode8发布之前开始处理应用程序,然后切换,当我尝试使用Facebook登录登录应用程序时出现以下错误

  

应用程序的实现:openURL:sourceApplication:annotation:not found。请将处理程序添加到App Delegate中。类:GhostGab.AppDelegate

我检查了所有设置,看起来很好。任何帮助将不胜感激

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FIRApp.configure()
    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    return true
}

  func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {

    let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
        application,
        open: url,
        sourceApplication: sourceApplication,
        annotation: annotation)
    // Add any custom logic here.
    return facebookDidHandle
}

1 个答案:

答案 0 :(得分:5)

您的功能定义:

func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
}

应替换为:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
}

第一个参数有一个下划线,而Any代表最后一个参数类型的AnyObject

这就是你收到错误的原因:

  

应用程序的实现:openURL:sourceApplication:annotation