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 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 update to an existing message with patch semantics. Non-null name, data, and extras fields in the provided message will replace the corresponding fields in the existing message, while null fields will be left unchanged.

    Declaration

    Objective-C

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

    Swift

    func update(_ message: ARTMessage, operation: ARTMessageOperation?, params: [String : ARTStringifiable]?, callback: ARTCallback? = 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 query string.

    callback

    A callback which, upon success, will contain a ARTMessage object containing the updated message. Upon failure, the callback will contain an ARTErrorInfo object which explains the error.

  • 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 patch semantics: non-null name, data, and extras fields in the provided message will replace the corresponding fields in the existing message, while null 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 ARTCallback)callback;

    Swift

    func delete(_ message: ARTMessage, operation: ARTMessageOperation?, params: [String : ARTStringifiable]?, callback: ARTCallback? = 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 query string.

    callback

    A callback which, upon success, will contain a ARTMessage object containing the deleted message. Upon failure, the callback will contain an ARTErrorInfo object which explains the error.

  • 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.