Nikolay Derkach
Nikolay Derkach

Reputation: 1754

iOS any way to modify push notification alert message once received?

My server yields push notifications with a payload including loc-key and loc-args, then when a message is received in the app it displays a notification based on the contents of Localizable.strings filling loc-key template with the content of loc-args.

I'd like to do some post processing for the content of the displayed notification, e.g. access user's address book locally and match a phone number to a contact name, and then display an updated alert while the app is running the background. Is there a way to do that?

Upvotes: 0

Views: 225

Answers (2)

Paulw11
Paulw11

Reputation: 115051

You can use a silent push notification (content-available = 1) which will be delivered to application(_:didReceiveRemoteNotification:fetchCompletionHandler:) and then use the information in the push notification to create and display a local notification.

The only drawback with this approach is that your application delegate method won't be called if the user has terminated your app (swipe up from app switcher).

Upvotes: 2

Constantin Saulenco
Constantin Saulenco

Reputation: 2383

If app is in foreground you can catch and process the notification, but if the app is in background or the app is not running you have no access to the notification data.

Upvotes: 0

Related Questions