簡體   English   中英

PFAnalytics.trackAppOpenedWithLaunchOptions中的錯誤(launchOptions,塊:無)

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

我試圖將Parse導入到我的Swift應用程序中,並且每次我添加// Register for Push Notifications時,我都會收到一條錯誤消息,提示“ PFAnalytics.Type”沒有名為“ trackAppOpenedWithLaunchOptions”的成員,我從字面上復制並粘貼了部分代碼解析網站,不知道如何解決

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

由於您將nil傳遞給該塊,因此請替換以下行:

PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions, block: nil)

與此:

PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)

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

PFAnalytics.trackAppOpenedWithLaunchOptionsInBackground(launchOptions, block: nil)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM