System API
System API
Retrieves device and system information.
getSystemInfoSync()
Synchronously retrieves full system information.
Return Value:
| Field | Type | Description |
|---|---|---|
platform | string | Platform ('ios' | 'android') |
brand | string | Device brand |
model | string | Device model |
system | string | OS and version |
pixelRatio | number | Device pixel ratio |
screenWidth | number | Screen width (px) |
screenHeight | number | Screen height (px) |
windowWidth | number | Available window width (px) |
windowHeight | number | Available window height (px) |
safeArea | SafeArea | Safe area information |
language | string | Language setting |
theme | string | Theme ('light' | 'dark') |
deviceOrientation | string | Screen orientation ('portrait' | 'landscape') |
SDKVersion | string | SDK version |
version | string | Service version |
environment | string | Access environment ('prod' | 'dev'). Can be used for switching resource CDN addresses, etc. |
benchmarkLevel | number | Performance level (Android) |
wifiEnabled | boolean | Wi-Fi enabled status |
const info = TudadaSDK.getSystemInfoSync();
console.log('Platform:', info.platform);
console.log('Screen:', info.windowWidth, 'x', info.windowHeight);
console.log('SafeArea:', info.safeArea);
getSystemInfo(options?)
Asynchronously retrieves full system information.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
Same as the return value of getSystemInfoSync().
TudadaSDK.getSystemInfo({
success: (res) => console.log('System info:', res),
});
Tip: You can use the
environmentfield to switch resource CDN addresses per environment.const info = TudadaSDK.getSystemInfoSync();
const cdnBase = info.environment === 'prod'
? 'https://cdn.example.com/prod'
: 'https://cdn.example.com/dev';
getWindowInfo()
Synchronously retrieves window/screen size and SafeArea information.
Return Value:
| Field | Type | Description |
|---|---|---|
pixelRatio | number | Device pixel ratio |
screenWidth | number | Screen width (px) |
screenHeight | number | Screen height (px) |
windowWidth | number | Available window width (px) |
windowHeight | number | Available window height (px) |
safeArea | SafeArea | Safe area information |
const windowInfo = TudadaSDK.getWindowInfo();
console.log('SafeArea:', windowInfo.safeArea);
console.log('Pixel ratio:', windowInfo.pixelRatio);
getWindowInfoAsync(options?)
Asynchronously retrieves window/screen size and SafeArea information.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
Same as the return value of getWindowInfo().
SafeArea Structure:
| Field | Type | Description |
|---|---|---|
left | number | Top-left X coordinate |
top | number | Top-left Y coordinate |
right | number | Bottom-right X coordinate |
bottom | number | Bottom-right Y coordinate |
width | number | Safe area width |
height | number | Safe area height |
getAppBaseInfo()
Synchronously retrieves app/SDK basic information.
Return Value:
| Field | Type | Description |
|---|---|---|
SDKVersion | string | SDK version |
version | string | Service version |
theme | string | Theme ('light' | 'dark') |
language | string | Language setting |
environment | string | Access environment ('prod' | 'dev') |
const appInfo = TudadaSDK.getAppBaseInfo();
console.log('SDK version:', appInfo.SDKVersion);
console.log('Theme:', appInfo.theme);
console.log('Environment:', appInfo.environment); // 'prod' or 'dev'
getAppBaseInfoAsync(options?)
Asynchronously retrieves app/SDK basic information.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
Same as the return value of getAppBaseInfo().
getDeviceInfo()
Synchronously retrieves device hardware information.
Return Value:
| Field | Type | Description |
|---|---|---|
brand | string | Device brand |
model | string | Device model |
system | string | OS and version |
platform | string | Platform ('ios' | 'android') |
benchmarkLevel | number | Performance level (Android) |
const deviceInfo = TudadaSDK.getDeviceInfo();
console.log('Brand:', deviceInfo.brand);
console.log('Model:', deviceInfo.model);
console.log('Benchmark level:', deviceInfo.benchmarkLevel);
getDeviceInfoAsync(options?)
Asynchronously retrieves device hardware information.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
Same as the return value of getDeviceInfo().