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.
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.
- For
Native
sourced collection, MeData Service will execute the code it provides out of the box - For
Script
sourced collection; MeData Service will execute the script authered on Orchestrator - For
VC
sourced collection, MeData Service will access targeted VC from Wallet Service - 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.
- Swift
- Kotlin
// 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
}
// TBD...
Get MeData Definitions
Returns locally cached MeData definitions.
- Swift
- Kotlin
// Signature
public func getMeDataDefinitions() -> [MeDataDefinition]?
// Usage
let meDataDefinitions = DataSapien.getMeDataService().getMeDataDefinitions()
// TBD...
Get MeData Definition by Name
- Swift
- Kotlin
// Signature
public func getMeDataDefinitionByName(name: String) -> MeDataDefinition?
// Usage
let genderDef = DataSapien.getMeDataService().getMeDataDefinitionByName(name: "gender")
// TBD...
2. Medata Values
MeData Values are actual data entries tied to a user (e.g., gender = male, birthdate = 1990).
Save MeData Value
- Swift
- Kotlin
// Signature
public func saveMeDataValue(meDataContainer: MeDataContainer)
// Usage
let container = MeDataContainer(...) // define container
DataSapien.getMeDataService().saveMeDataValue(meDataContainer: container)
// TBD...
Save with Completion
- Swift
- Kotlin
public func saveMeDataValue(meDataContainer: MeDataContainer,
onSuccess: @escaping (Bool) -> Void,
onError: ((Error) -> Void)? = nil)
// TBD...
Bulk Save MeData Values
- Swift
- Kotlin
public func bulkSaveMeDataValues(meDataContainers: [MeDataContainer],
onSuccess: @escaping (Bool) -> Void,
onError: ((Error) -> Void)? = nil)
// TBD...
Get All MeData Values
- Swift
- Kotlin
public func getAllMeDataValue(onSuccess: @escaping ([MeData]?) -> Void,
onError: ((Error) -> Void)? = nil)
// TBD...
Get MeData Value by Name
- Swift
- Kotlin
public func getMeDataValueByName(name: String) -> MeData?
// TBD...
Get Latest MeData Value by Name
- Swift
- Kotlin
public func getLatestMeDataValueByName(name: String) -> [String]?
// TBD...
Get Latest Values for Multiple MeData
- Swift
- Kotlin
public func getLatestMeDataListValueByName(names: [String]) -> [String: [String]?]
// TBD...
Clear MeData Value by Name
- Swift
- Kotlin
public func clearMeDataValueByName(name: String)
// TBD...