Skip to main content
Version: v3

Wear

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Wearing status sensor.

Methods

getStatus

Get the current device wearing status, 0: not wearing, 1: wearing, 2: in motion, 3: not sure

getStatus(): number

onChange

Register the device wear status change event listening callback function

onChange(callback: () => void): void

offChange

Cancel the device wear status change event listening callback function

offChange(callback: () => void): void

Example

import { Wear } from '@zos/sensor'

const wear = new Wear()
const status = wear.getStatus()
const callback = () => {
console.log(wear.getStatus())
}

wear.onChange(callback)

// When not needed for use
wear.offChange(callback)