ARTChannelProtocol

Objective-C

@protocol ARTChannelProtocol

Swift

protocol ARTChannelProtocol

The protocol upon which ARTRestChannelProtocol and ARTRealtimeChannelProtocol are based.

  • The channel name.

    Declaration

    Objective-C

    @property (readonly) NSString *_Nonnull name;

    Swift

    var name: String { get }
  • Publishes a single message to the channel with the given event name and payload. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name data:(nullable id)data;

    Swift

    func publish(_ name: String?, data: Any?)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

  • Publishes a single message to the channel with the given event name and payload. A callback may optionally be passed in to this call to be notified of success or failure of the operation. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
           callback:(nullable ARTCallback)callback;

    Swift

    func publish(_ name: String?, data: Any?, callback: ARTCallback? = nil)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    callback

    A success or failure callback function.

  • Publishes a single message to the channel with the given event name and payload. A callback may optionally be passed in to this call to be notified of success or failure of the operation. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
                  data:(nullable id)data
        resultCallback:(nullable ARTPublishResultCallback)resultCallback;

    Swift

    func publish(_ name: String?, data: Any?, resultCallback: ARTPublishResultCallback? = nil)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    resultCallback

    A success or failure callback function. On success, receives an ARTPublishResult containing the serial of the published message.

  • Publishes a single message to the channel with the given event name, payload, and clientId. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
           clientId:(nonnull NSString *)clientId;

    Swift

    func publish(_ name: String?, data: Any?, clientId: String)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    clientId

    The ARTMessage/clientId of the message.

  • Publishes a single message to the channel with the given event name, payload, and clientId. A callback may optionally be passed in to this call to be notified of success or failure of the operation. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
           clientId:(nonnull NSString *)clientId
           callback:(nullable ARTCallback)callback;

    Swift

    func publish(_ name: String?, data: Any?, clientId: String, callback: ARTCallback? = nil)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    clientId

    The ARTMessage/clientId of the message.

    callback

    A success or failure callback function.

  • Publishes a single message to the channel with the given event name, payload, and extras. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
             extras:(nullable id<ARTJsonCompatible>)extras;

    Swift

    func publish(_ name: String?, data: Any?, extras: (any ARTJsonCompatible)?)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    extras

    The ARTMessage/extras of the message.

  • Publishes a single message to the channel with the given event name, payload, and extras. A callback may optionally be passed in to this call to be notified of success or failure of the operation. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
             extras:(nullable id<ARTJsonCompatible>)extras
           callback:(nullable ARTCallback)callback;

    Swift

    func publish(_ name: String?, data: Any?, extras: (any ARTJsonCompatible)?, callback: ARTCallback? = nil)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    extras

    The ARTMessage/extras of the message.

    callback

    A success or failure callback function.

  • Publishes a single message to the channel with the given event name, payload, clientId, and extras. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
           clientId:(nonnull NSString *)clientId
             extras:(nullable id<ARTJsonCompatible>)extras;

    Swift

    func publish(_ name: String?, data: Any?, clientId: String, extras: (any ARTJsonCompatible)?)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    clientId

    The ARTMessage/clientId of the message.

    extras

    The ARTMessage/extras of the message.

  • Publishes a single message to the channel with the given event name, payload, clientId, and extras. A callback may optionally be passed in to this call to be notified of success or failure of the operation. When publish is called with this client library, it won’t attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Declaration

    Objective-C

    - (void)publish:(nullable NSString *)name
               data:(nullable id)data
           clientId:(nonnull NSString *)clientId
             extras:(nullable id<ARTJsonCompatible>)extras
           callback:(nullable ARTCallback)callback;

    Swift

    func publish(_ name: String?, data: Any?, clientId: String, extras: (any ARTJsonCompatible)?, callback: ARTCallback? = nil)

    Parameters

    name

    The name of the message.

    data

    The payload of the message.

    clientId

    The ARTMessage/clientId of the message.

    extras

    The ARTMessage/extras of the message.

    callback

    A success or failure callback function.

  • Publishes an array of messages to the channel.

    Declaration

    Objective-C

    - (void)publish:(nonnull NSArray<ARTMessage *> *)messages;

    Swift

    func publish(_ messages: [ARTMessage])

    Parameters

    messages

    An array of ARTMessage objects.

  • Publishes an array of messages to the channel. A callback may optionally be passed in to this call to be notified of success or failure of the operation.

    Declaration

    Objective-C

    - (void)publish:(nonnull NSArray<ARTMessage *> *)messages
           callback:(nullable ARTCallback)callback;

    Swift

    func publish(_ messages: [ARTMessage], callback: ARTCallback? = nil)

    Parameters

    messages

    An array of ARTMessage objects.

    callback

    A success or failure callback function.

  • Publishes an array of messages to the channel. A callback may optionally be passed in to this call to be notified of success or failure of the operation.

    Declaration

    Objective-C

    - (void)publish:(nonnull NSArray<ARTMessage *> *)messages
        resultCallback:(nullable ARTPublishResultCallback)resultCallback;

    Swift

    func publish(_ messages: [ARTMessage], resultCallback: ARTPublishResultCallback? = nil)

    Parameters

    messages

    An array of ARTMessage objects.

    resultCallback

    A success or failure callback function. On success, receives an ARTPublishResult containing the serials of the published messages.

  • Publishes an update to existing message with shallow mixin semantics. Non-nil name, data, and extras properties in the provided message will replace the corresponding fields in the existing message, while nil properties will be left unchanged. Note that this publishes an update, it does not mutate the original message if passed in.

    Declaration

    Objective-C

    - (void)updateMessage:(nonnull ARTMessage *)message
                operation:(nullable ARTMessageOperation *)operation
                   params:(nullable NSDictionary<NSString *, ARTStringifiable *> *)
                              params
                 callback:(nullable ARTEditResultCallback)callback;

    Swift

    func update(_ message: ARTMessage, operation: ARTMessageOperation?, params: [String : ARTStringifiable]?, callback: ARTEditResultCallback? = nil)

    Parameters

    message

    An ARTMessage object containing a populated serial field and the fields to update.

    operation

    An optional ARTMessageOperation object containing metadata about the update operation.

    params

    Optional parameters sent as part of the request. As Ably adds supported parameters, they will be documented on the docs pages.

    callback

    A success or failure callback function. On success, it receives an ARTUpdateDeleteResult object containing the new version of the message.

  • Marks a message as deleted by publishing an update with an action of ARTMessageActionDelete. This does not remove the message from the server, and the full message history remains accessible. Uses shallow mixin semantics: non-nil name, data, and extras properties in the provided message will replace the corresponding properties in the existing message, while nil fields will be left unchanged (meaning that if you for example want the ARTMessageActionDelete to have an empty data, you should explicitly set the data to an empty object).

    Declaration

    Objective-C

    - (void)deleteMessage:(nonnull ARTMessage *)message
                operation:(nullable ARTMessageOperation *)operation
                   params:(nullable NSDictionary<NSString *, ARTStringifiable *> *)
                              params
                 callback:(nullable ARTEditResultCallback)callback;

    Swift

    func delete(_ message: ARTMessage, operation: ARTMessageOperation?, params: [String : ARTStringifiable]?, callback: ARTEditResultCallback? = nil)

    Parameters

    message

    An ARTMessage object containing a populated serial field.

    operation

    An optional ARTMessageOperation object containing metadata about the delete operation.

    params

    Optional parameters sent as part of the request. As Ably adds supported parameters, they will be documented on the docs pages.

    callback

    A success or failure callback function. On success, it receives an ARTUpdateDeleteResult object containing the new version of the message.

  • Appends data to an existing message. The supplied data property is appended to the previous message’s data, while all other properties (name, extras) replace the previous values if provided.

    Declaration

    Objective-C

    - (void)appendMessage:(nonnull ARTMessage *)message
                operation:(nullable ARTMessageOperation *)operation
                   params:(nullable NSDictionary<NSString *, ARTStringifiable *> *)
                              params
                 callback:(nullable ARTEditResultCallback)callback;

    Swift

    func append(_ message: ARTMessage, operation: ARTMessageOperation?, params: [String : ARTStringifiable]?, callback: ARTEditResultCallback? = nil)

    Parameters

    message

    An ARTMessage object containing a populated serial field and the data to append.

    operation

    An optional ARTMessageOperation object containing metadata about the append operation.

    params

    Optional parameters sent as part of the request. As Ably adds supported parameters, they will be documented on the docs pages.

    callback

    A success or failure callback function. On success, it receives an ARTUpdateDeleteResult object containing the new version of the message.

  • Retrieves the latest version of a specific message by its serial identifier.

    Declaration

    Objective-C

    - (void)getMessageWithSerial:(nonnull NSString *)serial
                        callback:(nonnull ARTMessageErrorCallback)callback;

    Swift

    func getMessageWithSerial(_ serial: String, callback: @escaping ARTMessageErrorCallback)

    Parameters

    serial

    A serial identifier string of the message to retrieve.

    callback

    A callback which, upon success, will contain a ARTMessage object representing the latest version of the message. Upon failure, the callback will contain an ARTErrorInfo object which explains the error.

  • Retrieves all historical versions of a specific message, ordered by version. This includes the original message and all subsequent updates or delete operations.

    Declaration

    Objective-C

    - (void)getMessageVersionsWithSerial:(nonnull NSString *)serial
                                callback:
                                    (nonnull ARTPaginatedMessagesCallback)callback;

    Swift

    func getMessageVersions(withSerial serial: String, callback: @escaping ARTPaginatedMessagesCallback)

    Parameters

    serial

    A serial identifier string of the message whose versions are to be retrieved.

    callback

    A callback which, upon success, will contain an ARTPaginatedResult object containing an array of ARTMessage objects representing all versions of the message. Upon failure, the callback will contain an ARTErrorInfo object which explains the error.