my.getDeviceInfo retrieves essential device information and the current user's role in the Super Qi app. This JSAPI plays a critical role in enabling developers to build Miniapps that serve both Customer and Business users effectively.
The most important value returned by this API is currentRole, which indicates whether the logged-in user is a:
customer - An individual consumer using the Super Qi appbusiness - A merchant/business account using the Super Qi appBy checking the currentRole, your Miniapp can dynamically adapt its behavior, UI, and authorization flows to match the user type. For example:
currentRole is "customer", call my.getAuthCode with Customer User ScopescurrentRole is "business", call my.getAuthCode with Business (Merchant) User ScopesThis allows you to build a single Miniapp that seamlessly works for both B2C and B2B scenarios.
my.getDeviceInfo({
success: (res) => {
my.alert({
content: res.currentRole,
});
},
fail: (res) => {
console.log('getDeviceInfo call failed: ', JSON.stringify(res));
my.alert({
content: JSON.stringify(res),
});
},
});
AlipayJSBridge.call(
"getDeviceInfo",
{},
function (data) {
console.log(data);
}
);
| Property | Type | Required | Description |
|---|---|---|---|
success | Function | No | Callback executed when the API call succeeds. Provides the payload defined in Callback payload. |
fail | Function | No | Callback executed when the API call fails. |
complete | Function | No | Callback executed after success or failure. |
| Property | Type | Description |
|---|---|---|
language | string | The user's preferred language (e.g., "en-US"). |
isProdEnv | string | Indicates if the app is running in production environment ("true" or "false"). |
currentRole | string | The role of the current user. Possible values: "customer" (individual consumer) or "business" (merchant/business account). |
systemInfo | string | Operating system information (e.g., "Android 15", "iOS 16"). |
hardwareInfo | string | Device hardware model information (e.g., "HONOR_PGT-AN00"). |
loginTime | string | Timestamp indicating when the user logged in (in milliseconds). |
{
"language": "en-US",
"isProdEnv": "true",
"currentRole": "customer",
"systemInfo": "Android 15",
"hardwareInfo": "HONOR_PGT-AN00",
"loginTime": "360307579"
}
{
"language": "en-US",
"isProdEnv": "true",
"currentRole": "business",
"systemInfo": "Android 15",
"hardwareInfo": "HONOR_PGT-AN00",
"loginTime": "360307579"
}