Skip to content

Delayed Delivery

Publishers can specify the time when the message should be processed and delivered to subscribers. This can be done in addition to all other publishing options (basic publish, with headers. Scheduled messages can be canceled at any time using the message cancellation API.

NSString *message = @"Hello World!";

DeliveryOptions *deliveryOptions = [DeliveryOptions new];
deliveryOptions.publishAt = [NSDate dateWithTimeIntervalSinceNow:2];

[Backendless.shared.messaging publishWithChannelName:@"default" message:message deliveryOptions:deliveryOptions responseHandler:^(MessageStatus *messageStatus) {
    NSLog(@"Message (id = %@) has been published with status: %@", messageStatus.messageId, messageStatus.status);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
let message = "Hello World!"

let deliveryOptions = DeliveryOptions()
deliveryOptions.publishAt = Date(timeIntervalSinceNow: 2)

Backendless.shared.messaging.publish(channelName: "default", message: message, deliveryOptions: deliveryOptions, responseHandler: { messageStatus in
    print("Message (id = \(messageStatus.messageId ?? "") has been published with status: \(messageStatus.status ?? "")")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})