ValidicMobile Reference
Introduction
The main components of the ValidicMobile library are the API client, Bluetooth, HealthKit, and OCR.
Users
A user session is required for the HealthKit, Bluetooth, and OCR components of the library to submit data to Validic’s servers. You should verify that a valid user exists in the VLDSession singleton before using these components' features. Example:
if (![[VLDSession sharedInstance] user]) {
// prompt for user information
} else {
// proceed to feature screen
}
API Client
The API Client provides convenient methods to upload VLDRecord objects to Validic’s servers. It handles creating proper URLs, constructing the request object and parsing the server response. When not using [VLDSession submitRecord:] to upload data, it is recommended to use VLDAPIClient.
HealthKit
The ValidicMobile library provides a simple way to read and upload data from HealthKit to Validic. VLDHealthKitManager can subscribe to specific HealthKit data types and automatically upload them to Validic in the background as new data is recorded.
Subscribing to HealthKit data updates only needs to be done once for a user. The subscriptions will be persisted across app launches in the VLDSession object. A typical use of the HealthKit component would be to create a UISwitch that adds the required subscriptions when turned on and removes them when turned off. Example:
- (IBAction)switchAction:(UISwitch *)sender {
NSArray *subscriptions = ... // HKSampleType objects
if (sender.on) {
[[VLDHealthKitManager sharedInstance] setSubscriptions:subscriptions completion:nil];
} else {
[[VLDHealthKitManager sharedInstance] setSubscriptions:@[] completion:nil];
}
}
To properly process the delivery of data in the background, the subscription observers need to be recreated immediately when the app is launched. To do this, you need to call [VLDHealthKitManager observeCurrentSubscriptions] inside your application delegate’s application:didFinishLaunchingWithOptions: callback. Example:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[VLDHealthKitManager sharedInstance] observeCurrentSubscriptions];
// your application's initialization code
return YES;
}
Bluetooth
Readings from validated Bluetooth Low Energy devices can be captured and uploaded to Validic with VLDBluetoothPeripheralController. A list of supported devices can be obtained from [VLDBluetoothPeripheral supportedPeripherals]. You must implement the VLDBluetoothPeripheralControllerDelegate protocol to receive the different callbacks so that the user may be prompted to take the measurement at the right time, display the measurement value, or get notified of any errors that occurred.
OCR
VLDOCRController is the primary interface for getting records from a peripheral via OCR. The live results and final record are given to the VLDOCRController’s delegate object (VLDOCRControllerDelegate).
VLDOCRController is initialized with a VLDOCRPeripheral object. A VLDOCRPeripheral object can be obtained by calling [VLDOCRPeripheral supportedPeripherals].
When an instance of VLDOCRController is initialized it will immediately
turn on the camera for the current device. The camera preview can be accessed
with the previewLayer
property. VLDOCRController needs to be configured
with the configureForPreviewLayerSize:
method. You need to call this method
when VLDOCRController is initialized and pass in the size of the preview layer
(generally the full size of the screen).
This will allow the library to set the overlayFrame
property to the correct size.
overlayFrame
should then be used to set the frame of the overlayImage
from
the peripheral. This is required so that the user is able to position the camera so
that the peripheral is in the proper place to be processed for OCR. Note: you will need
to call configureForPreviewLayerSize:
if the size of the preview layer changes, it
is recommended to call this method from the viewDidLayoutSubviews
callback in your
view controller.
For a complete example of this implemented see the “Vitalsnap example” project.
Class References
- VLDAPIClient
- VLDBiometrics
- VLDBluetoothPassiveManager
- VLDBluetoothPeripheral
- VLDBluetoothPeripheralController
- VLDDiabetes
- VLDFitness
- VLDGlareArea
- VLDHealthKitManager
- VLDHealthKitSubscription
- VLDMedia
- VLDModel
- VLDNutrition
- VLDOCRController
- VLDOCRPeripheral
- VLDOCRResult
- VLDOCRViewController
- VLDPeripheral
- VLDRecord
- VLDRoutine
- VLDServerResponse
- VLDSession
- VLDSleep
- VLDUser
- VLDWeight