Essential APIs

getDeviceInfo

Retrieve device information and the current user's role (customer or business) to build apps for different user types.

Overview

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 app
  • business - A merchant/business account using the Super Qi app

By checking the currentRole, your Miniapp can dynamically adapt its behavior, UI, and authorization flows to match the user type. For example:

This allows you to build a single Miniapp that seamlessly works for both B2C and B2B scenarios.

Usage Example

DSL

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),
    });
  },
});

H5+

AlipayJSBridge.call(
  "getDeviceInfo",
  {},
  function (data) {
    console.log(data);
  }
);

Parameters

PropertyTypeRequiredDescription
successFunctionNoCallback executed when the API call succeeds. Provides the payload defined in Callback payload.
failFunctionNoCallback executed when the API call fails.
completeFunctionNoCallback executed after success or failure.

Callback Payload

PropertyTypeDescription
languagestringThe user's preferred language (e.g., "en-US").
isProdEnvstringIndicates if the app is running in production environment ("true" or "false").
currentRolestringThe role of the current user. Possible values: "customer" (individual consumer) or "business" (merchant/business account).
systemInfostringOperating system information (e.g., "Android 15", "iOS 16").
hardwareInfostringDevice hardware model information (e.g., "HONOR_PGT-AN00").
loginTimestringTimestamp indicating when the user logged in (in milliseconds).

Success Example (Customer User)

{
  "language": "en-US",
  "isProdEnv": "true",
  "currentRole": "customer",
  "systemInfo": "Android 15",
  "hardwareInfo": "HONOR_PGT-AN00",
  "loginTime": "360307579"
}

Success Example (Business User)

{
  "language": "en-US",
  "isProdEnv": "true",
  "currentRole": "business",
  "systemInfo": "Android 15",
  "hardwareInfo": "HONOR_PGT-AN00",
  "loginTime": "360307579"
}