gpt4 book ai didi

ios - 解析: Foreground Push Open Tracking

转载 作者:行者123 更新时间:2023-12-02 02:33:27 25 4
gpt4 key购买 nike

我正在为我的 ios 应用程序使用解析推送(使用 xcode)。我想跟踪应用程序和推送。后台状态和非事件状态正常工作,但前台故障。当我在前台接收推送时,推送打开统计数据保持为 0。这就是我到目前为止所拥有的..

我希望有人能帮助我:-)

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
if(application.applicationState == UIApplicationStateInactive) {

NSLog(@"Inactive");
[PFPush handlePush:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];

} else if (application.applicationState == UIApplicationStateBackground) {

NSLog(@"Background");
[PFPush handlePush:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];

} else {

NSLog(@"Active");
[PFPush handlePush:userInfo];
completionHandler(UIBackgroundFetchResultNewData);
[PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];

}
}

最佳答案

I want to track the app and push-openings. The background state and inactive state are working, but foreground fails

Parse 实际上并不跟踪应用程序位于前台时收到的推送通知。我想原因是推送通知的目的是让用户将应用程序从后台带到前台。如果应用程序已位于前台,则推送通知对于该用户来说是多余的,因此对于您的分析来说也是多余的。

但是,如果您仍然有兴趣跟踪应用程序位于前台时接收推送通知的用户,您可以执行以下两项操作:

A) 实现应用委托(delegate)的 application:didReceiveRemoteNotification: 函数,如下所示:

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
PFPush.handlePush(userInfo)
}

将此与 Parse's recommended implementation 进行比较,仅当 application.applicationState == .Inactive

时才调用 trackAppOpenedWithRemoteNotificationPayload

因此,这意味着 Parse 的推送分析会将所有收到的推送计为“推送打开”。

B) 当应用程序位于前台时,将收到的推送通知作为单独的分析事件进行跟踪:

    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

if application.applicationState == .Inactive {
// The application was just brought from the background to the foreground,
// so we consider the app as having been "opened by a push notification."
PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
}
else if application.applicationState == .Active {
PFAnalytics.trackEvent("Received Push while app was in the foreground")
}

PFPush.handlePush(userInfo)
}

关于ios - 解析: Foreground Push Open Tracking,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28166384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com