跳到主要内容

System API

System API

查询设备及系统信息。

getSystemInfoSync()

同步查询完整系统信息。

返回值:

字段类型说明
platformstring平台 ('ios' | 'android')
brandstring设备品牌
modelstring设备型号
systemstring操作系统及版本
pixelRationumber设备像素比
screenWidthnumber屏幕宽度 (px)
screenHeightnumber屏幕高度 (px)
windowWidthnumber可用窗口宽度 (px)
windowHeightnumber可用窗口高度 (px)
safeAreaSafeArea安全区域信息
languagestring语言设置
themestring主题 ('light' | 'dark')
deviceOrientationstring屏幕方向 ('portrait' | 'landscape')
SDKVersionstringSDK 版本
versionstring服务版本
environmentstring访问环境 ('prod' | 'dev')。可用于资源 CDN 地址切换等
benchmarkLevelnumber性能等级 (Android)
wifiEnabledbooleanWi-Fi 启用状态
const info = TudadaSDK.getSystemInfoSync();
console.log('平台:', info.platform);
console.log('屏幕:', info.windowWidth, 'x', info.windowHeight);
console.log('SafeArea:', info.safeArea);

getSystemInfo(options?)

异步查询完整系统信息。

选项:

参数类型必填说明
successfunction-成功回调
failfunction-失败回调
completefunction-完成回调

成功响应:

getSystemInfoSync() 的返回值相同。

TudadaSDK.getSystemInfo({
success: (res) => console.log('系统信息:', res),
});

使用提示: 使用 environment 字段可以按环境切换资源 CDN 地址。

const info = TudadaSDK.getSystemInfoSync();
const cdnBase = info.environment === 'prod'
? 'https://cdn.example.com/prod'
: 'https://cdn.example.com/dev';

getWindowInfo()

同步查询窗口/屏幕尺寸及安全区域信息。

返回值:

字段类型说明
pixelRationumber设备像素比
screenWidthnumber屏幕宽度 (px)
screenHeightnumber屏幕高度 (px)
windowWidthnumber可用窗口宽度 (px)
windowHeightnumber可用窗口高度 (px)
safeAreaSafeArea安全区域信息
const windowInfo = TudadaSDK.getWindowInfo();
console.log('SafeArea:', windowInfo.safeArea);
console.log('像素比:', windowInfo.pixelRatio);

getWindowInfoAsync(options?)

异步查询窗口/屏幕尺寸及安全区域信息。

选项:

参数类型必填说明
successfunction-成功回调
failfunction-失败回调
completefunction-完成回调

成功响应:

getWindowInfo() 的返回值相同。

SafeArea 结构:

字段类型说明
leftnumber左上角 X 坐标
topnumber左上角 Y 坐标
rightnumber右下角 X 坐标
bottomnumber右下角 Y 坐标
widthnumber安全区域宽度
heightnumber安全区域高度

getAppBaseInfo()

同步查询应用/SDK 基本信息。

返回值:

字段类型说明
SDKVersionstringSDK 版本
versionstring服务版本
themestring主题 ('light' | 'dark')
languagestring语言设置
environmentstring访问环境 ('prod' | 'dev')
const appInfo = TudadaSDK.getAppBaseInfo();
console.log('SDK 版本:', appInfo.SDKVersion);
console.log('主题:', appInfo.theme);
console.log('环境:', appInfo.environment); // 'prod' 或 'dev'

getAppBaseInfoAsync(options?)

异步查询应用/SDK 基本信息。

选项:

参数类型必填说明
successfunction-成功回调
failfunction-失败回调
completefunction-完成回调

成功响应:

getAppBaseInfo() 的返回值相同。

getDeviceInfo()

同步查询设备硬件信息。

返回值:

字段类型说明
brandstring设备品牌
modelstring设备型号
systemstring操作系统及版本
platformstring平台 ('ios' | 'android')
benchmarkLevelnumber性能等级 (Android)
const deviceInfo = TudadaSDK.getDeviceInfo();
console.log('品牌:', deviceInfo.brand);
console.log('型号:', deviceInfo.model);
console.log('性能等级:', deviceInfo.benchmarkLevel);

getDeviceInfoAsync(options?)

异步查询设备硬件信息。

选项:

参数类型必填说明
successfunction-成功回调
failfunction-失败回调
completefunction-完成回调

成功响应:

getDeviceInfo() 的返回值相同。