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
ARTMessageActionenum values.Note
A message that you create via theinitWithName:data:orinitWithName:data:clientId:initializers will have anactionofARTMessageActionCreate. However, the value of this property will be ignored when you pass this message to the SDK (e.g. when publishing the message).Declaration
Objective-C
@property (nonatomic) ARTMessageAction action;Swift
var action: ARTMessageAction { 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 version information for the message, containing serial, timestamp, and operation metadata.
Declaration
Objective-C
@property (nonatomic, nullable) ARTMessageVersion *version;Swift
var version: ARTMessageVersion? { get set } -
Contains annotations for the message, including summary data.
Declaration
Objective-C
@property (nonatomic, nullable) ARTMessageAnnotations *annotations;Swift
var annotations: ARTMessageAnnotations? { get set } -
Construct an
ARTMessageobject 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
nameThe event name.
dataThe message payload.
-
Construct an
ARTMessageobject 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
nameThe event name.
dataThe message payload.
clientIdThe client ID of the publisher of this message.
-
Whether the
actionproperty has been set by the internals of the SDK.This property defaults to
NO, indicating that theactionproperty is either the default value or has been set by the user. As described in the documentation foraction, this means that the SDK should ignore the value of this property. In particular, it should not populate this property when sending this message over the wire.Note
If we had a separateWireMessagetype instead of usingARTMessageas both our internal and external representation of a message, then we wouldn’t need this mechanism. But we don’t.Declaration
Objective-C
@property (nonatomic) BOOL actionIsInternallySet;Swift
var actionIsInternallySet: Bool { get set }
-
A static factory method to create an
ARTMessageobject 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 -> SelfParameters
jsonObjectA
Message-like deserialized object.optionsAn
ARTChannelOptionsobject. If you have an encrypted channel, use this to allow the library to decrypt the data.Return Value
An
ARTMessageobject. -
A static factory method to create an array of
ARTMessageobjects 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
jsonArrayAn array of
Message-like deserialized objects.optionsAn
ARTChannelOptionsobject. If you have an encrypted channel, use this to allow the library to decrypt the data.Return Value
An array of
ARTMessageobjects.