ONGDeviceClient Class Reference

Inherits from NSObject
Declared in ONGDeviceClient.h

+ sharedInstance

Access to the initialized and configured instance of the ONGDeviceClient. Before calling this method You have to initialize SDK by calling [ONGClientBuilder build].

+ (ONGDeviceClient *)sharedInstance

Return Value

instance of the configured ONGDeviceClient.

Discussion

Warning: If the SDK is not initialized via [ONGClientBuilder build] this method throws an exception.

See Also

  • ONGClientBuilder, [ONGClient deviceClient]

Declared In

ONGDeviceClient.h

– authenticateDevice:completion:

Performs device authentication.

- (void)authenticateDevice:(nullable NSArray<NSString*> *)scopes completion:(nullable void ( ^ ) ( BOOL success , NSError *_Nullable error ))completion

Parameters

scopes

array of scopes.

completion

block that will be called on authentication completion.

Discussion

The returned error will be of the ONGGenericErrorDomain.

Declared In

ONGDeviceClient.h

– fetchResource:completion:

Perform an authenticated network request. It requires passing an instance of the ONGResourceRequest as parameter. In case of a malformed request no task will be returned and the completion block is called immediately (synchronously). The device needs to be authenticated, otherwise SDK will return the ONGFetchAnonymousResourceErrorDeviceNotAuthenticated error.

- (nullable ONGNetworkTask *)fetchResource:(ONGResourceRequest *)request completion:(nullable void ( ^ ) ( ONGResourceResponse *_Nullable response , NSError *_Nullable error ))completion

Parameters

request

instance of ONGResourceRequest instantiated manually or by using ONGRequestBuilder

completion

block that will be called either upon request completion or immediately in case if validation error.

Return Value

instance of ONGNetworkTask or nil. By utilizing ONGNetworkTask developer may observe and control execution of the request.

Discussion

The returned errors will be within the ONGGenericErrorDomain, ONGFetchAnonymousResourceErrorDomain or NSURLErrorDomain.

Declared In

ONGDeviceClient.h

– fetchUnauthenticatedResource:completion:

Perform an unauthenticated network request. It requires passing an instance of the ONGResourceRequest as parameter. In case of a malformed request no task will be returned and the completion block is called immediately (synchronously).

- (nullable ONGNetworkTask *)fetchUnauthenticatedResource:(ONGResourceRequest *)request completion:(nullable void ( ^ ) ( ONGResourceResponse *_Nullable response , NSError *_Nullable error ))completion

Parameters

request

instance of ONGResourceRequest instantiated manually or by using ONGRequestBuilder

completion

completion block that will be called either upon request completion or immediately in case if validation error.

Return Value

instance of ONGNetworkTask or nil. By utilizing ONGNetworkTask developer may observe and control exectution of request.

Discussion

The returned errors will be within the ONGGenericErrorDomain, ONGFetchUnauthenticatedResourceErrorDomain or NSURLErrorDomain.

Declared In

ONGDeviceClient.h

– clientIdWithError:

Returns the clientId for the registered device.

- (nullable NSString *)clientIdWithError:(NSError *_Nullable *_Nullable)error

Parameters

error

describes the reason behind the clientId fetch failure.

Return Value

string with clientId.

Declared In

ONGDeviceClient.h