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
truewhen 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
ARTPresenceActionand ID. Returns an array ofARTPresenceMessageobjects.Declaration
Objective-C
- (void)get:(nonnull ARTRealtimePresenceQuery *)query callback:(nonnull ARTPresenceMessagesCallback)callback;Swift
func get(_ query: ARTRealtimePresenceQuery, callback: @escaping ARTPresenceMessagesCallback)Parameters
queryAn
ARTRealtimePresenceQueryobject.callbackA callback for retriving an
ARTPaginatedResultobject with an array ofARTPresenceMessageobjects. -
Enters the presence set for the channel, optionally passing a
datapayload. AclientIdis required to be present on a channel.Declaration
Objective-C
- (void)enter:(id _Nullable)data;Swift
func enter(_ data: Any?)Parameters
dataThe payload associated with the presence member.
-
Enters the presence set for the channel, optionally passing a
datapayload. AclientIdis 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
dataThe payload associated with the presence member.
callbackA success or failure callback function.
-
Updates the
datapayload for a presence member. If called before entering the presence set, this is treated as anARTPresenceAction.ARTPresenceEnterevent.Declaration
Objective-C
- (void)update:(id _Nullable)data;Swift
func update(_ data: Any?)Parameters
dataThe payload to update for the presence member.
-
Updates the
datapayload for a presence member. If called before entering the presence set, this is treated as anARTPresenceAction.ARTPresenceEnterevent. 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
dataThe payload to update for the presence member.
callbackA 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
dataThe 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
dataThe payload associated with the presence member.
callbackA 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 wildcardclientId.Declaration
Objective-C
- (void)enterClient:(nonnull NSString *)clientId data:(id _Nullable)data;Swift
func enterClient(_ clientId: String, data: Any?)Parameters
clientIdThe ID of the client to enter into the presence set.
dataThe 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 wildcardclientId. 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
clientIdThe ID of the client to enter into the presence set.
dataThe payload associated with the presence member.
callbackA success or failure callback function.
-
Updates the
datapayload for a presence member using a givenclientId. 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 wildcardclientId.Declaration
Objective-C
- (void)updateClient:(nonnull NSString *)clientId data:(id _Nullable)data;Swift
func updateClient(_ clientId: String, data: Any?)Parameters
clientIdThe ID of the client to update in the presence set.
dataThe payload to update for the presence member.
-
Updates the
datapayload for a presence member using a givenclientId. 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 wildcardclientId. 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
clientIdThe ID of the client to update in the presence set.
dataThe payload to update for the presence member.
callbackA 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 wildcardclientId. 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
clientIdThe ID of the client to leave the presence set for.
dataThe 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 wildcardclientId. 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
clientIdThe ID of the client to leave the presence set for.
dataThe payload associated with the presence member.
callbackA success or failure callback function.
-
Registers a listener that is called each time a
ARTPresenceMessageis 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
callbackAn event listener function.
Return Value
An event listener object.
-
Registers a listener that is called each time a
ARTPresenceMessageis 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. It will not be called if theARTRealtimeChannelOptions.attachOnSubscribechannel option is set tofalse.Declaration
Objective-C
- (ARTEventListener *_Nullable) subscribeWithAttachCallback:(nullable ARTCallback)onAttach callback:(nonnull ARTPresenceMessageCallback)callback;Swift
func subscribe(attachCallback onAttach: ARTCallback?, callback: @escaping ARTPresenceMessageCallback) -> ARTEventListener?Parameters
onAttachAn attach callback function.
callbackAn event listener function.
Return Value
An event listener object.
-
Registers a listener that is called each time a
ARTPresenceMessagematching a givenARTPresenceActionis 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
actionA
ARTPresenceActionto register the listener for.callbackAn event listener function.
Return Value
An event listener object.
-
Registers a listener that is called each time a
ARTPresenceMessagematching a givenARTPresenceActionis 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. It will not be called if theARTRealtimeChannelOptions.attachOnSubscribechannel option is set tofalse.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
actionA
ARTPresenceActionto register the listener for.onAttachAn attach callback function.
callbackAn event listener function.
Return Value
An event listener object.
-
Deregisters all listeners currently receiving
ARTPresenceMessagefor the channel.Declaration
Objective-C
- (void)unsubscribe;Swift
func unsubscribe() -
Deregisters a specific listener that is registered to receive
ARTPresenceMessageon the channel.Declaration
Objective-C
- (void)unsubscribe:(nonnull ARTEventListener *)listener;Swift
func unsubscribe(_ listener: ARTEventListener)Parameters
listenerAn event listener to unsubscribe.
-
Deregisters a specific listener that is registered to receive
ARTPresenceMessageon the channel for a givenARTPresenceAction.Declaration
Objective-C
- (void)unsubscribe:(ARTPresenceAction)action listener:(nonnull ARTEventListener *)listener;Swift
func unsubscribe(_ action: ARTPresenceAction, listener: ARTEventListener)Parameters
actionA specific
ARTPresenceActionto deregister the listener for.listenerAn event listener to unsubscribe.
-
Retrieves a
ARTPaginatedResultobject, containing an array of historicalARTPresenceMessageobjects 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) throwsParameters
queryAn
ARTRealtimeHistoryQueryobject.callbackA callback for retriving an
ARTPaginatedResultobject with an array ofARTPresenceMessageobjects.errorPtrA reference to the
NSErrorobject where an error information will be saved in case of failure.Return Value
In case of failure returns
falseand the error information can be retrived via theerrorparameter.