文档

系统 system

更新时间:
一键部署

本文介绍自定义设备面板SDK中系统信息的API调用。

背景信息

SDK的安装与API调用方法,请参考快速开始

获取系统信息

getSystemInfo

getSystemInfoSync:同步方法

请求参数

参数

参数类型

子参数

子参数类型

描述

是否必填

-

-

-

-

-

出参

参数

参数类型

子参数

子参数类型

描述

info

object

apilevel

Number

App SDK版本号

appEnv

string

App环境(内部需要关心)外部release。

appName

string

App名称,云智能:"iLop";天猫精灵:"TGenie"。

appVersion

string

App版本号。

language

string

App语言。

model

string

手机型号。

osVersion

string

系统版本。

pixelRatio

Number

设备像素比。

platform

string

手机系统平台:ios;Android。

runtime

string

容器环境,目前仅有 h5。

screenHeight

Number

屏幕高度。单位:px。screenHeight 数值在 Android系统下不准确,请用 screenHeight/pixelRatio 计算出正确的数值。

screenWidth

Number

屏幕宽度。单位:px。screenWidth 数值在 Android系统下不准确,请用 screenWidth/pixelRatio 计算出正确的数值。

sdkVersion

string

SDK版本。

statusBarHeight

Number

手机状态栏高度。

调用示例

import { system } from 'aliyun-livinglink-sdk';

// 异步方法
system.getSystemInfo().then((sysInfo)=>{
   console.log(sysInfo)
}).catch(()=>{
})

 // 同步方法
 const sysInfo = system.getSystemInfoSync();
 console.log(sysInfo)

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✔︎

订阅系统权限事件(蓝牙、定位权限)

subscribeAll

请求参数

参数

参数类型

子参数

子参数类型

描述

是否必填

-

-

-

-

-

出参

参数

参数类型

子参数

子参数类型

描述

result

object

ret

string

订阅结果

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.subscribeAll().then((res)=>{
   console.log(res)
}).catch(()=>{
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✖︎

取消订阅系统权限事件(蓝牙、定位权限)

unsubscribeAll

请求参数

参数

参数类型

子参数

子参数类型

描述

是否必填

-

-

-

-

-

出参

参数

参数类型

子参数

子参数类型

描述

result

object

ret

string

订阅结果

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.unsubscribeAll().then((res)=>{
   console.log(res)
}).catch(()=>{
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✖︎

获取蓝牙开关状态

getBlueToothEnabled

请求参数

参数

参数类型

子参数

子参数类型

描述

是否必填

-

-

-

-

-

出参

参数

参数类型

子参数

子参数类型

描述

result

object

enable

boolean

true:开启;false:关闭。

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.getBlueToothEnabled().then((res)=>{
   console.log(res)
}).catch(()=>{
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✔︎

监听蓝牙开关状态事件

onBlueToothEnabledChange

请求参数

参数

参数类型

描述

是否必填

callback

Function

蓝牙开关状态事件的回调函数

出参

参数

参数类型

子参数

子参数类型

描述

msg

object

enable

boolean

true:开启;false:关闭。

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.subscribeAll().then((res)=>{
   console.log(res)
})
// 使用此事件之前要先订阅
system.onBlueToothEnabledChange((msg)=>{
  console.log(msg)
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✖︎

获取定位权限开关状态

getLocationEnabled

请求参数

参数

参数类型

子参数

子参数类型

描述

是否必填

-

-

-

-

-

出参

参数

参数类型

子参数

子参数类型

描述

result

object

enable

boolean

true:开启;false:关闭。

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.getLocationEnabled().then((res)=>{
   console.log(res)
}).catch(()=>{
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✔︎

监听定位权限开关状态事件

onLocationEnabledChange

请求参数

参数

参数类型

描述

是否必填

callback

Function

定位权限开关状态事件的回调函数。

出参

参数

参数类型

子参数

子参数类型

描述

msg

object

enable

boolean

true:开启;false:关闭。

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.subscribeAll().then((res)=>{
   console.log(res)
})
// 使用此事件之前,要先订阅
system.onBlueToothEnabledChange((msg)=>{
  console.log(msg)
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✖︎

设置系统状态栏文字颜色

setStatusBarStyle

请求参数

参数

参数类型

描述

是否必填

barStyle

string

light-content:将状态栏文字设置成白色;

dark-content:将状态栏文字设置成黑色。

出参

参数

参数类型

子参数

子参数类型

描述

-

-

-

-

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.setStatusBarStyle('light-content')

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✔︎

获取系统网络状态

getNetworkStatus

请求参数

参数

参数类型

描述

是否必填

-

-

-

出参

参数

参数类型

子参数

子参数类型

描述

network

string

手机系统网络状态:wifi,cell,others,none,unknown。

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.getNetworkStatus().then((networkStatus)=>{
  console.log(networkStatus)
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✔︎

监听系统网络状态变化事件

onNetworkStatusChange

请求参数

参数

参数类型

描述

是否必填

callback

Function

系统网络状态变化事件的回调函数。

出参

参数

参数类型

子参数

子参数类型

描述

network

string

手机系统网络状态:wifi,cell,others,none,unknown。

调用示例

import { system } from 'aliyun-livinglink-sdk';

system.onNetworkStatusChange((networkStatus)=>{
  console.log(networkStatus)
})

API支持度

云智能

自有品牌

天猫精灵

✔︎

✔︎

✔︎

  • 本页导读 (0)
文档反馈