# ks.getSystemInfo

# ks.getSystemInfo(Object object)

异步获取平台基础信息。

# 参数

Object object

属性 类型 必填 说明 最低版本
success function 回调函数
fail function 回调函数
complete function 回调函数

object.success 回调函数

参数

Object res

属性 类型 说明 最低版本
brand string 设备品牌
model string 设备型号
pixelRatio number 设备像素比
screenWidth number 屏幕宽度,单位px
screenHeight number 屏幕高度,单位px
windowWidth number 可使用窗口宽度,单位px
windowHeight number 可使用窗口高度,单位px
statusBarHeight number 状态栏的高度,单位px
language string 快手设置的语言
version string 快手小游戏版本号
system string 操作系统及版本
platform string 客户端平台
albumAuthorized boolean 允许使用相册的开关(仅 iOS 有效)
cameraAuthorized boolean 允许使用摄像头的开关
locationAuthorized boolean 允许使用定位的开关
microphoneAuthorized boolean 允许使用麦克风的开关
notificationAuthorized boolean 允许通知的开关
notificationAlertAuthorized boolean 允许通知带有提醒的开关(仅 iOS 有效)
notificationBadgeAuthorized boolean 允许通知带有标记的开关(仅 iOS 有效)
notificationSoundAuthorized boolean 允许通知带有声音的开关(仅 iOS 有效)
bluetoothEnabled boolean 蓝牙的系统开关
locationEnabled boolean 地理位置的系统开关
wifiEnabled boolean Wi-Fi 的系统开关
safeArea Object 在竖屏正方向下的安全区域
host Object 当前小游戏运行的宿主环境

safeArea的结构

属性 类型 说明 最低版本
left number 安全区域左上角横坐标
right number 安全区域右下角横坐标
top number 安全区域左上角纵坐标
bottom number 安全区域右下角纵坐标
width number
height number

host 的结构

属性 类型 说明
appId string 宿主 app 对应的 appId
env string 哪种快手app,有快手,快手极速版,和快看点三个值
gameVersion string 游戏版本

deviceOrientation 的合法值

说明 最低版本
'portrait' 竖屏
'landscape' 横屏

# 示例代码

ks.getSystemInfo({
  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)
  }
})
try {
  const res = ks.getSystemInfoSync()
  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)
} catch (e) {
  // Do something when catch error
}