Reputation:
I was wondering if it is possible for the app on the client to be able to read the data in the payload when an APNS notification is sent?
For example, if the APNS notification said "Hello world!", and the user clicked 'View' to go to the app, would there be a way for the app to see that the APNS notification said "Hello world!".
Thanks.
Upvotes: 1
Views: 1423
Reputation: 13433
APNS notifications are tied to a specific token which is associated with a specific app on a single phone. When the notification arrives, iPhone OS shows the user the alert, plays the sound (if specified), and sets the application badge (if any).
If the app is running and the screen isn't asleep the app is run and the payload JSON packet is handed over. If the app is running and the screen is dark, the user is shown the alert with a single button to unlock the screen then the app is handed the payload. If the app is NOT running the user is given a View/Cancel choice. If they tap View, the app is run and the payload JSON is handed over.
As you can see, in all these cases the JSON packet containing the notification alert, sound, badge, and any other extra bits you send is handed over to the application. The docs show you how to retrieve the JSON packet. It's up to you what to do with it.
If you're thinking of an app seeing the payload headed for another app, then the answer is no. Notifications are tied to specific apps signatures.
Upvotes: 4