Record Events

Native Android ==> Shared module


Record Upload Queue

Records collected by the SDK are queued for upload before being submitted to the Validic API. You can retrieve an immutable snapshot of the records currently in the queue using getQueuedInformRecords().

viewModelScope.launch {
  val pendingRecords: List<InformRecord> = SessionV2.getInstance(context).getQueuedInformRecords()
  Log.i("Queue", "${pendingRecords.size} records pending upload")
}

The returned list is a point-in-time snapshot and is safe to read independently of the upload pipeline.


Record Upload To Inform

Listening for Authentication and records submission events produced by the Validic Mobile SDKs can be set up by registering a SessionV2.Listener. If a 4xx error is returned from the server, the record will be discarded and ResourceListener.onResourceResponse(InformRecord, Error) will be called with a non-null exception. If the record is submitted successfully, then ResourceListener.onResourceResponse(InformRecord, null) will be called and the record returned will have a server populated id property.

If a 401 is received from the server then the User's stored credentials are invalid. The persisted user will be removed and ResourceListener.onUserSessionEnded(User, unsentRecords) will be called with the invalid user credentials and a list of any records that were captured for the user, but were not transmitted to the Validic API.

SessionV2.getInstance(context).addResourceListener(object: SessionV2.Listener {  
  override fun onResourceResponse(resource: InformRecord?, error: Exception?) {  
    if (error != null)  
      Log.e("Error", error.message ?: error.cause?.message ?: "Failed to Submit Reading")  
    resource?.let {  
      Log.i("Success", "Submitted Reading logID: ${it.logId} serverID: ${it.id}")  
    }  
  }

  override fun onUserSessionEnded(user: User, resources: List<InformRecord>?){  
    Log.i("User ${user.validicUserId} session ended with ${resources?.size} unsubmitted records")  
  }  
})