Skip to main content

MeData Service

MeData Service is the core of the Mobile SDK. It collects MeData values from various sources according to the MeData Definitions managed on Orchestrator. Most of other Mobile SDK services are triggered or effected by MeData Service.

info

Mobile SDK performs background network access to fetch MeData Definitions from DataSapien Mobile Backend.

Data Vault

MeData collected by Mobile SDK is allways stored on user device. Data is stored in a platform encrypted and sandboxed data base that is called the Data Vault. MeData Service provides methods to query and consume stored MeData in Data Vault.

MeData Collection

Mobile SDK collects data from various sources: Native, external APIs via Scripts, from VC (Verifiable Credentials) and Question answers.

  1. For Native sourced collection, MeData Service will execute the code it provides out of the box
  2. For Script sourced collection; MeData Service will execute the script authered on Orchestrator
  3. For VC sourced collection, MeData Service will access targeted VC from Wallet Service
  4. For Question sourced collection, some kind of UI interaction is required. This UI can be anything from a dedicated screen that displays a list of questions or simple a popup. Mobile SDK provides its own UI or the data required to display yours in your host app..

MeData Service Functions

To access MeDataService functions; get its instance from DataSapien object: DataSapien.getMeDataService().


1. Medata Definitions

MeData Definitions are metadata schemas that define what MeData is, how it is categorized, and what data types are used. These are managed on the Orchestrator and synced to the client SDK.

Fetch MeData Definitions

Fetches and persists MeData definition list from the backend.

MeData Definition Fetch
// Signature
public func fetchMeDataDefinitions(onSuccess: @escaping ([MeDataDefinition]) -> Void,
onError: ((Error) -> Void)? = nil)

// Usage
DataSapien.getMeDataService().fetchMeDataDefinitions { definitions in
// use definitions
} onError: { error in
// handle error
}

Get MeData Definitions

Returns locally cached MeData definitions.

MeData Definition Get
// Signature
public func getMeDataDefinitions() -> [MeDataDefinition]?

// Usage
let meDataDefinitions = DataSapien.getMeDataService().getMeDataDefinitions()

Get MeData Definition by Name

Get Definition by Name
// Signature
public func getMeDataDefinitionByName(name: String) -> MeDataDefinition?

// Usage
let genderDef = DataSapien.getMeDataService().getMeDataDefinitionByName(name: "gender")

2. Medata Values

MeData Values are actual data entries tied to a user (e.g., gender = male, birthdate = 1990).

Save MeData Value

Save MeData Value
// Signature
public func saveMeDataValue(meDataContainer: MeDataContainer)

// Usage
let container = MeDataContainer(...) // define container
DataSapien.getMeDataService().saveMeDataValue(meDataContainer: container)

Save with Completion

Save with Completion
public func saveMeDataValue(meDataContainer: MeDataContainer,
onSuccess: @escaping (Bool) -> Void,
onError: ((Error) -> Void)? = nil)

Bulk Save MeData Values

Bulk Save MeData Values
public func bulkSaveMeDataValues(meDataContainers: [MeDataContainer],
onSuccess: @escaping (Bool) -> Void,
onError: ((Error) -> Void)? = nil)

Get All MeData Values

Get All MeData Values
public func getAllMeDataValue(onSuccess: @escaping ([MeData]?) -> Void,
onError: ((Error) -> Void)? = nil)

Get MeData Value by Name

Get MeData by Name
public func getMeDataValueByName(name: String) -> MeData?

Get Latest MeData Value by Name

Get Latest MeData by Name
public func getLatestMeDataValueByName(name: String) -> [String]?

Get Latest Values for Multiple MeData

Get Latest List
public func getLatestMeDataListValueByName(names: [String]) -> [String: [String]?]

Clear MeData Value by Name

Clear MeData
public func clearMeDataValueByName(name: String)