Open svzi opened 7 years ago
@svzi Sven, thanks for the suggestion.
There is a similar functionality already implemented in the plugin.
Utilizing the data.notId
key in the payload will allow for setting this with server control. For example - sending the same notId
with the payload will update the existing notification in the tray with the same notId.
According to your words, this is the functionality you are looking after. Let me know if this is the case.
@AntonDobrev Anton, thanks for the answer.
I just tried it and sent some pushes with same data.notId
, but they all show up in the notification tray of my device. So I guess I'm doing something wrong. Could you please offer any additional documentation or some code sample?
Best, Sven
@svzi Sven, here is an example:
Sending the following payload (using the same notId
for the pushes you want to replace). For example, these title and message will replace the notification currently in the tray and with the same notId
value.
Let me know if this works for you.
{
"data":{
"title":"some title 4",
"message":"some message 4",
"notId":123
}
}
@AntonDobrev Anton, thanks for the example, but sadly that doesn't work. 😞 The notId
doesn't change anything.
I've also tried to add it to the notification
property instead of data
, but that doesn't help either.
This is my complete test push:
{
to: device_token, // required fill with device token
collapse_key: 'test_key',
data: {
notId: 1,
your_custom_data_key: 'your_custom_data_value2'
},
notification: {
title: 'Test',
body: 'test body data.',
icon: 'notification',
}
}
For testing purposes I just modify notification.title
and notification.body
and push again. The old notification in my tray doesn't get replaced, instead the new push message will be added as well.
Any update?
I haven't tried it myself but, isn't there a "collapse_key" option you set in the payload for this?
I DO use Telerik Backend Service but right now I am not using this option.
It applies when the device is off though, don't know.
Thanks @Daxito, but you're right. It only applies when the device is offline and the message has not been sent to the device. As you may notice I already use that key (https://github.com/NativeScript/push-plugin/issues/93#issuecomment-279957444).
@AntonDobrev Any update on this issue? This is really important to our app!
Hi there!
I’m looking for a way to aggregate my Android Notifications using this push-plugin, because I want to avoid showing 10 times the same message to the user in the notifications bar…
It should be possible to update existing notifications: https://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating
I've already talked with @Pip3r4o about that on Slack, here is what he answered to my initial request:
Any way you can add that new feature? I guess it could become handy to a lot of projects. 👍
Best, Sven