智能客服
你问我答,随时在线为你解决问题
从1078版本开始,接口前缀由hbs调整为qg,原hbs仍支持。
接口 | 描述 |
|---|---|
获取系统信息。 | |
获取系统信息(同步方法)。 | |
判断当前客户端是否支持某个能力。 |
获取手机的系统信息。
参数 | 类型 | 必填(M)/选填(O) | 说明 |
|---|---|---|---|
success | function | O | 接口调用成功的回调函数,详情请参见success回调函数参数。 |
fail | function | O | 接口调用失败的回调函数。 |
complete | function | O | 若有函数传入,将在成功、失败后调用该函数。 |
参数 | 类型 | 说明 |
|---|---|---|
brand | string | 手机品牌。 |
model | string | 手机型号。 |
pixelRatio | number | 设备像素比。 说明 为确保获取的pixelRatio和safeArea相匹配,需将minPlatformVersion配置1078及以上版本。 |
screenWidth | number | 屏幕宽度。 |
screenHeight | number | 屏幕高度。 |
windowWidth | number | 可使用窗口宽度。 |
windowHeight | number | 可使用窗口高度。 |
language | string | 系统语言。 |
region | string | 系统地区。 |
script | string | 系统语言书写方式。 |
coreVersion | string | 渲染引擎版本号。 |
COREVersion | string | 渲染引擎版本号。 |
system | string | 操作系统版本。 |
platform | string | 客户端平台。 说明 若返回值为“HarmonyOS”,表示当前客户端平台所在的操作系统版本为HarmonyOS 5.0及以上;若返回其他值,则表示当前客户端平台所在的操作系统版本为HarmonyOS 3.1/4.0及以下。 |
version | string | 快应用中心版本。 |
statusBarHeight | number | 状态栏高度,以屏幕的实际分辨率为单位。 |
platformVersionName | string | 运行平台版本名称。 说明 若快游戏minPlatformVersion在1078及以上版本,才会返回当前字段。 |
platformVersionCode | number | 运行平台标准版本号。 说明 若快游戏minPlatformVersion在1078及以上版本,才会返回当前字段。 |
safeArea | object | 在竖屏正方向下的安全区域,详情可参见safeArea参数。 说明 若快游戏minPlatformVersion在1078及以上版本,才会返回当前字段。 |
属性 | 类型 | 说明 |
|---|---|---|
bottom | number | 安全区域右下角纵坐标。 |
left | number | 安全区域左上角横坐标。 |
right | number | 安全区域右下角横坐标。 |
top | number | 安全区域左上角纵坐标。 |
height | number | 安全区域的高度,大小为实际高度(以px为单位)/设备屏幕密度。 |
width | number | 安全区域的宽度,大小为实际宽度(以px为单位)/设备屏幕密度。 |
- qg.getSystemInfo({
- success(res) {
- console.log("on getSystemInfo: success =" + JSON.stringify(res));
- },
- fail() {
- console.log("on getSystemInfo: fail");
- },
- complete() {
- console.log("on getSystemInfo: complete");
- }
- });
- "brand":"HUAWEI",
- "model":"C*T-A**0",
- "pixelRatio":3,
- "screenWidth":360,
- "screenHeight":746.6666666666666,
- "windowWidth":360,
- "windowHeight":746.6666666666666,
- "language":"zh",
- "region":"CN",
- "script":"Hans",
- "coreVersion":"1.1.21",
- "COREVersion":"1.1.21",
- "system":"Android 10",
- "platform":"ANDROIDOS",
- "version":"3.6.1.2",
- "statusBarHeight":0,
- "platformVersionName":"1.106",
- "platformVersionCode":1106,
- "safeArea":{
- "bottom":746.6666666666666,
- "left":0,
- "right":360,
- "top":0,
- "height":746.6666666666666,
- "width":360
- }
获取系统信息(同步方法)。
详情可参见success回调函数参数。
- var res = qg.getSystemInfoSync();
- console.log("on getSystemInfoSync: success =" + JSON.stringify(res));
判断当前客户端是否支持某个能力。
参数 | 类型 | 必填(M)/选填(O) | 说明 |
|---|---|---|---|
capability | string | M | 能力名称,取值如下:
|
- if (typeof qg.canIUse === 'function') {
- const isSupportNearbyPlaying = qg.canIUse('MiniGame.NearbyPlaying');
- console.log('isSupportNearbyPlaying: ' + isSupportNearbyPlaying) // 是否支持近场联机特性
- const isSupportInteractiveCard = qg.canIUse('MiniGame.InteractiveCard');
- console.log('isSupportInteractiveCard: ' + isSupportInteractiveCard) // 是否支持互动卡片加桌能力
- }