Is it possible to change the notification with a push notification before being displayed on the device by iOS?

Display my push notification message - Message from: +919687335565

attached screenshot:

enter image description here

I just want to get the name of this +919687335565 contact number from the Address book and the display name of this contact instead of the phone number in push notification .

Before displaying notification I want to replace the phone number +919687335565 with my Chandresh contact name in the push notification.

as attached screenshot:

enter image description here

+6
source share
3 answers

There are various options for preprocessing and changing the notification payload on iOS.

Up to iOS 10

You can send silent notifications that will not be shown to the user. Our application will wake up when it is completed or in the background, and you can pre-process the contents of the notifications. Read more about how to configure it here. However, this type of notification is not 100% reliable and should not be abused, for example. used for all notifications that need to be delivered, as Apple may stop sending notifications after several messages.

Another option: if your application supports VoIP . This way, your application will pretty much always listen to push notifications, and you will always be ready to pre-process notifications before you show them. However, if your application does not have real VoIP capabilities, for example. Apple application will be rejected by Apple in the review. Here is a great tutorial on how to set it up.

From iOS 10

With the introduction of iOS 10, we are finally able to pre-process our notifications, even when the application is in the background or terminated. No need for VoIP settings or special types of notifications. Here is a great tutorial on how to set it up.

+1
source

No, It is Immpossible. Since the push notification is a server descriptor. This message only changes the server, not the application, because this time the application is in the background or terminated. But you can change the message when the application is in the foreground, and background selection - then you can customize your message and show it.

-one
source

This is possible with the exception of:

want to get the name of this +91 ********* contact number from your address book

because the Address Book not available when the application is in the background!
You must write a separate logic in the application itself in order to replace the mobile device with the corresponding name.

How is this possible:

Before iOS 10 and iOS 8 +:
Use PushKit to send silent push notifications, the application will be woken up by iOS, change the mobile phone number by name, show a local notification.

iOS 10+:
Use the Notification Service Extension to modify the contents of notifications before it is shown to the user.
See the official documentation

Using this extension of the service, iOS gives you the opportunity to first receive notifications directly in the application, change content, and then deliver to the user.
Here you can change the mobile number by name.

-one
source

Source: https://habr.com/ru/post/1013547/


All Articles