I have defined a Push Template with some smart text in the message body and a Button Options. I want to deliver notifications just to a selected devices using this template, and I want to put a custom header on it to be retrieved later in the activity associated to the button (the value of the header will be an objectId of a register in a custom table).
How can I deliver notifications using this template via API?
I have seen there are to methods signature for Backendless.Messaging.pushWithTemplate. One of them receives a Map as second argument.
Where do I put the query for the selected devices?
Where do I put the value of the custom header?
second argument is for template values (substitutions for smart text).
So you can define a smart text in your custom header (e.g. headerObjectId) and then send template with second argument as {"headerObjectId": "your-object-id-value-here"}
In order to select the devices to which notifications will be sent, follow the instructions described in the documentation - Notification Audience (WHO)
It is not possible to establish recipients in other ways, including in the request.
Thank you - however for the moment it’s not possible to use a template and via the API to set the Segment of the template which is what I think @Nono_Carballo wanted to do too.
Yes, you are right, at the moment it is impossible to use a template and install a template segment through the API, only through the console, as I wrote above.
Nor the channel can be sent in the second parameter?
I’m thinking in registering a device on more than one channel (column channelName in Users table seems to accept multiple values), if I could then send a push notification using the template and indicate the target channel, that will be fine.
Push templates contain settings to whom to send notifications. When calling via API, you can specify only the name of the template and templateValues, which contains the values for replacing the sartText. In this case, you cannot override the recipient list in any way.
In order to send notifications through the API and specify a list of recipients, you can use one of the following calls:
Hey @Nono_Carballo from what I understand you’d need to create your own Templates from scratch and then apply those parameter, channel and segmentation but dev will confirm no doubt.
When sending push notifications via API, except when sent using templates, for example Basic Push, you specify PublishOptions.
new Backendless.PublishOptions ({
headers: {
"android-ticker-text": "Your just got a push notification",
"android-content-title": "This is a notification title",
"android-content-text": "Push notifications are cool"
}
android-ticker-text - is android ticker text android-content-title - is android content title android-content-text - android content text
Perhaps I was mistaken when I said about duplicating template settings with PublishOptions, only a few settings are repeated there. Possible values for PublishOptions can be found here - Push Notification Headers
For now, I can offer you the following work-round: create several templates with different Segment and do Send Notification from a Push Template with the segment you need.
I will also consult with my colleagues, perhaps there is some other option. I will let you know about the result in this topic.
That will be a solution for me only if I could create Push Templates via API. I’m thinking on creating Push Templates via API (will all it’s settings) and specify a different channel on each one, then subscribe users to those channels, when I send push notification using the template just those users will receive the notification, that’s is what I want.