PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions,block:nil)出错

时间:2015-04-14 23:30:27

标签: swift parse-platform ios8

我试图将Parse导入到我的Swift应用程序中,每次添加// Register for Push Notifications时都会收到错误消息“PFAnalytics.Type'没有名为' trackAppOpenedWithLaunchOptions'的成员我从Parse网站上复制并粘贴了一些代码并且不知道如何修复它

// Register for Push Notitications
    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("backgroundRefreshStatus")
        let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
        var noPushPayload = false;
        if let options = launchOptions {
            noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil;
        }
        if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
            PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions, block: nil)
        }
    }
    if application.respondsToSelector("registerUserNotificationSettings:") {
        let userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
        let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
    } else {
        let types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound
        application.registerForRemoteNotificationTypes(types)
    }

1 个答案:

答案 0 :(得分:0)

由于您将nil传递给该块,请替换此行:

PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions, block: nil)

这一个:

PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)

如果您需要在后台执行此操作,请使用以下行:

PFAnalytics.trackAppOpenedWithLaunchOptionsInBackground(launchOptions, block: nil)