VocService

Extends Protocol:
NSObject
Declared In:
See:

Introduction

VocService encapsulates the functionality provided by Voc SDK.

Discussion

VocService instance is created through VocServiceFactory. To create the service, a delegate implementing VocServiceDelegate protocol and delegate queue are required. In most cases the delegate queue will be the main app queue, however there is no restriction what type of queue to use. If the queue is not serial then users of Voc SDK must ensure voc item objects are accessed serially since they are not thread safe. One such way to achieve that would be to add a lock object of some kind to voc item userInfo and use it to serialize access.

VocService state is available through VocService.state property. Initially VocService is in VOCServiceStateNotRegistered state until it is successfully registered with VoC server. To register call [VocService registerService].

VocService might become unregistered and return to VOCServiceStateNotRegistered state if the user is deleted from server or some time has passed since SDK could connect to VoC server.



Methods

-application:didReceiveRemoteNotification:fetchCompletionHandler:

Must be invoked when remote notification is received to let Voc SDK process it.

-application:performFetchWithCompletionHandler:

Must be invoked when OS wakes up app in background to perform fetch.

-networkQuality

Gets the current network quality.

-setDevicePushToken:

Must be set to the device APNS push token in order push notifications to work.

-unregisterService:

Unregisters voc service with Voc server and stops downloading.


application:didReceiveRemoteNotification:fetchCompletionHandler:


Must be invoked when remote notification is received to let Voc SDK process it.

- (BOOL)application:(nonnull UIApplication *)application 
        didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo 
        fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult result))completionHandler; 
Parameters
application

Singleton app object.

completionHandler

will be called only if the remote notification was for voc service (the method returned YES). Sometimes it might be called before this method returns. If this method returns NO the app will have to call the completionHandler received from iOS.

userInfo

This is obtained from UIApplicationDelegate::didReceiveRemoteNotification:fetchCompletionHandler: and passed into this method. It is a dictionary that contains information related to the remote notification, potentially including a badge number for the app icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data.

Return Value

Will return YES if the remote notification is for voc service, otherwise NO.


application:performFetchWithCompletionHandler:


Must be invoked when OS wakes up app in background to perform fetch.

- (BOOL)application:(nonnull UIApplication *)application 
        performFetchWithCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult result))completionHandler; 
Parameters
application

Singleton app object.

completionHandler

Gets called if voc service performs operation in the background otherwise completionHandler will not be called by voc service - the app will have to call it when it is done. If the app wants to perform operations in background it will have to give voc service a different completionHandler not the one it received. The app should call the original completionHandler only after both it is done and the compeltionHandler it gave to voc service is invoked.

Return Value

Will return YES if voc service performs operations in background.


networkQuality


Gets the current network quality.

- (nullable id<VocNetworkQuality>) networkQuality; 

setDevicePushToken:


Must be set to the device APNS push token in order push notifications to work.

- (void)setDevicePushToken:(NSData * __nullable)devicePushToken; 
Parameters
devicePushToken

It is the APNS push token.


unregisterService:


Unregisters voc service with Voc server and stops downloading.

- (void)unregisterService:(nullable void (^)(NSError * __nullable))completion; 

Properties

cacheAvailable

The remaining storage available for downloaded files (bytes). This is the smaller values of the unused cache and the space available on device.

cacheSize

Size of the cache for downloaded files (bytes).

cacheUsed

The amount of storage used for downloaded files (bytes).

config

Provides access to various configations properties of voc service.

connectionType

Gives the current network connection type and if there is one at all.

devicePushTokenString

Apple Push Notification service(APNS) push token in readable format (read-only).

downloadAllowed

Shows if voc service policies allow downloads at the moment.

lastPolicyStatus

Access the last policy status of voc service.

sortedLogFilePaths

List of SDK log files.

state

The current state of voc service.


cacheAvailable


The remaining storage available for downloaded files (bytes). This is the smaller values of the unused cache and the space available on device.

@property (readonly,
    assign,
    nonatomic) uint64_t cacheAvailable; 

cacheSize


Size of the cache for downloaded files (bytes).

@property (readwrite,
    assign,
    nonatomic) uint64_t cacheSize; 

cacheUsed


The amount of storage used for downloaded files (bytes).

@property (readonly,
    assign,
    nonatomic) uint64_t cacheUsed; 

config


Provides access to various configations properties of voc service.

@property (readonly,
    nonnull,
    strong,
    nonatomic) id<VocConfig> config; 

connectionType


Gives the current network connection type and if there is one at all.

@property (readonly,
    assign,
    nonatomic) VOCConnectionType connectionType; 

devicePushTokenString


Apple Push Notification service(APNS) push token in readable format (read-only).

@property (readonly,
    nullable,
    strong,
    atomic) NSString *devicePushTokenString; 

downloadAllowed


Shows if voc service policies allow downloads at the moment.

@property (readonly,
    assign,
    nonatomic) BOOL downloadAllowed; 

lastPolicyStatus


Access the last policy status of voc service.

@property (readonly,
    assign,
    nonatomic) VOCPolicyStatus lastPolicyStatus; 

sortedLogFilePaths


List of SDK log files.

@property (readonly,
    nullable,
    strong,
    atomic) NSArray* sortedLogFilePaths; 

state


The current state of voc service.

@property (readonly,
    assign,
    nonatomic) VOCServiceState state;