Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

swift - It's possible to change push notification message before display on device from iOS side?

Display my push notification message is "Message from: +919687335565"

attached screenshot :

enter image description here

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

Before displaying notification i want to replace phone number +919687335565 with its contact name Chandresh in push notification.

like attached screenshot :

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are various possibilities for preprocessing and modify the payload of a notification on iOS.

Before iOS 10

You could be sending Silent Notifications, what will not be not shown to the user. Will wake our application when it is terminated or in background, and you will be able to do preprocessing on the notification content. See more info here, how to set it up. However, this notification type is not 100% reliable, and should not be abused, e.g. used for all notifications to be delivered, because Apple could stop the notifications to be sent after a number of messages.

The other option is, if your application supports VoIP. This way your app will pretty much always listen to push notifications, and you will be always available to preprocess the notifications, before you would be displaying them. However, if your app does not have real VoIP capabilities, e.g. phone calls, your app will be rejected by Apple on the review. Here is a great tutorial, how to set it up.

From iOS 10

With the introduction of iOS 10, we are finally able to do preprocessing on our notifications, even, when the app is in background or terminated. No VoIP capabilities or special type of notifications needed to be sent. Here is a great tutorial, how to set it up.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...