ARTRealtimeInstanceMethodsProtocol
Objective-C
@protocol ARTRealtimeInstanceMethodsProtocol <NSObject>
Swift
protocol ARTRealtimeInstanceMethodsProtocol : NSObjectProtocol
This protocol contains the non-initializer instance methods provided by the ARTRealtime client class.
-
Retrieves a
ARTLocalDeviceobject 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
clientIdcan 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. AclientIdmay also be implicit in a token used to instantiate the library; an error will be raised if aclientIdspecified here conflicts with theclientIdimplicit in the token.Declaration
Objective-C
@property (readonly, nullable) NSString *clientId;Swift
var clientId: String? { get } -
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 theARTAuthOptions.queryTimeproperty instead of this method.Declaration
Objective-C
- (void)time:(nonnull ARTDateTimeCallback)callback;Swift
func time(_ callback: @escaping ARTDateTimeCallback)Parameters
callbackA callback for receiving the time as a
NSDateobject. -
Makes a REST request to a provided path. This is provided as a convenience for developers who wish to use REST API functionality that is either not documented or is not yet included in the public API, without having to directly handle features such as authentication, paging, fallback hosts, MsgPack and JSON support.
Declaration
Objective-C
- (BOOL)request:(nonnull NSString *)method path:(nonnull NSString *)path params:(nullable NSStringDictionary *)params body:(nullable id)body headers:(nullable NSStringDictionary *)headers callback:(nonnull ARTHTTPPaginatedCallback)callback error:(NSError *_Nullable *_Nullable)errorPtr;Swift
func request(_ method: String, path: String, params: [String : String]?, body: Any?, headers: [String : String]?, callback: @escaping ARTHTTPPaginatedCallback) throwsParameters
methodThe request method to use, such as GET, POST.
pathThe request path.
paramsThe parameters to include in the URL query of the request. The parameters depend on the endpoint being queried. See the REST API reference for the available parameters of each endpoint.
bodyThe JSON body of the request.
headersAdditional HTTP headers to include in the request.
callbackA callback for retriving
ARTHttpPaginatedResponseobject returned by the HTTP request, containing an empty or JSON-encodable object.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. -
Queries the REST
/statsAPI and retrieves your application’s usage statistics. Returns aARTPaginatedResultobject, containing an array ofARTStatsobjects. 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) throwsParameters
queryAn
ARTStatsQueryobject.callbackA callback for retriving an
ARTPaginatedResultobject with an array ofARTStatsobjects.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. -
Calls
-[ARTConnectionProtocol connect]and causes the connection to open, entering the connecting state. Explicitly callingconnectis unnecessary unless theARTClientOptions.autoConnectproperty 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 toconnect.Declaration
Objective-C
- (void)close;Swift
func close()