Manthan
Manthan

Reputation: 3914

Modify Notification data before displaying to user in iOS

I have an app in which I am using an FCM notification when there is an event from server.

I want to get the notification data and update the message from one of the parameter from Notification Payload when app is in background, foreground or killed.

I have tried to use Silent Push Notification with Content Available but when my app is killed, then I am unable to receive callback in my App delegate.

I have tried lots of links from Stack Overflow but could not get the perfect suggestion.

I am interested in solutions with different iOS (12,13,14,15) versions.

My problem is just like this Stack Overflow question.

Upvotes: 2

Views: 1235

Answers (1)

Dan Morrow
Dan Morrow

Reputation: 4481

It sounds like what you want is a Notification Service Extension. This is a separate binary (packaged with your app) that can run when a notification is received. Your extension can intercept the push-notification payload, and modify it, so that other things can be displayed.

https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension

This is also really good, too. https://www.raywenderlich.com/8277640-push-notifications-tutorial-for-ios-rich-push-notifications

Upvotes: 2

Related Questions