Skip to content

Example: Basic Push

NSString *message = @"Hello!";

PublishOptions *publishOptions = [PublishOptions new];
[publishOptions setHeadersWithHeaders:@{@"ios-alert": @"Alert message", @"ios-badge": @1, @"ios-sound": @"default"}];

[Backendless.shared.messaging publishWithChannelName:@"default" message:message publishOptions:publishOptions responseHandler:^(MessageStatus *messageStatus) {
    NSLog(@"Message status: %@", messageStatus);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
let message = "Hello!"

let publishOptions = PublishOptions()
publishOptions.setHeaders(headers: ["ios-alert": "Alert message", "ios-badge": 1, "ios-sound": "default"])

Backendless.shared.messaging.publish(channelName: "default", message: message, publishOptions: publishOptions, responseHandler: { messageStatus in
    print("Message status: \(messageStatus)")
}, errorHandler: { fault in
    print("Error: \(fault.message)")
})