Skip to content
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

iOS - Identifying the trigger of iOS Remote notifications callback #56

Open
eladmoshe opened this issue Aug 12, 2015 · 0 comments
Open

Comments

@eladmoshe
Copy link

Hi,

This is a question rather than an issue.
TL;DR - In application:didReceiveRemoteNotification I want to identify when the callback was triggered by user tapping the notification vs. the callback being called by the OS upon arrival of a notification.

Suppose you implement email client application. When a new mail is received, a notification should be displayed, and the app should pull the new mail ASAP. When the user taps the notification in the notification center, the app should display the new mail. However, if he opens the application directly (not through the notification) he should see the list of mails already updated with the latest data.

Ideally, the app would have a callback called upon arrival of a notification with {content-available:1} for updating the data, and another callback when the user clicks the notification.

However, if the app implements application:didReceiveRemoteNotification:fetchCompletionHandler: the same callback might be called twice - once immediately when the notification arrives, and again if the user clicks the notification in the notification center.

So, when the callback is triggered, how should the app know if it should navigate to the new mail (when the user taps the notification) or fetch the data (called by the system)?

I tried querying the applicationState. This doesn't help as when the user opens the control center and a notification is received (but not tapped), the application is in inactive state, same as it is when the user taps the notification.

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

1 participant