Guide for developers to query the device region
Currently, there are five ways to send overseas news:
- boardcast
- alias
- gaid
- regid
- User-account
Broadcasting does not need to specify a user, so it provides the function of querying the user's region for other methods
Corresponding regional domain name:
- Singapore:https://sgp-api.xmpush.global.xiaomi.com
- India:https://idmb-api.xmpush.global.xiaomi.com
- Economic Area countries+UK:https://fr-api.xmpush.global.xiaomi.com
- Russia :https://ru-api.xmpush.global.xiaomi.com
- Mainland China :https://api.xmpush.xiaomi.com
一、Alias
- Get the RegId corresponding to an Alias of an application (take India as an example)
Formal environment
API adress:
https://idmb-api.xmpush.global.xiaomi.com/v1/alias/get_regid_by_alias
HTTP request method:GET
Add HEADER field Authorization , for authentication. The format is key=.
APP_SECRET is obtained from the developer website.
Note: Character keys must be lowercase. E.g : Authorization: key=YOUR_APP_SECRET
Table 1-a. Get Alias corresponding RegId GET
type | parameter name | Parameter Description |
Long | appId | AppId of the application. |
String | packageName | Optional. Because an AppId may correspond to multiple package names, use this parameter to specify a specific package name. |
String | aliasName | alias to be queried |
Returns a string in json format.
If successful, the returned string has the following format. (reason value is RegId)
{
"result": "ok",
"reason": "qXX5tXbsX/egM9lKDdWotd+XXXtO0njRu/+O/905Xvqpm+sXo064FAgV4A1kwXXX",
"trace_id": "Xxx00000000000000000xx",
"code": 0,
"description": "成功"
}
If it fails, the returned string has the following format.
{
"result": "error",
"reason": "Alias not found",
"trace_id": "Xxx00000000000000000xx",
"code": 22006,
"description": "应用程序Id不合法"
}
- Query Region by RegId see 2
二、Regid
- Batch query RegId registration regions (take India as an example)
Formal environment
API adress:
https://idmb-api.xmpush.global.xiaomi.com/v3/regid/get_region_by_regid
HTTP Request Method:POST
Add HEADER field Authorization, for authentication。The format is key=。
APP_SECRET is obtained from the developer website.
Note: Character keys must be lowercase. E.g :Authorization: key=YOUR_APP_SECRET
Table 1-a. Get POST of Alias corresponding RegId
type | parameter name | Parameter Description |
String | regIds | regId list, multiple regIds are separated by commas |
Returns a string in json format.
If successful, the returned string format is as follows.
Region enumeration
Russia
India
China
Europe
Singapore
{
"result": "ok",
"trace_id": "Xxx00000000000000000xx",
"code": 0,
"data": {
"XjeqGVL7dt4JKaCs17UVTnX93rrh0tTtMm8VdztaFadeDG/mHW/5Sn5ccg5V7e8X": "India",
"mE+34vb8x/XMCm2cvmXDVMaB3U+Bq7TPdu56Tbr9TXpvSlGtWVaJwOZTN0lrhXm1": "India"
},
"description": "成功"
}
If it fails, the returned string has the following format.
{
"result": "error",
"reason": "System error!",
"trace_id": "Xxx00000000000000000xx",
"code": 1,
"description": "内部错误"
}
- Using the SDK:https://dev.mi.com/console/doc/detail?pId=1278#_8
三、UserAccount
- Get a list of RegIds corresponding to a UserAccount of an application (take India as an example)
Formal environment
API adress:
https://idmb-api.xmpush.global.xiaomi.com/v1/useraccount/get_regids_by_useraccount
HTTP Request Method:GET
Add HEADER field Authorization, for authentication。The format is key =。
APP_SECRET is obtained from the developer website.
Note: Character keys must be lowercase. E.g :Authorization: key=YOUR_APP_SECRET
Table 1-a. Get Alias corresponding RegId GET
type | parameter name | Parameter Description |
Long | appId | AppId of the application. |
String | packageName | Optional. Because an AppId may correspond to multiple package names, use this parameter to specify a specific package name. |
String | userAccount | User account to be queried |
Returns a string in json format.
If successful, the returned string has the following format. (data.list list value is RegId list)
{
"result": "ok",
"trace_id": "Xxx00000000000000000xx",
"code": 0,
"data": {
"list": [
"qXX5tXbsX/egM9lKDdWotd+XXXtO0njRu/+O/905Xvqpm+sXo064FAgV4A1kwXXX"
]
},
"description": "成功"
}
If it fails, the returned string has the following format.
{
"result": "error",
"reason": "Alias not found",
"trace_id": "Xxx00000000000000000xx",
"code": 22006,
"description": "应用程序Id不合法"
}
- Query Region by RegId see 2