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 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 update to an existing message with patch semantics. Non-null
name,data, andextrasfields 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
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 query string.
callbackA callback which, upon success, will contain a
ARTMessageobject containing the updated message. Upon failure, the callback will contain anARTErrorInfoobject 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-nullname,data, andextrasfields 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 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 ARTCallback)callback;Swift
func delete(_ message: ARTMessage, operation: ARTMessageOperation?, params: [String : ARTStringifiable]?, callback: ARTCallback? = nil)Parameters
messageAn
ARTMessageobject containing a populatedserialfield.operationAn optional
ARTMessageOperationobject containing metadata about the delete operation.paramsOptional parameters sent as part of the query string.
callbackA callback which, upon success, will contain a
ARTMessageobject containing the deleted message. Upon failure, the callback will contain anARTErrorInfoobject 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
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.