Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to modify incoming Push Notification Text on iOS

I have a usecase where a notification provider ends up sending me push notification text in a format that I'd like to change. Can I do so in the app's ObjectiveC/Swift code?

like image 301
sparkFinder Avatar asked Mar 23 '16 22:03

sparkFinder


People also ask

Can you personalize push notifications?

To add an extra layer of personalization to an iOS or Android push campaign message, you can use geo-location based push notifications. There are two ways brands can send push notifications based on a user's location: Location-based notifications: App users receive these pushes based on data collected on the backend.

How do I change push notifications on iOS?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered—immediately or in the scheduled notification summary.

Can you customize iPhone notifications?

Most notification settings can be customized for each app. You can turn app notifications on or off, have notifications play a sound, choose how and where you want app notifications to appear when your device is unlocked, and more. Go to Settings > Notifications.


2 Answers

Since iOS 10, it is possible to modify the text of push notifications (unless they are silent notifications) by creating a UNNotificationServiceExtension for your application.

The extension is created as a separate Target in Xcode and provides a NotificationService class with two functions, one that allows you to modify the content of the push notification (didReceive withContentHandler) and one that notifies your application if didReceive withContentHandler did not complete in time (serviceExtensionTimeWillExpire).

For this to work, the push notification that is sent to your application also needs to be modified to include the key/value pair mutable-content with a value of 1 so that iOS knows to invoke the UNNotificationServiceExtension for your application.

Apple's UNNotificationServiceExtension Documentation

like image 104
Brandon Haugen Avatar answered Oct 13 '22 00:10

Brandon Haugen


Your iOS app does not get a chance to modify the incoming push notification data before it is displayed to the user.

like image 34
Mathew Spolin Avatar answered Oct 13 '22 01:10

Mathew Spolin