解析:前台推送开启跟踪
Parse: Foreground Push Open Tracking
我正在为我的 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) 像这样实现您的应用委托的 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 的推送分析将计算 所有 收到的推送作为 "Push Opens"。
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 应用程序使用解析推送(使用 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) 像这样实现您的应用委托的 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 的推送分析将计算 所有 收到的推送作为 "Push Opens"。
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)
}