Yao Fan
Yao Fan

Reputation: 124

How to get all the push notification payloads after an iOS app launches or did become active

I have an app to work on. And I need to know if there is already some push notifications before the app is opened. Is there a way to solving the issue?

Thanks

Upvotes: 1

Views: 217

Answers (2)

EricS
EricS

Reputation: 9768

You can't push a notification to a device when your application hasn't been opened at least once - the user has to authorize push notifications and you need get the push token value - returned after calling registerForRemoteNotifications - and send it to your server.

There's no guarantee that your app will see multiple push notifications if they all arrived when the application wasn't running. Often you'll just see the most recent notification. You should store all of the notifications on your server and have your application request them when it becomes active if there's at least one notification waiting for you.

Upvotes: 1

Sean
Sean

Reputation: 1088

Once you've registered for notifications you need to setup didReceiveRemoteNotification method in your AppDelegate. There you can handle any information received from a Push Notification. Here's a link to there relevant documentation.

Upvotes: 0

Related Questions