bl.getSystemInfoAsync(Object object)
iOS 和 Android App 9.19.0 起支持,低版本需做兼容处理。
异步获取系统信息。在不支持异步获取的客户端上,会使用同步实现返回结果。
仅支持回调方式调用,不支持 Promise 风格调用。
按需获取信息时,也可使用 bl.getSystemSetting、bl.getAppAuthorizeSetting、bl.getDeviceInfo、bl.getWindowInfo 和 bl.getAppBaseInfo。
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数,成功或失败都会执行 |
object.success 回调参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| brand | string | 设备品牌 |
| model | string | 设备型号,新机型刚推出时可能返回 unknown。 |
| pixelRatio | number | 设备像素比 |
| screenWidth | number | 屏幕宽度,单位px |
| screenHeight | number | 屏幕高度,单位px |
| windowWidth | number | 可使用窗口宽度,单位px |
| windowHeight | number | 可使用窗口高度,单位px |
| statusBarHeight | number | 状态栏的高度,单位px |
| language | string | 哔哩哔哩 App 设置的语言。 |
| version | string | 哔哩哔哩 App 版本号。 |
| system | string | 操作系统及版本 |
| platform | string | 客户端平台,ios 为 iOS,android 为 Android。 |
| fontSizeSetting | number | 用户字体大小,单位为 px。 |
| SDKVersion | string | 客户端基础库版本 |
| benchmarkLevel | number | 设备性能等级(仅 Android 支持)。-2 或 0 表示设备无法运行小游戏,-1 表示性能未知,>= 1 为性能值,越高性能越好。仅反馈真机性能,暂不支持 IDE 模拟器机型。 |
| albumAuthorized | boolean | 允许哔哩哔哩使用相册的开关(仅 iOS 有效) |
| cameraAuthorized | boolean | 允许哔哩哔哩使用摄像头的开关 |
| locationAuthorized | boolean | 允许哔哩哔哩使用定位的开关 |
| microphoneAuthorized | boolean | 允许哔哩哔哩使用麦克风的开关 |
| notificationAuthorized | boolean | 允许哔哩哔哩通知的开关 |
| notificationAlertAuthorized | boolean | 允许哔哩哔哩通知带有提醒的开关(仅 iOS 有效) |
| notificationBadgeAuthorized | boolean | 允许哔哩哔哩通知带有标记的开关(仅 iOS 有效) |
| notificationSoundAuthorized | boolean | 允许哔哩哔哩通知带有声音的开关(仅 iOS 有效) |
| phoneCalendarAuthorized | boolean | 允许哔哩哔哩使用日历的开关 |
| bluetoothEnabled | boolean | 蓝牙的系统开关 |
| locationEnabled | boolean | 地理位置的系统开关 |
| wifiEnabled | boolean | Wi-Fi 的系统开关 |
| safeArea | Object | 在竖屏正方向下的安全区域。部分机型没有安全区域概念,也不会返回 safeArea 字段,开发者需自行兼容。 |
| locationReducedAccuracy | boolean | true 表示模糊定位,false 表示精确定位(仅 iOS 支持)。 |
| theme | string | 系统当前主题,dark 为深色,light 为浅色。该字段不支持小游戏。 |
| host | Object | 当前运行的宿主环境。 |
| enableDebug | boolean | 是否已打开调试,可通过右上角菜单或 bl.setEnableDebug 打开。 |
| deviceOrientation | string | 设备方向,portrait 为竖屏,landscape 为横屏。iOS 横屏游戏中返回值可能不准确,建议根据屏幕宽高判断。 |
safeArea 的结构
| 属性 | 类型 | 说明 |
|---|---|---|
| left | number | 安全区域左上角横坐标 |
| right | number | 安全区域右下角横坐标 |
| top | number | 安全区域左上角纵坐标 |
| bottom | number | 安全区域右下角纵坐标 |
| width | number | 安全区域的宽度,单位逻辑像素 |
| height | number | 安全区域的高度,单位逻辑像素 |
host 的结构
| 属性 | 类型 | 说明 |
|---|---|---|
| appId | string | 宿主 App 对应的 appId。 |
示例代码
bl.getSystemInfoAsync({
success (res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
}
})