Skip to content

Example: Target All Devices for an OS

NSString *message = @"Hello!";

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

DeliveryOptions *deliveryOptions = [DeliveryOptions new];
deliveryOptions.pushBroadcast = PushBroadcastEnumFOR_IOS | PushBroadcastEnumFOR_ANDROID;

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

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

let deliveryOptions = DeliveryOptions()
deliveryOptions.pushBroadcast = PushBroadcastEnum.FOR_IOS.rawValue | PushBroadcastEnum.FOR_ANDROID.rawValue

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

Codeless Reference

The example below publishes the message to the "default" channel. This message is delivered only to Android devices, since no values were set for iOS properties.


For a detailed description of the Codeless block, refer to the Push With API topic of this guide.