Skip to main content
Version: v3

getSportData

Start from API_LEVEL 3.6 . Please refer to API_LEVEL.

By default, the system will off the screen in one page of the Mini Program, and the system will exit the Mini Program after 10s, and enter the dial page when the watch is woken up again. If relaunch is set to true, the Mini Program will reopen and enter the corresponding page when the watch is woken up again.

info

permission code: data:user.hd.workout

Type

function getSportData(options: Options, callback: (callbackResult: CallbackResult) => void): Result

Parameters

Options

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
typestringY-Sports type, refer to the value of SportType3.6

CallbackResult

PropertyTypeDescriptionAPI_LEVEL
codenumberResult status code, 0 means success, non- 0 means failure3.6
datastringSports data, return value type is string, needs to be parsed using JSON.parse, the parsed type is Array<object>, the specific type of object can be referred to the SportType type description below, and the return value corresponding to each type is different3.6

Result

TypeDescription
BooleanIf it returns true, it means the call was successful, otherwise the call failed

SportType

ValueTypeDescriptionAPI_LEVEL
speedobjectSpeed, example return value {"speed": "9.99", "name": "Speed"}3.6
avg_speedobjectAverage speed, example return value {"avg_speed": "9.99", "name": "Average Speed"}3.6
paceobjectPace, example return value {"avg_pace": "1' 12" "," name ":" Average Pace "}3.6
avg_paceobjectAverage pace, example return value {"avg_pace": "1'12'", "name": "Average Pace"}3.6
distanceobjectDistance, example return value {"distance": "9.99", "name": "Distance"}3.6
durationobjectTime duration of workout, example return value {"duration":"1:15:15", "name": "Duration"}3.6
caloriesobjectConsumption, example return value {"calories": "9.99", "name": "Calories"}3.6
cadenceobjectCadence/cadence, example return value {"cadence": "9.99", "name": "Cadence"}3.6
avg_cadenceobjectAverage cadence, example return value {"avg_cadence": "9.99", "name": "Average Cadence"}3.6
altitudeobjectAltitude, example return value {"altitude": "9.99", "name": "Elevation"}3.6
total_up_altitudeobjectAccumulated elevation, example return value {"total_up_altitude": "9.99", "name": "Total Ascent"}3.6
total_countobjectTotal count, example return value {"total_count": "9.99", "name": "Total count"}3.6
vertical_speedobjectVertical Speed, example return value {"vertical_speed": "9.99", "name": "Vertical Speed"}3.6
downhill_countobjectNumber of downhills, example return value {"downhill_count": "9.99", "name": "Downhills"}3.6
total_downhill_distanceobjectCumulative downhill distance, example return value {"total_downhill_distance": "9.99", "name": "Total Downhill Distance"}3.6

Example

import { getSportData } from '@zos/app-access'

const result = getSportData(
{
type: 'distance',
},
(callbackResult) => {
const { code, data } = callbackResult
if (code === 0) {
const [{ distance }] = JSON.parse(data)
console.log(distance)
}
},
)