Skip to main content
版本:v3+

checkSensor

API_LEVEL 3.0 开始支持,API 兼容性请参考 API_LEVEL

检查传感器在当前设备的可用性。

类型

function checkSensor(sensor: Sensor): Result

参数

Sensor

类型说明
object传感器,比如检查定位传感器是否可用,传入 Geolocation 传感器构造函数

Result

类型说明
booleantrue - 传感器在当前设备可用,false - 传感器在当前设备不可用

代码示例

import { checkSensor, Geolocation } from '@zos/sensor'

const result = checkSensor(Geolocation)
let geolocation = null

if (result) {
geolocation = new Geolocation()
}