ARTMessage
Objective-C
@interface ARTMessage : ARTBaseMessage
Swift
class ARTMessage : ARTBaseMessage
Contains an individual message that is sent to, or received from, Ably.
-
The event name, if available
Declaration
Objective-C
@property (nonatomic, nullable) NSString *name;
Swift
var name: String? { get set }
-
The action type of the message, one of the
ARTMessageAction
enum values.Declaration
Objective-C
@property (nonatomic) ARTMessageAction action;
Swift
var action: ARTMessageAction { get set }
-
The version of the message, lexicographically-comparable with other versions (that share the same serial). Will differ from the serial only if the message has been updated or deleted.
Declaration
Objective-C
@property (nonatomic, nullable) NSString *version;
Swift
var version: String? { get set }
-
This message’s unique serial (an identifier that will be the same in all future updates of this message).
Declaration
Objective-C
@property (nonatomic, nullable) NSString *serial;
Swift
var serial: String? { get set }
-
The timestamp of the very first version of a given message.
Declaration
Objective-C
@property (nonatomic, nullable) NSDate *createdAt;
Swift
var createdAt: Date? { get set }
-
Construct an
ARTMessage
object with an event name and payload.Declaration
Objective-C
- (nonnull instancetype)initWithName:(nullable NSString *)name data:(nonnull id)data;
Swift
init(name: String?, data: Any)
Parameters
name
The event name.
data
The message payload.
-
Construct an
ARTMessage
object with an event name, payload, and a unique client ID.Declaration
Objective-C
- (nonnull instancetype)initWithName:(nullable NSString *)name data:(nonnull id)data clientId:(nonnull NSString *)clientId;
Swift
init(name: String?, data: Any, clientId: String)
Parameters
name
The event name.
data
The message payload.
clientId
The client ID of the publisher of this message.
-
A static factory method to create an
ARTMessage
object from a deserialized Message-like object encoded using Ably’s wire protocol.Declaration
Objective-C
+ (nullable instancetype)fromEncoded:(nonnull NSDictionary *)jsonObject channelOptions:(nonnull ARTChannelOptions *)options error:(NSError *_Nullable *_Nullable)error;
Swift
class func fromEncoded(_ jsonObject: [AnyHashable : Any], channelOptions options: ARTChannelOptions) throws -> Self
Parameters
jsonObject
A
Message
-like deserialized object.options
An
ARTChannelOptions
object. If you have an encrypted channel, use this to allow the library to decrypt the data.Return Value
An
ARTMessage
object. -
A static factory method to create an array of
ARTMessage
objects from an array of deserialized Message-like object encoded using Ably’s wire protocol.Declaration
Objective-C
+ (nullable NSArray<ARTMessage *> *) fromEncodedArray:(nonnull NSArray<NSDictionary *> *)jsonArray channelOptions:(nonnull ARTChannelOptions *)options error:(NSError *_Nullable *_Nullable)error;
Swift
class func fromEncodedArray(_ jsonArray: [[AnyHashable : Any]], channelOptions options: ARTChannelOptions) throws -> [ARTMessage]
Parameters
jsonArray
An array of
Message
-like deserialized objects.options
An
ARTChannelOptions
object. If you have an encrypted channel, use this to allow the library to decrypt the data.Return Value
An array of
ARTMessage
objects.