Skip to main content

React Native MeData Service

info

This documentation is for React Native SDK 2.1.x

Functions

saveMeDataRecord

saveMeDataRecord(name: string, value: string): Promise<boolean>

Saves a new MeData record for the given definition name with the provided value.

Parameters:

  • name: string — MeData definition name (for example "daily_steps").
  • value: string — Value to be stored for the definition.

getMeDataDefinitions

getMeDataDefinitions(): Promise<MeDataDefinition[]>

Returns all MeData definitions.

Parameters: None.

getMeDataDefinition

getMeDataDefinition(name: string): Promise<MeDataDefinition | null>

Returns a single MeData definition by its name, or null if it is not found.

Parameters:

  • name: string — The unique MeData definition name (for example "daily_steps").

getMeDataCategories

getMeDataCategories(): Promise<MeDataCategory[]>

Returns all MeData categories.

Parameters: None.

getMeDataDefinitionsByCategory

getMeDataDefinitionsByCategory(name: string): Promise<MeDataDefinition[]>

Returns MeData definitions for the given category name.

Parameters:

  • name: string — Category name to filter MeData definitions.

getMeDataRecords

getMeDataRecords(name: string): Promise<MeDataRecord[]>

Returns all stored records for the given MeData definition name.

Parameters:

  • name: string — MeData definition name whose records should be fetched.

getLastMeDataRecord

getLastMeDataRecord(name: string): Promise<MeDataRecord | null>

Returns the most recent MeData record for the given definition name, or null if there is no record.

Parameters:

  • name: string — MeData definition name whose latest record should be returned.

collectMeData

collectMeData(meDataDefinitionNames: string[]): Promise<Record<string, MeDataRecord>>

Triggers MeData collectors for the given definition names and returns an object mapping each definition name to its collected record.

Parameters:

  • meDataDefinitionNames: string[] — Array of MeData definition names to collect.

getAggregatedMeDataRecord

getAggregatedMeDataRecord(
name: string,
startDate: number,
endDate: number,
aggregation: Aggregation,
aggregationInterval?: AggregationInterval
): Promise<AggregatedMeDataRecord>

Aggregates the numeric MeData records in the given date range into a single record. When aggregationInterval is provided, values are first reduced per interval window using the interval's own aggregation, and aggregation is then applied over the interval results. A record is always returned; its value is null when the range holds no numeric data.

Parameters:

  • name: string — MeData definition name. The definition must be of NUMBER data type.
  • startDate: number — Start of the range (epoch milliseconds).
  • endDate: number — End of the range (epoch milliseconds).
  • aggregation: Aggregation — Aggregation applied over the range ("SUM", "AVG", "MIN" or "MAX").
  • aggregationInterval?: AggregationInterval — Optional windowing; seconds must be greater than 0.

getAggregatedMeDataRecordIntervals

getAggregatedMeDataRecordIntervals(
name: string,
startDate: number,
endDate: number,
aggregationInterval: AggregationInterval
): Promise<AggregatedMeDataRecord[]>

Splits the given date range into windows of aggregationInterval.seconds and returns one aggregated record per window. Every window in the range is present in the result, in ascending order; windows that hold no numeric record carry a null value.

Parameters:

  • name: string — MeData definition name. The definition must be of NUMBER data type.
  • startDate: number — Start of the range (epoch milliseconds).
  • endDate: number — End of the range (epoch milliseconds).
  • aggregationInterval: AggregationInterval — Window length and the aggregation applied inside each window; seconds must be greater than 0.

showMeDataView

showMeDataView(): Promise<boolean>

Presents the SDK-provided MeData view.

Parameters: None.

deleteMeData

deleteMeData(name: string): Promise<boolean>

Deletes all records of the MeData definition with the given name.

Parameters:

  • name: string — MeData definition name.

deleteMeDataRecord

deleteMeDataRecord(name: string, id: string): Promise<boolean>

Deletes a single MeData record by its identifier.

Parameters:

  • name: string — MeData definition name.
  • id: string — Identifier of the record to delete.

Classes

MeDataDefinition

{
id: string;
name: string;
text: string;
source: string;
script?: Script | null;
valueDef?: ValueDefinition | null;
category?: MeDataCategory | null;
iconUrl?: string | null;
description?: string | null;
sharable?: boolean | null;
hidden?: boolean | null;
storageSettings?: MeDataStorageSettings | null;
question?: Question | null;
}

MeDataStorageSettings

{
onlyIfChanged?: boolean | null;
longLimit?: number | null;
}

DataType

"STRING" | "NUMBER" | "BOOLEAN" | "DATETIME" | "IMAGE" | "VIDEO" | "OBJECT" | "UNKNOWN" | null

EnumeratedValue

{
id: string;
name: string;
text: string;
description?: string | null;
imageUrl?: string | null;
}

EnumeratedValueConstraints

{
allowNone?: boolean | null;
allowIdk?: boolean | null;
allowNa?: boolean | null;
allowOther?: boolean | null;
}

MeDataCategory

{
id: string;
text: string;
name: string;
iconUrl?: string | null;
description?: string | null;
}

MeDataType

"NATIVE" | "QA" | "SCRIPT" | "INFERRED" | "UNKNOWN"

Question

{
id: string;
name: string;
text: string;
description?: string | null;
imageUrl?: string | null;
}

QuestionDefinition

{
valueDef: ValueDefinition;
question: Question;
isMeData: boolean;
contextKey: string;
}

ValueDefinition

{
type: string;
constraints?: ValueTypeConstraints | null;
multivalued?: boolean | null;
multiValueConstraints?: MultiValueConstraints | null;
enumerated?: boolean | null;
enumeratedValues?: EnumeratedValue[] | null;
enumeratedValueConstraints?: EnumeratedValueConstraints | null;
}

ValueTypeConstraints

{
minValue?: number | null;
maxValue?: number | null;
regex?: string | null;
allowCamera?: boolean | null;
allowGallery?: boolean | null;
}

MultiValueConstraints

{
minValue: number;
maxValue: number;
}

MeData

{
id: string;
definitionName: string;
records: MeDataRecord[];
}

MeDataRecord

{
id: string;
meDataDefinitionId: string;
notAvailable: boolean;
date: number;
values: MeDataValue[];
}

MeDataValue

{
id: string;
evName?: string | null;
value: string;
}

AggregatedMeDataRecord

{
startDate: number; // epoch ms
endDate: number; // epoch ms
value: number | null; // null = no data in the range/window, not a measured 0
}

AggregationInterval

{
seconds: number; // window length, must be greater than 0
aggregation: Aggregation; // applied inside each window
}

Aggregation

"SUM" | "AVG" | "MIN" | "MAX"