StuartM
StuartM

Reputation: 6823

Parse not sending push open notifications for iOS7

I have followed the guide for the relevant Push setup with Parse.

When testing the app on an iOS7 device and iOS8 device the same method is called when opening from a push:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    DebugLog(@"%s",__PRETTY_FUNCTION__);
    if (application.applicationState == UIApplicationStateInactive) {
        [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo];
    }
    if (completionHandler) {
        completionHandler(UIBackgroundFetchResultNoData);
    }
    [PFPush handlePush:userInfo];
}

It appears that although the [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; method is called on iOS7 the data is not shown in Parse.

For example, checking the Push that has been sent shows the amount of Opens. If I send a push to an iOS7 device and iOS8, the same part of code is being called. However, it is only recorded for the iOS8 version. Is there anything else I should be doing?

We have followed the relevant guide: https://parse.com/docs/ios/guide#push-notifications

This is also implemented:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    DebugLog(@"%s",__PRETTY_FUNCTION__);
    if (application.applicationState == UIApplicationStateInactive) {
        // 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];
    }
    [PFPush handlePush:userInfo];
}

Upvotes: 0

Views: 199

Answers (1)

StuartM
StuartM

Reputation: 6823

The issue was caused by some Notification Permission testing.

When testing notification permissions the prompt will only come up for the first time. To get the prompt to come up again you need to:
Remove the app and reset the device
Turn it on and change the date to a future date, reset again
Turn it on and re-install/build the app, the permission prompt will occur again.

We had been completing this for some testing on iOS7 and iOS8 devices. The issue seemed to be that on the iOS7 device although the push open notification was called it was not recorded, this seemed to be related to the date being in the future.

The date on the iOS8 device was also in the future, but possibly not as far ahead. When the date was set to the correct date on the device the push open notification on the iOS7 device was recorded again.

Upvotes: 0

Related Questions