Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing action titles in interactive notifications at run time

As per my understanding I have to register categories and actions therein for local or remote interactive notifications, now my requirement is that I want to show buttons with dynamic titles coming as part of the push payload.

As an alternative I have also tried the option of firing a local notification with settings registered when a remote notification is received, but somehow it is not working and the local notification is not fired. Help highly appreciated.

like image 645
Santosh Kumar Dwivedi Avatar asked May 07 '15 14:05

Santosh Kumar Dwivedi


People also ask

What are actionable push notifications?

Actionable notifications are a unique type of notification as they allow the user to add buttons to the notification which can then send an event to Home Assistant once clicked.

How do I customize notifications in Swift?

It's the same process as setting up for Notification Service Extension. Go to xcode select File > New > Target > Notification Content Extension > Next > Product Name( name it as CustomUI) > Finish > Active scheme popUp(if comes then select cancel). Every Custom UI must have its unique category Identifier.

What are rich push notifications?

Rich push notifications are short pop-up messages sent to a user's device with a rich media attachment such as an animated GIF, video, or audio. They allow you to communicate with your customers in an inviting way even when they're not actively using your app or visiting your website.


1 Answers

The short answer is that you can't change the action button title at runtime.

BUT, you can try the following:

  1. Before sending a notification to the device, send it a "silent" notification, using the content-available property. In this notification, send a data which represent your new action button titles.

  2. Update your relevant category using registerUserNotificationSettings:.

  3. Send the "real" notification with the new action titles, you've just created.

It need to be tested, as I never tried it in a production mode. Also, take into consideration, that you're going to double up your notification sent amount.

like image 125
Asaf Avatar answered Oct 03 '22 16:10

Asaf