API
Basics
bn.getSystemInfo
Return Values
Object res
Property | Type | Example | Description |
---|---|---|---|
brand | string | "Apple" "Xiaomi" | Device brand |
model | string | Device model | |
pixelRatio | number | Device's pixel ratio | |
screenWidth | number | Screen width in px | |
screenHeight | number | Screen height in px | |
windowWidth | number | Available window width in px | |
windowHeight | number | Available window height in px | |
statusBarHeight | number | Status bar height in px | |
language | string | Language set in App | |
version | string | App version | |
SDKVersion | string | Base library version for the App version | |
system | string | Operating system and version | |
platform | string | "ios" "android" | Client platform |
safeArea | Object | Safe area when the screen is in vertical orientation platform |
res.safeArea
Property | Type | Description |
---|---|---|
left | number | The x-coordinate of the top-left corner of the safe area |
right | number | The x-coordinate of the bottom-right corner of the safe area |
top | number | The y-coordinate of the top-left corner of the safe area |
bottom | number | The y-coordinate of the bottom-right corner of the safe area |
width | number | Safe area width in logical pixels |
height | number | Safe area height in logical pixels |
bn.getLaunchOptionsSync
Obtains the parameters upon Mini Game startup.
Return Values
Object res Startup parameters
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
scene | number | - | - | The scene value for Mini Game startup |
query | Object | - | - | The query parameter for Mini Game startup |
referrerInfo | Object | - | - | The source information. This is returned when a user enters the Mini Program from another Mini Program, Official Account, or app. Otherwise, {} is returned. (see the Note below for details.) |
referrerInfo is composed as follows
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
appId | string | - | - | The appId of the source Mini Program, Official Account, or app. |
extraData | Object | - | - |
bn.getEnterOptionsSync
Gets the parameters when the applet starts. If the current startup is cold, the return value is the same as the callback parameter for bn.getLaunchOptionsSync
; If the current is a hot start, the return value is the same as bn.onShow
.
Return Values
Object res Startup parameters
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
scene | number | - | - | The scene value for Mini Game startup |
query | Object | - | - | The query parameter for Mini Game startup |
referrerInfo | Object | - | - | The source information. This is returned when a user enters the Mini Program from another Mini Program, Official Account, or app. Otherwise, {} is returned. (see the Note below for details) |
referrerInfo is composed as follows
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
appId | string | - | - | The appId of the source Mini Program, Official Account, or app. |
extraData | Object | - | - |
bn.onUnhandledRejection
Listen for unhandled Promise
rejection events.
Parameters
function callback
Callback function for unhandled Promise
rejection event.
function parameters
Object res
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
reason | string | - | Reason for rejection, usually an Error object | |
promise | Promise.<any> | - | scene code |
Notes
All unhandledRejection
can be captured by this monitor, but only the Error
type will trigger an alarm in the background of the applet.
bn.onError
Listens on the Mini Game error event. This event is triggered as a result of script error or failed API call.
Parameters
function callback
The callback function for the Mini Game error event.
Parameters
string error Error message, including stacks.
bn.onShow
Listens on the event that Mini Game is switched to foreground.
Parameters
function callback
The callback function for the event that Mini Game is switched to foreground.
Parameters
Object res
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
scene | number | - | - | The scene value for Mini Game startup |
query | Object | - | - | The query parameter for Mini Game startup |
referrerInfo | Object | - | - | The source information. This is returned when a user enters the Mini Program from another Mini Program, Official Account, or app. Otherwise, {} is returned. (see the Note below for details.) |
referrerInfo is composed as follows
Property | Type | Default Value | Required | Description |
---|---|---|---|---|
appId | string | - | - | The appId of the source Mini Program, Official Account, or app. |
extraData | Object | - | - |
Notes
In some versions, when there is no referrerInfo
, the value undefined is returned. You can use options.referrerInfo && options.referrerInfo.appId
to make a judgment.
bn.offHide
Listens on the event that Mini Game is switched to background.
Parameters
function callback
The callback function for the event that Mini Game is switched to background.
bn.offUnhandledRejection
Cancel listening for unhandled Promise rejection events.
Parameters
function callback
Callback function for unhandled Promise rejection event.
bn.offError
Un-listens on Mini Game error event.