ARTRestInstanceMethodsProtocol

Objective-C

@protocol ARTRestInstanceMethodsProtocol <NSObject>

Swift

protocol ARTRestInstanceMethodsProtocol : NSObjectProtocol

This protocol contains the non-initializer instance methods provided by the ARTRest client class.

  • 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.

  • 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) throws

    Parameters

    method

    The request method to use, such as GET, POST.

    path

    The request path.

    params

    The 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.

    body

    The JSON body of the request.

    headers

    Additional HTTP headers to include in the request.

    callback

    A callback for retriving ARTHttpPaginatedResponse object returned by the HTTP request, containing an empty or JSON-encodable object.

    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.

  • 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.

  • Retrieves an 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 }