Record Events

Native Android ==> Shared module

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")  
  }  
})