System
Retrieves device and system information, which is essential for creating responsive layouts, optimizing rendering, and tailoring user experiences. The API is available in both synchronous and asynchronous versions to suit different use cases.
TTMinis.game.getSystemInfoSync()
Gets system information synchronously.
Returns
Field | Type | Description |
|
| Screen width, in px |
|
| Screen height, in px |
|
| Available window width, in px |
|
| Available window height, in px |
|
| Device pixel ratio |
|
| Device pixel ratio |
|
| Device orientation |
|
| Operating system and version |
|
| Client platform. Valid values: |
|
| Status bar height |
|
| Language |
|
| Safe area in portrait orientation |
|
| SDK version |
|
| Client version number |
Example
try {
const res = TTMinis.game.getSystemInfoSync()
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
}TTMinis.game.getSystemInfo(opts)
Gets system information asynchronously.
Parameters
Field | Type | Description | Required |
|
| Callback function called when the API call succeeds | No |
|
| Callback function called when the API call fails | No |
|
| Callback function called when the API call ends (called on both success and failure) | No |
Success callback parameters
Field | Type | Description |
|
| Screen width, in px |
|
| Screen height, in px |
|
| Available window width, in px |
|
| Available window height, in px |
|
| Device pixel ratio |
|
| Device pixel ratio |
|
| Device orientation |
|
| Operating system and version |
|
| Client platform. Valid values: |
|
| Status bar height |
|
| Language |
|
| Safe area in portrait orientation |
|
| SDK version |
|
| Client version number |
Example
TTMinis.game.getSystemInfo({
success (res) {
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
}
})TTMinis.game.getWindowInfo()
Note: Supported starting from SDK version 0.2.0. Lower versions must be adjusted for compatibility.
Gets window information synchronously.
Returns
Field | Type | Description |
|
| Device pixel ratio |
|
| Screen width, in px |
|
| Screen height, in px |
|
| Available window width, in px |
|
| Available window height, in px |
|
| Status bar height, in px |
|
| Safe area in portrait orientation. Some devices do not have a safe area concept and will not return the |
|
| The y-coordinate of the top edge of the window |
Example
const windowInfo = TTMinis.game.getWindowInfo()
console.log(windowInfo.pixelRatio)
console.log(windowInfo.screenWidth)
console.log(windowInfo.screenHeight)
console.log(windowInfo.windowWidth)
console.log(windowInfo.windowHeight)
console.log(windowInfo.statusBarHeight)
console.log(windowInfo.safeArea)
console.log(windowInfo.screenTop)