ARTRealtimePresenceProtocol

Objective-C

@protocol ARTRealtimePresenceProtocol

Swift

protocol ARTRealtimePresenceProtocol

The protocol upon which the ARTRealtimePresence is implemented.

  • Indicates whether the presence set synchronization between Ably and the clients on the channel has been completed. Set to true when the sync is complete.

    Declaration

    Objective-C

    @property (readonly) BOOL syncComplete;

    Swift

    var syncComplete: Bool { get }
  • Retrieves the current members present on the channel and the metadata for each member, such as their ARTPresenceAction and ID. Returns an array of ARTPresenceMessage objects.

    Declaration

    Objective-C

    - (void)get:(nonnull ARTRealtimePresenceQuery *)query
        callback:(nonnull ARTPresenceMessagesCallback)callback;

    Swift

    func get(_ query: ARTRealtimePresenceQuery, callback: @escaping ARTPresenceMessagesCallback)

    Parameters

    query
    callback

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

  • Enters the presence set for the channel, optionally passing a data payload. A clientId is required to be present on a channel.

    Declaration

    Objective-C

    - (void)enter:(id _Nullable)data;

    Swift

    func enter(_ data: Any?)

    Parameters

    data

    The payload associated with the presence member.

  • Enters the presence set for the channel, optionally passing a data payload. A clientId is required to be present on a channel. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)enter:(id _Nullable)data callback:(nullable ARTCallback)callback;

    Swift

    func enter(_ data: Any?, callback: ARTCallback? = nil)

    Parameters

    data

    The payload associated with the presence member.

    callback

    A success or failure callback function.

  • Updates the data payload for a presence member. If called before entering the presence set, this is treated as an ARTPresenceAction.ARTPresenceEnter event.

    Declaration

    Objective-C

    - (void)update:(id _Nullable)data;

    Swift

    func update(_ data: Any?)

    Parameters

    data

    The payload to update for the presence member.

  • Updates the data payload for a presence member. If called before entering the presence set, this is treated as an ARTPresenceAction.ARTPresenceEnter event. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)update:(id _Nullable)data callback:(nullable ARTCallback)callback;

    Swift

    func update(_ data: Any?, callback: ARTCallback? = nil)

    Parameters

    data

    The payload to update for the presence member.

    callback

    A success or failure callback function.

  • Leaves the presence set for the channel. A client must have previously entered the presence set before they can leave it.

    Declaration

    Objective-C

    - (void)leave:(id _Nullable)data;

    Swift

    func leave(_ data: Any?)

    Parameters

    data

    The payload associated with the presence member.

  • Leaves the presence set for the channel. A client must have previously entered the presence set before they can leave it. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)leave:(id _Nullable)data callback:(nullable ARTCallback)callback;

    Swift

    func leave(_ data: Any?, callback: ARTCallback? = nil)

    Parameters

    data

    The payload associated with the presence member.

    callback

    A success or failure callback function.

  • Enters the presence set of the channel for a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId.

    Declaration

    Objective-C

    - (void)enterClient:(nonnull NSString *)clientId data:(id _Nullable)data;

    Swift

    func enterClient(_ clientId: String, data: Any?)

    Parameters

    clientId

    The ID of the client to enter into the presence set.

    data

    The payload associated with the presence member.

  • Enters the presence set of the channel for a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)enterClient:(nonnull NSString *)clientId
                   data:(id _Nullable)data
               callback:(nullable ARTCallback)callback;

    Swift

    func enterClient(_ clientId: String, data: Any?, callback: ARTCallback? = nil)

    Parameters

    clientId

    The ID of the client to enter into the presence set.

    data

    The payload associated with the presence member.

    callback

    A success or failure callback function.

  • Updates the data payload for a presence member using a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId.

    Declaration

    Objective-C

    - (void)updateClient:(nonnull NSString *)clientId data:(id _Nullable)data;

    Swift

    func updateClient(_ clientId: String, data: Any?)

    Parameters

    clientId

    The ID of the client to update in the presence set.

    data

    The payload to update for the presence member.

  • Updates the data payload for a presence member using a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)updateClient:(nonnull NSString *)clientId
                    data:(id _Nullable)data
                callback:(nullable ARTCallback)callback;

    Swift

    func updateClient(_ clientId: String, data: Any?, callback: ARTCallback? = nil)

    Parameters

    clientId

    The ID of the client to update in the presence set.

    data

    The payload to update for the presence member.

    callback

    A success or failure callback function.

  • Leaves the presence set of the channel for a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)leaveClient:(nonnull NSString *)clientId data:(id _Nullable)data;

    Swift

    func leaveClient(_ clientId: String, data: Any?)

    Parameters

    clientId

    The ID of the client to leave the presence set for.

    data

    The payload associated with the presence member.

  • Leaves the presence set of the channel for a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId. An optional callback may be provided to notify of the success or failure of the operation.

    Declaration

    Objective-C

    - (void)leaveClient:(nonnull NSString *)clientId
                   data:(id _Nullable)data
               callback:(nullable ARTCallback)callback;

    Swift

    func leaveClient(_ clientId: String, data: Any?, callback: ARTCallback? = nil)

    Parameters

    clientId

    The ID of the client to leave the presence set for.

    data

    The payload associated with the presence member.

    callback

    A success or failure callback function.

  • Registers a listener that is called each time a ARTPresenceMessage is received on the channel, such as a new member entering the presence set.

    Declaration

    Objective-C

    - (ARTEventListener *_Nullable)subscribe:
        (nonnull ARTPresenceMessageCallback)callback;

    Swift

    func subscribe(_ callback: @escaping ARTPresenceMessageCallback) -> ARTEventListener?

    Parameters

    callback

    An event listener function.

    Return Value

    An event listener object.

  • Registers a listener that is called each time a ARTPresenceMessage is received on the channel, such as a new member entering the presence set. A callback may optionally be passed in to this call to be notified of success or failure of the channel -[ARTRealtimeChannelProtocol attach] operation.

    Declaration

    Objective-C

    - (ARTEventListener *_Nullable)
        subscribeWithAttachCallback:(nullable ARTCallback)onAttach
                           callback:(nonnull ARTPresenceMessageCallback)callback;

    Swift

    func subscribe(attachCallback onAttach: ARTCallback?, callback: @escaping ARTPresenceMessageCallback) -> ARTEventListener?

    Parameters

    onAttach

    An attach callback function.

    callback

    An event listener function.

    Return Value

    An event listener object.

  • Registers a listener that is called each time a ARTPresenceMessage matching a given ARTPresenceAction is received on the channel, such as a new member entering the presence set.

    Declaration

    Objective-C

    - (ARTEventListener *_Nullable)subscribe:(ARTPresenceAction)action
                                    callback:(nonnull ARTPresenceMessageCallback)
                                                 callback;

    Swift

    func subscribe(_ action: ARTPresenceAction, callback: @escaping ARTPresenceMessageCallback) -> ARTEventListener?

    Parameters

    action

    A ARTPresenceAction to register the listener for.

    callback

    An event listener function.

    Return Value

    An event listener object.

  • Registers a listener that is called each time a ARTPresenceMessage matching a given ARTPresenceAction is received on the channel, such as a new member entering the presence set. A callback may optionally be passed in to this call to be notified of success or failure of the channel -[ARTRealtimeChannelProtocol attach] operation.

    Declaration

    Objective-C

    - (ARTEventListener *_Nullable)subscribe:(ARTPresenceAction)action
                                    onAttach:(nullable ARTCallback)onAttach
                                    callback:(nonnull ARTPresenceMessageCallback)
                                                 callback;

    Swift

    func subscribe(_ action: ARTPresenceAction, onAttach: ARTCallback?, callback: @escaping ARTPresenceMessageCallback) -> ARTEventListener?

    Parameters

    action

    A ARTPresenceAction to register the listener for.

    onAttach

    An attach callback function.

    callback

    An event listener function.

    Return Value

    An event listener object.

  • Deregisters all listeners currently receiving ARTPresenceMessage for the channel.

    Declaration

    Objective-C

    - (void)unsubscribe;

    Swift

    func unsubscribe()
  • Deregisters a specific listener that is registered to receive ARTPresenceMessage on the channel.

    Declaration

    Objective-C

    - (void)unsubscribe:(nonnull ARTEventListener *)listener;

    Swift

    func unsubscribe(_ listener: ARTEventListener)

    Parameters

    listener

    An event listener to unsubscribe.

  • Deregisters a specific listener that is registered to receive ARTPresenceMessage on the channel for a given ARTPresenceAction.

    Declaration

    Objective-C

    - (void)unsubscribe:(ARTPresenceAction)action
               listener:(nonnull ARTEventListener *)listener;

    Swift

    func unsubscribe(_ action: ARTPresenceAction, listener: ARTEventListener)

    Parameters

    action

    A specific ARTPresenceAction to deregister the listener for.

    listener

    An event listener to unsubscribe.

  • Retrieves a ARTPaginatedResult object, containing an array of historical ARTPresenceMessage objects for the channel. If the channel is configured to persist messages, then presence messages can be retrieved from history for up to 72 hours in the past. If not, presence messages can only be retrieved from history for up to two minutes in the past.

    Declaration

    Objective-C

    - (BOOL)history:(ARTRealtimeHistoryQuery *_Nullable)query
           callback:(nonnull ARTPaginatedPresenceCallback)callback
              error:(NSError *_Nullable *_Nullable)errorPtr;

    Swift

    func history(_ query: ARTRealtimeHistoryQuery?, callback: @escaping ARTPaginatedPresenceCallback) throws

    Parameters

    query
    callback

    A callback for retriving an ARTPaginatedResult object with an array of ARTPresenceMessage 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.