Reputation: 773
I'm trying to access the push notification payload before user actually gets the push notification. I want to create some sort of filter of the push notifications that the user receives. Is this possible?
Upvotes: 1
Views: 49
Reputation: 1683
You can get notification payload before it fired using this extension "NotificationService"
Add one target in the project and you can get notification data in bellow function.
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
}
One more thing you need to add is in notification payload add two-parameter like this
{
"aps":{
"alert": {
"title": "This it title",
"body": "This is body"
},
"mutable-content":1,
"content-available":1
},
"mediaType": "png",
"mediaUrl": "your url her"
}
"mutable-content":1,
"content-available":1
mutable content and content available = 1
if you do not add these two keys in payload then the above function should not call.
Thank you.
Upvotes: 3