简体   繁体   中英

Error in PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions, block: nil)

Im trying to Import Parse into my Swift application and everytime I add the //Register for Push Notifications I get a error saying 'PFAnalytics.Type' does not have a member named 'trackAppOpenedWithLaunchOptions' and I literally copied and pasted the bit of code from the Parse website and dont know how to fix it

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

Since you are passing nil to the block, please replace this line:

PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions, block: nil)

with this one:

PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)

If you need to do it in the background, please use this line:

PFAnalytics.trackAppOpenedWithLaunchOptionsInBackground(launchOptions, block: nil)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM