Skip to content

Send Notification from a Push Template

[Backendless.shared.messaging
 pushWithTemplateWithTemplateName:@"DiscountPromotion"
 responseHandler:^(MessageStatus *messageStatus) {
    NSLog(@"Message status: %@", messageStatus);
}
 errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];


// with template values  
[Backendless.shared.messaging
 pushWithTemplateWithTemplateName:@"DiscountPromotion"
 templateValues:@{@"key1": @"value1"}
 responseHandler:^(MessageStatus *messageStatus) {
    NSLog(@"Message status: %@", messageStatus);
}
 errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.messaging.pushWithTemplate(
    templateName: "DiscountPromotion",
    responseHandler: { messageStatus in
        print("Message status: \(messageStatus)")
    },
    errorHandler: { fault in
        print("Error: \(fault.message ?? "")")
    })


// with template values
Backendless.shared.messaging.pushWithTemplate(
    templateName: "DiscountPromotion",
    templateValues: ["key1": "value1"],
    responseHandler: { messageStatus in
        print("Message status: \(messageStatus)")
    },
    errorHandler: { fault in
        print("Error: \(fault.message ?? "")")
    })

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