Skip to content

Send Notification from a Push Template

Future<MessageStatus> Backendless.messaging.pushWithTemplate(String templateName);

Backendless Console includes a code generator which creates the client-side code for publishing a push notification for a template. To access the code generator, login to Backendless Console, select your app and click the Messaging icon. Select the PUSH NOTIFICATION tab and click the Push Templates menu. There is the "show code" icon for each created template as shown below. When you click the icon, a popup is displayed with the generated code:

generate-code-push-template.zoom70

The displayed popup lets you select the client-side language and copy the generated code:
push-template-generated-code

Codeless Reference

push_with_template_1

where:

Argument                Description
with template Name of the push template from which push notification will be created by the server.
template values Name of a custom smart text variable used in the template.
return result If selected, the operation returns an object containing message details. See the object description below.

Returns an object containing published message details:

where:

Argument                Description
messageId ID of the published message.
status Can be one of the following values: FAILED, PUBLISHED, SCHEDULED, CANCELLED, UNKNOWN
errorMessage Contains a detailed error message when status is "failed".
sendingTimeInMillis Time required to process the message.
successfulSendsAmount The number of successfully sent messages.
failedSendsAmount The number of undelivered messages.

The example below sends the message using the "welcome_message" template. The template values property below contains an object with the name and age properties whose values will replace the smart text placeholders in the template.

push_with_template_2

After the Codeless logic runs, the operation returns the following object containing unique message ID, status details, and other information.

push_with_template_3