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
nameThe name of the message.
dataThe 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
nameThe name of the message.
dataThe payload of the message.
callbackA 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
nameThe name of the message.
dataThe payload of the message.
resultCallbackA success or failure callback function. On success, receives an
ARTPublishResultcontaining 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
nameThe name of the message.
dataThe payload of the message.
clientIdThe
ARTMessage/clientIdof 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
nameThe name of the message.
dataThe payload of the message.
clientIdThe
ARTMessage/clientIdof the message.callbackA 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
nameThe name of the message.
dataThe payload of the message.
extrasThe
ARTMessage/extrasof 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
nameThe name of the message.
dataThe payload of the message.
extrasThe
ARTMessage/extrasof the message.callbackA success or failure callback function.
-
Publishes a single message to the channel with the given event name, payload,
clientId, andextras. 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
nameThe name of the message.
dataThe payload of the message.
clientIdThe
ARTMessage/clientIdof the message.extrasThe
ARTMessage/extrasof the message. -
Publishes a single message to the channel with the given event name, payload,
clientId, andextras. 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
nameThe name of the message.
dataThe payload of the message.
clientIdThe
ARTMessage/clientIdof the message.extrasThe
ARTMessage/extrasof the message.callbackA 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
messagesAn array of
ARTMessageobjects. -
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
messagesAn array of
ARTMessageobjects.callbackA 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
messagesAn array of
ARTMessageobjects.resultCallbackA success or failure callback function. On success, receives an
ARTPublishResultcontaining the serials of the published messages. -
Publishes an update to existing message with shallow mixin semantics. Non-
nilname,data, andextrasproperties in the provided message will replace the corresponding fields in the existing message, whilenilproperties 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
messageAn
ARTMessageobject containing a populatedserialfield and the fields to update.operationAn optional
ARTMessageOperationobject containing metadata about the update operation.paramsOptional parameters sent as part of the request. As Ably adds supported parameters, they will be documented on the docs pages.
callbackA success or failure callback function. On success, it receives an
ARTUpdateDeleteResultobject 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-nilname,data, andextrasproperties in the provided message will replace the corresponding properties in the existing message, whilenilfields will be left unchanged (meaning that if you for example want theARTMessageActionDeleteto have an empty data, you should explicitly set thedatato 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
messageAn
ARTMessageobject containing a populatedserialfield.operationAn optional
ARTMessageOperationobject containing metadata about the delete operation.paramsOptional parameters sent as part of the request. As Ably adds supported parameters, they will be documented on the docs pages.
callbackA success or failure callback function. On success, it receives an
ARTUpdateDeleteResultobject containing the new version of the message. -
Appends data to an existing message. The supplied
dataproperty 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
messageAn
ARTMessageobject containing a populatedserialfield and the data to append.operationAn optional
ARTMessageOperationobject containing metadata about the append operation.paramsOptional parameters sent as part of the request. As Ably adds supported parameters, they will be documented on the docs pages.
callbackA success or failure callback function. On success, it receives an
ARTUpdateDeleteResultobject 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
serialA serial identifier string of the message to retrieve.
callbackA callback which, upon success, will contain a
ARTMessageobject representing the latest version of the message. Upon failure, the callback will contain anARTErrorInfoobject 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
serialA serial identifier string of the message whose versions are to be retrieved.
callbackA callback which, upon success, will contain an
ARTPaginatedResultobject containing an array ofARTMessageobjects representing all versions of the message. Upon failure, the callback will contain anARTErrorInfoobject which explains the error.