dlt.getCountryInfo
Introduction
Get country information based on SIM or language.
Usage Limitations
Supported from basic library version 3.0.0
or higher.
Parameters
Object object
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
type | string | Yes | Possible values: 'sim', 'language' | |
success | function | No | Callback function for successful API call | |
fail | function | No | Callback function for failed API call | |
complete | function | No | Callback function for API call completion |
Note: If the type
parameter does not meet the requirements, the default logic will be used. The default logic is as follows: try to get SIM information first, and if not available, retrieve information based on language.
Return Value
Attribute | Type | Description |
---|---|---|
countryCode | string | Country |
mcc | string | Country code |
mnc | string | Network code |
source | string | Source, 'sim', 'language' |
success | string | true - setting successful false - setting failed |
Example Code
// pages/index/index.js
Page({
getCountryInfo() {
dlt.getCountryInfo({
type: 'sim',
success: (res) => {
console.log('success', res);
},
fail: (res) => {
console.log('fail', res);
},
complete: (res) => {
console.log('complete', res);
},
});
},
});