VLDSession

Objective-C

@interface VLDSession : NSObject

Swift

class VLDSession : NSObject

VLDSession stores a user, their current HealthKit subscriptions and all pending record uploads. This data is persisted between app launches but is deleted if endSession is called.

VLDSession is a singleton object and must be accessed by its sharedInstance method. The different components of the Validic Mobile library rely on a valid user existing in the current VLDSession singleton object.

Notifications

When VLDSession uploads a record it will send an NSNotification. To listen for this notification add an observer to the NSNotificationCenter with the name kVLDRecordSubmittedNotification. The object property of the notification will contain the VLDRecord object uploaded.

If a 400 error is returned from the server, the record will be discarded and an NSNotification will be posted. To listen for this notification add an observer to the NSNotificationCenter with the name kVLDRecordSubmissionFailedNotification. The object property of the notification will contain the invalid VLDRecord object. The userInfo dictionary for this notification will contain one key, error with the NSError object for the failed upload.

When an image is uploaded VLDSession will send out an NSNotification with the name kVLDRecordImageSubmittedNotification. The object property of the notification will contain a VLDMedia instance. If the image fails to upload an NSNotification will be sent out with the name kVLDRecordImageSubmissionFailedNotification and the object property of the notification will be the record object associated with the image and the userInfo dictionary will contain a value for the key error with the NSError object describing the problem.

  • The user for the current session.

    Declaration

    Objective-C

    @property (nonatomic, readonly) VLDUser *user;

    Swift

    var user: VLDUser! { get }
  • Version of the ValidicMobile library in a string comprised of three period-separated integers/

    Declaration

    Objective-C

    + (NSString *)libraryVersion;

    Swift

    class func libraryVersion() -> String!
  • sharedInstance returns the VLDSession singleton and should be the only way VLDSession is accessed.

    Declaration

    Objective-C

    + (instancetype)sharedInstance;

    Swift

    class func sharedInstance() -> Self!
  • Starts a new session with the specified user. Deletes existing session if present. This method throws an exception if [user isValid] returns false, i.e. if validicUserID, organizationID, or authToken is nil.

    Declaration

    Objective-C

    - (void)startSessionWithUser:(VLDUser *)user;

    Swift

    func start(with user: VLDUser!)

    Parameters

    user

    the Validic user that owns the session data.

  • Removes all locally stored session data.

    Declaration

    Objective-C

    - (void)endSession;

    Swift

    func end()
  • Queues a VLDRecord for submission.

    Declaration

    Objective-C

    - (void)submitRecord:(VLDRecord *)record;

    Swift

    func submitRecord(_ record: VLDRecord!)

    Parameters

    record

    the record to be submitted.

  • Queues a VLDRecord with an image for submission.

    This method should be used to submit records created by VLDOCRController along with the image processed.

    Declaration

    Objective-C

    - (void)submitRecord:(VLDRecord *)record image:(UIImage *)image;

    Swift

    func submitRecord(_ record: VLDRecord!, image: UIImage!)

    Parameters

    record

    the record to be submitted.

    image

    the image associated with the record.

  • Queues an array of VLDRecord objects for submission. This arrray may contain more than one type of VLDRecord subclass.

    Declaration

    Objective-C

    - (void)submitRecords:(NSArray<__kindof VLDRecord *> *)records;

    Swift

    func submitRecords(_ records: [VLDRecord]!)

    Parameters

    records

    the records to be submitted.

  • Calling this method will begin uploading all pending records.

    In most situations it is not necessary to call this method as the system will automatically attempt to process the queue at the correct times.

    Declaration

    Objective-C

    - (void)processQueue;

    Swift

    func processQueue()