将应用程序转换为Swift 3后的UIApplication错误

时间:2016-09-27 21:16:40

标签: swift swift3

我将应用更新为最新语法后出现以下错误,我不明白为什么。有人可以帮忙吗?感谢。

 if application.applicationState != UIApplicationState.background {
        // Track an app open here if we launch with a push, unless
        // "content_available" was used to trigger a background push (introduced in iOS 7).
        // In that case, we skip tracking here to avoid double counting the app-open.

        let preBackgroundPush = !application.respondsToSelector(Selector("backgroundRefreshStatus"))
        let oldPushHandlerOnly = !self.respondsToSelector(#selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)))
        var pushPayload = false
        if let options = launchOptions {
            pushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil
        }
        if (preBackgroundPush || oldPushHandlerOnly || pushPayload) {
            PFAnalytics.trackAppOpened(launchOptions: launchOptions)
        }
    }
    if application.respondsToSelector(#selector(UIApplication.registerUserNotificationSettings(_:))) {
        let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()


    }

Errors

1 个答案:

答案 0 :(得分:-1)

对于成员'下标'的模棱两可的提及错误... 而不是:

pushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil

使用:

pushPayload = options[UIApplicationLaunchOptionsKey.remoteNotification] != nil