How to change the text of message buttons of push

2019-07-23 06:04发布

问题:

I am using Apple Push Notifications and when I receive a new notification, a message with two buttons appears: the alert box says: "View" and "Cancel".

I want to convert it into a one button alert. Is it possible to remove one button and change the text of the remaining one?

回答1:

Yes - see "The Notification Payload" here; set alert to a dictionary and action-loc-key in that dictionary to null and you'll get a single button that dismisses the notification.



回答2:

Yes you can - you need to send the action-loc-key child property of the alert property with your APS payload.

See this Apple Developer Article for full examples