Skip to content

trackAppOpenedWithRemoteNotificationPayload not recording app push open for iOS7 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
StuartMorris0 opened this issue Aug 20, 2015 · 2 comments

Comments

@StuartMorris0
Copy link

Hello,

I have an issue where trackAppOpenedWithRemoteNotificationPayload is being called in iOS7 but no push open event is shown in Parse.com.

The issue is detailed here on SO: http://stackoverflow.com/questions/32103788/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];
    }

Thanks

@nlutsenko
Copy link
Contributor

Hey @StuartMorris0, can you please verify that the check for application.applicationState == UIApplicationStateInactive passes on iOS 7 and 8?
The code behind this (inside PFAnalytics) as you might have seen doesn't have specific logic handling between iOS 7 and 8, so what I think happens is that on iOS 7 - the app is backgrounded and reports UIApplicationStateBackground there, instead of UIApplicationStateInactive.
Try modifying the code snippet to use something like this and let me know if it works.

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

@nlutsenko nlutsenko self-assigned this Aug 20, 2015
@StuartMorris0
Copy link
Author

Hey @nlutsenko. I can confirm that when I run the application connected to XCode, close the application (send to background), then send a Parse Push.
The push is received and used to open the app on both iOS7 and iOS8 devices.

didReceiveRemoteNotification is then called for both, when stepping through the code on each device I can see that the method is being called. However for iOS7 it is not recorded in Parse, for iOS8 it is.

However, good news... I discovered the issue.

So... to test notification permissions it can be a pain on a real device. The steps to request the permission again once already done for an app is to Reset the device, Change the date to a date in the future, reset again, then reinstall the app and the permission will be requested again.

This was complete on both the devices iOS7/iOS8. It appears that the iOS7 device with a future date was not sending those Push opens. But the iOS8 one was. Maybe the iOS7 one was slightly ahead in terms of a date in the future (maybe too far).

However, setting the iOS7 date back to the correct date the push open is recorded as expected. Strange, but worth noting here. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants