ARTRealtimeProtocol

Objective-C

@protocol ARTRealtimeProtocol <NSObject>

Swift

protocol ARTRealtimeProtocol : NSObjectProtocol

The protocol upon which the top level object ARTRealtime is implemented.

  • Retrieves a ARTLocalDevice object that represents the current state of the device as a target for push notifications.

    Declaration

    Objective-C

    @property (readonly) ARTLocalDevice *_Nonnull device;

    Swift

    var device: ARTLocalDevice { get }
  • A client ID, used for identifying this client when publishing messages or for presence purposes. The clientId can be any non-empty string, except it cannot contain a *. This option is primarily intended to be used in situations where the library is instantiated with a key. A clientId may also be implicit in a token used to instantiate the library; an error will be raised if a clientId specified here conflicts with the clientId implicit in the token.

    Declaration

    Objective-C

    @property (readonly, nullable) NSString *clientId;

    Swift

    var clientId: String? { get }
  • Constructs an ARTRealtime object using an Ably ARTClientOptions object.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithOptions:(nonnull ARTClientOptions *)options;

    Swift

    init(options: ARTClientOptions)

    Parameters

    options

    An ARTClientOptions object.

  • Constructs an ARTRealtime object using an Ably API key.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithKey:(nonnull NSString *)key;

    Swift

    init(key: String)

    Parameters

    key

    The Ably API key used to validate the client.

  • Constructs an ARTRealtime object using an Ably token string.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithToken:(nonnull NSString *)token;

    Swift

    init(token: String)

    Parameters

    token

    The Ably token string used to validate the client.

  • Retrieves the time from the Ably service. Clients that do not have access to a sufficiently well maintained time source and wish to issue Ably ARTTokenRequests with a more accurate timestamp should use the ARTAuthOptions.queryTime property instead of this method.

    Declaration

    Objective-C

    - (void)time:(nonnull ARTDateTimeCallback)callback;

    Swift

    func time(_ callback: @escaping ARTDateTimeCallback)

    Parameters

    callback

    A callback for receiving the time as a NSDate object.

  • Queries the REST /stats API and retrieves your application’s usage statistics. Returns a ARTPaginatedResult object, containing an array of ARTStats objects. See the Stats docs.

    Declaration

    Objective-C

    - (BOOL)stats:(nullable ARTStatsQuery *)query
         callback:(nonnull ARTPaginatedStatsCallback)callback
            error:(NSError *_Nullable *_Nullable)errorPtr;

    Swift

    func stats(_ query: ARTStatsQuery?, callback: @escaping ARTPaginatedStatsCallback) throws

    Parameters

    query

    An ARTStatsQuery object.

    callback

    A callback for retriving an ARTPaginatedResult object with an array of ARTStats objects.

    errorPtr

    A reference to the NSError object where an error information will be saved in case of failure.

    Return Value

    In case of failure returns false and the error information can be retrived via the error parameter.

  • Calls -[ARTConnectionProtocol connect] and causes the connection to open, entering the connecting state. Explicitly calling connect is unnecessary unless the ARTClientOptions.autoConnect property is disabled.

    Declaration

    Objective-C

    - (void)connect;

    Swift

    func connect()
  • Calls -[ARTConnectionProtocol close] and causes the connection to close, entering the closing state. Once closed, the library will not attempt to re-establish the connection without an explicit call to connect.

    Declaration

    Objective-C

    - (void)close;

    Swift

    func close()