my.getsysteminfosync()
支小宝客户端 支持
安诊儿客户端 支持
主体: 企业支付宝小程序 、 个人支付宝小程序
同步获取手机系统信息。
如果只需获取 clientname、clientversion、language、platform 字段,推荐使用更加轻量化的 my.env api。
object
查看示例
属性 | 类型 | 兼容性 | 描述 | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pixelratio | number | - | 设备像素比。 |
|||||||||||||||||||||||||
safearea | object | 基础库: 2.7.14 ios 客户端: 10.2.20 |
在竖屏正方向下的安全区域。安卓暂不支持。 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
screenheight | number | - | 屏幕高度。单位:px。 |
|||||||||||||||||||||||||
screenwidth | number | - | 屏幕宽度。单位:px。 |
|||||||||||||||||||||||||
screen | object | 支付宝: 10.2.0 |
屏幕宽度和高度。 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
statusbarheight | number | - | 状态栏高度。单位:px。 |
|||||||||||||||||||||||||
titlebarheight | number | - | 标题栏高度。单位:px。 |
|||||||||||||||||||||||||
windowwidth | number | - | 可使用窗口宽度。单位:px。 |
|||||||||||||||||||||||||
windowheight | number | - | 可使用窗口高度。 单位:px。 |
|||||||||||||||||||||||||
locationenabled | boolean | 支付宝: 10.2.0 |
地理位置的系统开关。 |
|||||||||||||||||||||||||
wifienabled | boolean | 支付宝: 10.2.0 |
wi-fi 的系统开关。 |
|||||||||||||||||||||||||
performance | string | 安卓客户端: 10.1.62 |
设备性能等级(仅 android 有效)。 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
brand | string | - | 手机品牌。 |
|||||||||||||||||||||||||
model | string | - | 手机型号。具体可参考 手机型号与 my.getsysteminfo 返回的 model 值对照表。 |
|||||||||||||||||||||||||
system | string | - | 系统版本。 |
|||||||||||||||||||||||||
platform | string | - | 系统名:android,ios / iphone os,harmony。 |
|||||||||||||||||||||||||
language | string | - | 支付宝设置的语言。 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
version | string | - | 支付宝客户端版本号。 |
|||||||||||||||||||||||||
albumauthorized | boolean | ios 客户端: 10.2.0 |
允许支付宝使用相册的开关 (仅 ios 有效)。 |
|||||||||||||||||||||||||
cameraauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝使用摄像头的开关。 |
|||||||||||||||||||||||||
locationauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝使用定位的开关。 |
|||||||||||||||||||||||||
microphoneauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝使用麦克风的开关。 |
|||||||||||||||||||||||||
notificationauthorized | boolean | 支付宝: 10.2.0 |
允许支付宝通知的开关。暂时仅支持安卓。 |
|||||||||||||||||||||||||
app | string | - | 当前运行的客户端。若当前为支付宝,则有效值为 'alipay'。 |
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
fontsizesetting | number | - | 用户设置字体大小。单位:px。 |
|||||||||||||||||||||||||
isiphonexseries | boolean | 基础库: 2.6.0 |
是否 iphonex 系列。 |
|||||||||||||||||||||||||
transparenttitle | boolean | 支付宝: 10.1.60 |
透明状态栏。 |
|||||||||||||||||||||||||
overlayauthorized | boolean | - | 允许支付宝使用悬浮窗的开关(仅 android 有效)。 |
|||||||||||||||||||||||||
storage | string | - | 设备磁盘容量。 |
|||||||||||||||||||||||||
currentbattery | string | - | 当前电量百分比。 |
接口调用出错时,返回 object 对象,error
属性为错误码,errormessage
属性为错误消息。
错误码 | 错误消息 | 凯发app官方网站的解决方案 |
---|---|---|
999 | "system error: return undefined" |
同步调用超时。可改用 my.getsysteminfo 获取数据。 |
const systeminfo = my.getsysteminfosync();
console.log(systeminfo);
{
"apilevel": 31,
"app": "alipay",
"appmode": "normal",
"bluetoothenabled": true,
"bluetoothauthorized": true,
"brand": "redmi",
"cameraauthorized": true,
"currentbattery": "56%",
"fontsizesetting": 16,
"isiphonexseries": false,
"language": "zh-hans",
"locationauthorized": true,
"locationenabled": false,
"microphoneauthorized": false,
"model": "xiaomi m2012k11ac",
"notificationauthorized": true,
"overlayauthorized": false,
"performance": "high",
"pixelratio": 2.75,
"platform": "android",
"screen": {
"height": 828,
"width": 393
},
"screenheight": 2276,
"screenwidth": 1080,
"statusbarheight": 30,
"storage": "242 gb",
"system": "12",
"titlebarheight": 48,
"transparenttitle": false,
"version": "10.3.50.8100",
"wifienabled": false,
"windowheight": 725,
"windowwidth": 393
}
{
"error": 999,
"errormessage": "system error: return undefined"
}
-
bugmy.getsysteminfosync 中 screenwidth 和 screenheight 在安卓端取值不对,android 少除了 pixelratio,推荐使用 screen.width 和 screen.height 代替。