1e41f4b71Sopenharmony_ci# @ohos.telephony.sim (SIM Management) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **sim** module provides basic SIM card management functions. With the APIs provided by this module, you can obtain the ISO country code, home PLMN ID, service provider name, SIM card status, type, installation status, and activation status of the SIM card in the specified slot. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci>**NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Modules to Import 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci```ts 13e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 14e41f4b71Sopenharmony_ci``` 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## sim.isSimActive<sup>7+</sup> 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ciisSimActive\(slotId: number, callback: AsyncCallback\<boolean\>\): void 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ciChecks whether the SIM card in the specified slot is activated. This API uses an asynchronous callback to return the result. 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci**Parameters** 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 27e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------- | 28e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 29e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result, which is a Boolean value indicating whether the SIM card in the specified slot is activated. The value **true** means yes and the value **false** means no. | 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Example** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci```ts 34e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 35e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_cisim.isSimActive(0, (err: BusinessError, data: boolean) => { 38e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 39e41f4b71Sopenharmony_ci}); 40e41f4b71Sopenharmony_ci``` 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci## sim.isSimActive<sup>7+</sup> 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ciisSimActive\(slotId: number\): Promise\<boolean\> 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ciChecks whether the SIM card in the specified slot is activated. This API uses a promise to return the result. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci**Parameters** 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 54e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 55e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci**Return value** 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci| Type | Description | 60e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- | 61e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** indicates that the SIM card in the specified slot is activated, and the value **false** indicates the opposite.| 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci**Example** 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci```ts 66e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 67e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_cisim.isSimActive(0).then((data: boolean) => { 70e41f4b71Sopenharmony_ci console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`); 71e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 72e41f4b71Sopenharmony_ci console.error(`isSimActive failed, promise: err->${JSON.stringify(err)}`); 73e41f4b71Sopenharmony_ci}); 74e41f4b71Sopenharmony_ci``` 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci## sim.isSimActiveSync<sup>10+</sup> 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ciisSimActiveSync\(slotId: number\): boolean 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ciChecks whether the SIM card in the specified slot is activated. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci**Parameters** 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 87e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 88e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**Return value** 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci| Type | Description | 93e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- | 94e41f4b71Sopenharmony_ci| boolean | Boolean value indicating whether the SIM card in the specified slot is activated. The value **true** means yes and the value **false** means no.| 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci**Example** 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci```ts 99e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_cilet isSimActive: boolean = sim.isSimActiveSync(0); 102e41f4b71Sopenharmony_ciconsole.log(`the sim is active:` + isSimActive); 103e41f4b71Sopenharmony_ci``` 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSlotId<sup>7+</sup> 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_cigetDefaultVoiceSlotId\(callback: AsyncCallback\<number\>\): void 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ciObtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result. 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**Parameters** 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 117e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------- | 118e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: card slot not set or service not unavailable| 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci**Example** 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci```ts 123e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 124e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_cisim.getDefaultVoiceSlotId((err: BusinessError, data: number) => { 127e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 128e41f4b71Sopenharmony_ci}); 129e41f4b71Sopenharmony_ci``` 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSlotId<sup>7+</sup> 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_cigetDefaultVoiceSlotId\(\): Promise\<number\> 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ciObtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result. 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci**Return value** 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci| Type | Description | 142e41f4b71Sopenharmony_ci| ----------------- | --------------------------------------- | 143e41f4b71Sopenharmony_ci| Promise\<number\> | Promise used to return the result.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: card slot not set or service not unavailable| 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci**Example** 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci```ts 148e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 149e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_cisim.getDefaultVoiceSlotId().then((data: number) => { 152e41f4b71Sopenharmony_ci console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); 153e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 154e41f4b71Sopenharmony_ci console.error(`getDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`); 155e41f4b71Sopenharmony_ci}); 156e41f4b71Sopenharmony_ci``` 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci## sim.hasOperatorPrivileges<sup>7+</sup> 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_cihasOperatorPrivileges\(slotId: number, callback: AsyncCallback\<boolean\>\): void 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ciChecks whether the application (caller) has been granted the operator permission. This API uses an asynchronous callback to return the result. 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci**Parameters** 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 169e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ---------------------------------------- | 170e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 171e41f4b71Sopenharmony_ci| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. | 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci**Error codes** 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci| ID| Error Message | 178e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 179e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 180e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 181e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 182e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 183e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci**Example** 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci```ts 188e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 189e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_cisim.hasOperatorPrivileges(0, (err: BusinessError, data: boolean) => { 192e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 193e41f4b71Sopenharmony_ci}); 194e41f4b71Sopenharmony_ci``` 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci## sim.hasOperatorPrivileges<sup>7+</sup> 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_cihasOperatorPrivileges\(slotId: number\): Promise\<boolean\> 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ciChecks whether the application (caller) has been granted the operator permission. This API uses a promise to return the result. 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**Parameters** 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 207e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- | 208e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci**Return value** 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci| Type | Description | 213e41f4b71Sopenharmony_ci| :----------------- | :---------------------------------------------------------- | 214e41f4b71Sopenharmony_ci| Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the application (caller) has been granted the carrier permission, and the value **false** indicates the opposite.| 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci**Error codes** 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_ci| ID| Error Message | 221e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 222e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 223e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 224e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 225e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 226e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci**Example** 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci```ts 231e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 232e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_cisim.hasOperatorPrivileges(0).then((data: boolean) => { 235e41f4b71Sopenharmony_ci console.log(`hasOperatorPrivileges success, promise: data->${JSON.stringify(data)}`); 236e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 237e41f4b71Sopenharmony_ci console.error(`hasOperatorPrivileges failed, promise: err->${JSON.stringify(err)}`); 238e41f4b71Sopenharmony_ci}); 239e41f4b71Sopenharmony_ci``` 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci## sim.getISOCountryCodeForSim 242e41f4b71Sopenharmony_ci 243e41f4b71Sopenharmony_cigetISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\<string\>\): void 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ciObtains the ISO country code of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci**Parameters** 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 252e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ---------------------------------------- | 253e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | 254e41f4b71Sopenharmony_ci| callback | AsyncCallback\<string\> | Yes | Callback used to return the result, which is an ISO country code, for example, **CN** (China).| 255e41f4b71Sopenharmony_ci 256e41f4b71Sopenharmony_ci**Error codes** 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci| ID| Error Message | 261e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 262e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 263e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 264e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 265e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 266e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 267e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci**Example** 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci```ts 272e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 273e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_cisim.getISOCountryCodeForSim(0, (err: BusinessError, data: string) => { 276e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 277e41f4b71Sopenharmony_ci}); 278e41f4b71Sopenharmony_ci``` 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci## sim.getISOCountryCodeForSim 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_cigetISOCountryCodeForSim\(slotId: number\): Promise\<string\> 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ciObtains the ISO country code of the SIM card in the specified slot. This API uses a promise to return the result. 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci**Parameters** 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 292e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 293e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci**Return value** 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci| Type | Description | 298e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ | 299e41f4b71Sopenharmony_ci| Promise\<string\> | Promise used to return the result, which is an ISO country code, for example, **CN** (China).| 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ci**Error codes** 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci| ID| Error Message | 306e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 307e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 308e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 309e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 310e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 311e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 312e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci**Example** 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ci```ts 317e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 318e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_cisim.getISOCountryCodeForSim(0).then((data: string) => { 321e41f4b71Sopenharmony_ci console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`); 322e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 323e41f4b71Sopenharmony_ci console.error(`getISOCountryCodeForSim failed, promise: err->${JSON.stringify(err)}`); 324e41f4b71Sopenharmony_ci}); 325e41f4b71Sopenharmony_ci``` 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci## sim.getISOCountryCodeForSimSync<sup>10+</sup> 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_cigetISOCountryCodeForSimSync\(slotId: number\): string 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ciObtains the ISO country code of the SIM card in the specified slot. 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci**Parameters** 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 338e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 339e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci**Return value** 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci| Type | Description | 344e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ | 345e41f4b71Sopenharmony_ci| string | ISO country code of the SIM card in the specified slot, for example, **CN** (China).| 346e41f4b71Sopenharmony_ci 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci**Example** 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci```ts 351e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_cilet countryCode: string = sim.getISOCountryCodeForSimSync(0); 354e41f4b71Sopenharmony_ciconsole.log(`the country ISO is:` + countryCode); 355e41f4b71Sopenharmony_ci``` 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci## sim.getSimOperatorNumeric 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_cigetSimOperatorNumeric\(slotId: number, callback: AsyncCallback\<string\>\): void 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ciObtains the home public land mobile network (PLMN) ID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci**Parameters** 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 369e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------- | 370e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 371e41f4b71Sopenharmony_ci| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. | 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci**Error codes** 374e41f4b71Sopenharmony_ci 375e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ci| ID| Error Message | 378e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 379e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 380e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 381e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 382e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 383e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 384e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ci**Example** 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci```ts 389e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 390e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_cisim.getSimOperatorNumeric(0, (err: BusinessError, data: string) => { 393e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 394e41f4b71Sopenharmony_ci}); 395e41f4b71Sopenharmony_ci``` 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_ci 398e41f4b71Sopenharmony_ci## sim.getSimOperatorNumeric 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_cigetSimOperatorNumeric\(slotId: number\): Promise\<string\> 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ciObtains the home PLMN ID of the SIM card in the specified slot. This API uses a promise to return the result. 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 405e41f4b71Sopenharmony_ci 406e41f4b71Sopenharmony_ci**Parameters** 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 409e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 410e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci**Return value** 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci| Type | Description | 415e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------ | 416e41f4b71Sopenharmony_ci| Promise\<string\> | Promise used to return the result.| 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci**Error codes** 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci| ID| Error Message | 423e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 424e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 425e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 426e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 427e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 428e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 429e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ci**Example** 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci```ts 434e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 435e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_cisim.getSimOperatorNumeric(0).then((data: string) => { 438e41f4b71Sopenharmony_ci console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`); 439e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 440e41f4b71Sopenharmony_ci console.error(`getSimOperatorNumeric failed, promise: err->${JSON.stringify(err)}`); 441e41f4b71Sopenharmony_ci}); 442e41f4b71Sopenharmony_ci``` 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ci## sim.getSimOperatorNumericSync<sup>10+</sup> 445e41f4b71Sopenharmony_ci 446e41f4b71Sopenharmony_cigetSimOperatorNumericSync\(slotId: number\): string 447e41f4b71Sopenharmony_ci 448e41f4b71Sopenharmony_ciObtains the home PLMN ID of the SIM card in the specified slot. 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ci**Parameters** 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 455e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 456e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci**Return value** 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci| Type | Description | 461e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------ | 462e41f4b71Sopenharmony_ci| string | Home PLMN number of the SIM card in the specified slot.| 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ci**Example** 466e41f4b71Sopenharmony_ci 467e41f4b71Sopenharmony_ci```ts 468e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_cilet numeric: string = sim.getSimOperatorNumericSync(0); 471e41f4b71Sopenharmony_ciconsole.log(`the sim operator numeric is:` + numeric); 472e41f4b71Sopenharmony_ci``` 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci## sim.getSimSpn 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_cigetSimSpn\(slotId: number, callback: AsyncCallback\<string\>\): void 478e41f4b71Sopenharmony_ci 479e41f4b71Sopenharmony_ciObtains the service provider name (SPN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci**Parameters** 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 486e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------- | 487e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 488e41f4b71Sopenharmony_ci| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. | 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci**Error codes** 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci| ID| Error Message | 495e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 496e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 497e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 498e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 499e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 500e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 501e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci**Example** 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci```ts 506e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 507e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 508e41f4b71Sopenharmony_ci 509e41f4b71Sopenharmony_cisim.getSimSpn(0, (err: BusinessError, data: string) => { 510e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 511e41f4b71Sopenharmony_ci}); 512e41f4b71Sopenharmony_ci``` 513e41f4b71Sopenharmony_ci 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci## sim.getSimSpn 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_cigetSimSpn\(slotId: number\): Promise\<string\> 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ciObtains the SPN of the SIM card in the specified slot. This API uses a promise to return the result. 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci**Parameters** 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 526e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 527e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 528e41f4b71Sopenharmony_ci 529e41f4b71Sopenharmony_ci**Return value** 530e41f4b71Sopenharmony_ci 531e41f4b71Sopenharmony_ci| Type | Description | 532e41f4b71Sopenharmony_ci| ----------------- | ----------------------------------------- | 533e41f4b71Sopenharmony_ci| Promise\<string\> | Promise used to return the result.| 534e41f4b71Sopenharmony_ci 535e41f4b71Sopenharmony_ci**Error codes** 536e41f4b71Sopenharmony_ci 537e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci| ID| Error Message | 540e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 541e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 542e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 543e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 544e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 545e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 546e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 547e41f4b71Sopenharmony_ci 548e41f4b71Sopenharmony_ci**Example** 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ci```ts 551e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 552e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_cisim.getSimSpn(0).then((data: string) => { 555e41f4b71Sopenharmony_ci console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`); 556e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 557e41f4b71Sopenharmony_ci console.error(`getSimSpn failed, promise: err->${JSON.stringify(err)}`); 558e41f4b71Sopenharmony_ci}); 559e41f4b71Sopenharmony_ci``` 560e41f4b71Sopenharmony_ci 561e41f4b71Sopenharmony_ci## sim.getSimSpnSync<sup>10+</sup> 562e41f4b71Sopenharmony_ci 563e41f4b71Sopenharmony_cigetSimSpnSync\(slotId: number\): string 564e41f4b71Sopenharmony_ci 565e41f4b71Sopenharmony_ciObtains the SPN of the SIM card in the specified slot. 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ci**Parameters** 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 572e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 573e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ci**Return value** 576e41f4b71Sopenharmony_ci 577e41f4b71Sopenharmony_ci| Type | Description | 578e41f4b71Sopenharmony_ci| ----------------- | ----------------------------------------- | 579e41f4b71Sopenharmony_ci| string | SPN of the SIM card in the specified slot.| 580e41f4b71Sopenharmony_ci 581e41f4b71Sopenharmony_ci 582e41f4b71Sopenharmony_ci**Example** 583e41f4b71Sopenharmony_ci 584e41f4b71Sopenharmony_ci```ts 585e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 586e41f4b71Sopenharmony_ci 587e41f4b71Sopenharmony_cilet spn: string = sim.getSimSpnSync(0); 588e41f4b71Sopenharmony_ciconsole.log(`the sim card spn is:` + spn); 589e41f4b71Sopenharmony_ci``` 590e41f4b71Sopenharmony_ci 591e41f4b71Sopenharmony_ci 592e41f4b71Sopenharmony_ci## sim.getSimState 593e41f4b71Sopenharmony_ci 594e41f4b71Sopenharmony_cigetSimState\(slotId: number, callback: AsyncCallback\<SimState\>\): void 595e41f4b71Sopenharmony_ci 596e41f4b71Sopenharmony_ciObtains the state of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 599e41f4b71Sopenharmony_ci 600e41f4b71Sopenharmony_ci**Parameters** 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 603e41f4b71Sopenharmony_ci| -------- | -------------------------------------- | ---- | -------------------------------------- | 604e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 605e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[SimState](#simstate)\> | Yes | Callback used to return the result. For details, see [SimState](#simstate). | 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_ci**Error codes** 608e41f4b71Sopenharmony_ci 609e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 610e41f4b71Sopenharmony_ci 611e41f4b71Sopenharmony_ci| ID| Error Message | 612e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 613e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 614e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 615e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 616e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 617e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 618e41f4b71Sopenharmony_ci 619e41f4b71Sopenharmony_ci**Example** 620e41f4b71Sopenharmony_ci 621e41f4b71Sopenharmony_ci```ts 622e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 623e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 624e41f4b71Sopenharmony_ci 625e41f4b71Sopenharmony_cisim.getSimState(0, (err: BusinessError, data: sim.SimState) => { 626e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 627e41f4b71Sopenharmony_ci}); 628e41f4b71Sopenharmony_ci``` 629e41f4b71Sopenharmony_ci 630e41f4b71Sopenharmony_ci 631e41f4b71Sopenharmony_ci## sim.getSimState 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_cigetSimState\(slotId: number\): Promise\<SimState\> 634e41f4b71Sopenharmony_ci 635e41f4b71Sopenharmony_ciObtains the state of the SIM card in the specified slot. This API uses a promise to return the result. 636e41f4b71Sopenharmony_ci 637e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 638e41f4b71Sopenharmony_ci 639e41f4b71Sopenharmony_ci**Parameters** 640e41f4b71Sopenharmony_ci 641e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 642e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 643e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci**Return value** 646e41f4b71Sopenharmony_ci 647e41f4b71Sopenharmony_ci| Type | Description | 648e41f4b71Sopenharmony_ci| -------------------------------- | ------------------------------------------ | 649e41f4b71Sopenharmony_ci| Promise\<[SimState](#simstate)\> | Promise used to return the result.| 650e41f4b71Sopenharmony_ci 651e41f4b71Sopenharmony_ci**Error codes** 652e41f4b71Sopenharmony_ci 653e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 654e41f4b71Sopenharmony_ci 655e41f4b71Sopenharmony_ci| ID| Error Message | 656e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 657e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 658e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 659e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 660e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 661e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 662e41f4b71Sopenharmony_ci 663e41f4b71Sopenharmony_ci**Example** 664e41f4b71Sopenharmony_ci 665e41f4b71Sopenharmony_ci```ts 666e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 667e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_cisim.getSimState(0).then((data: sim.SimState) => { 670e41f4b71Sopenharmony_ci console.log(`getSimState success, promise: data->${JSON.stringify(data)}`); 671e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 672e41f4b71Sopenharmony_ci console.error(`getSimState failed, promise: err->${JSON.stringify(err)}`); 673e41f4b71Sopenharmony_ci}); 674e41f4b71Sopenharmony_ci``` 675e41f4b71Sopenharmony_ci 676e41f4b71Sopenharmony_ci## sim.getSimStateSync<sup>10+</sup> 677e41f4b71Sopenharmony_ci 678e41f4b71Sopenharmony_cigetSimStateSync\(slotId: number\): SimState 679e41f4b71Sopenharmony_ci 680e41f4b71Sopenharmony_ciObtains the state of the SIM card in the specified slot. 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 683e41f4b71Sopenharmony_ci 684e41f4b71Sopenharmony_ci**Parameters** 685e41f4b71Sopenharmony_ci 686e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 687e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 688e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 689e41f4b71Sopenharmony_ci 690e41f4b71Sopenharmony_ci**Return value** 691e41f4b71Sopenharmony_ci 692e41f4b71Sopenharmony_ci| Type | Description | 693e41f4b71Sopenharmony_ci| ---------------------------- | ------------------------------------------ | 694e41f4b71Sopenharmony_ci| [SimState](#simstate) | State of the SIM card in the specified slot.| 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ci 697e41f4b71Sopenharmony_ci**Example** 698e41f4b71Sopenharmony_ci 699e41f4b71Sopenharmony_ci```ts 700e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 701e41f4b71Sopenharmony_ci 702e41f4b71Sopenharmony_cilet simState: sim.SimState = sim.getSimStateSync(0); 703e41f4b71Sopenharmony_ciconsole.log(`The sim state is:` + simState); 704e41f4b71Sopenharmony_ci``` 705e41f4b71Sopenharmony_ci 706e41f4b71Sopenharmony_ci## sim.getCardType<sup>7+</sup> 707e41f4b71Sopenharmony_ci 708e41f4b71Sopenharmony_cigetCardType\(slotId: number, callback: AsyncCallback\<CardType\>\): void 709e41f4b71Sopenharmony_ci 710e41f4b71Sopenharmony_ciObtains the type of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 711e41f4b71Sopenharmony_ci 712e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 713e41f4b71Sopenharmony_ci 714e41f4b71Sopenharmony_ci**Parameters** 715e41f4b71Sopenharmony_ci 716e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 717e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | -------------------------------------- | 718e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 719e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CardType](#cardtype7)\> | Yes | Callback used to return the result. | 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_ci**Error codes** 722e41f4b71Sopenharmony_ci 723e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 724e41f4b71Sopenharmony_ci 725e41f4b71Sopenharmony_ci| ID| Error Message | 726e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 727e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 728e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 729e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 730e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 731e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 732e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 733e41f4b71Sopenharmony_ci 734e41f4b71Sopenharmony_ci**Example** 735e41f4b71Sopenharmony_ci 736e41f4b71Sopenharmony_ci```ts 737e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 738e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 739e41f4b71Sopenharmony_ci 740e41f4b71Sopenharmony_cisim.getCardType(0, (err: BusinessError, data: sim.CardType) => { 741e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 742e41f4b71Sopenharmony_ci}); 743e41f4b71Sopenharmony_ci``` 744e41f4b71Sopenharmony_ci 745e41f4b71Sopenharmony_ci 746e41f4b71Sopenharmony_ci## sim.getCardType<sup>7+</sup> 747e41f4b71Sopenharmony_ci 748e41f4b71Sopenharmony_cigetCardType\(slotId: number\): Promise\<CardType\> 749e41f4b71Sopenharmony_ci 750e41f4b71Sopenharmony_ciObtains the type of the SIM card in the specified slot. This API uses a promise to return the result. 751e41f4b71Sopenharmony_ci 752e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 753e41f4b71Sopenharmony_ci 754e41f4b71Sopenharmony_ci**Parameters** 755e41f4b71Sopenharmony_ci 756e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 757e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 758e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_ci**Return value** 761e41f4b71Sopenharmony_ci 762e41f4b71Sopenharmony_ci| Type | Description | 763e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ | 764e41f4b71Sopenharmony_ci| Promise\<[CardType](#cardtype7)\> | Promise used to return the result.| 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ci**Error codes** 767e41f4b71Sopenharmony_ci 768e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 769e41f4b71Sopenharmony_ci 770e41f4b71Sopenharmony_ci| ID| Error Message | 771e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 772e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 773e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 774e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 775e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 776e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 777e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 778e41f4b71Sopenharmony_ci 779e41f4b71Sopenharmony_ci**Example** 780e41f4b71Sopenharmony_ci 781e41f4b71Sopenharmony_ci```ts 782e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 783e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_cisim.getCardType(0).then((data: sim.CardType) => { 786e41f4b71Sopenharmony_ci console.log(`getCardType success, promise: data->${JSON.stringify(data)}`); 787e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 788e41f4b71Sopenharmony_ci console.error(`getCardType failed, promise: err->${JSON.stringify(err)}`); 789e41f4b71Sopenharmony_ci}); 790e41f4b71Sopenharmony_ci``` 791e41f4b71Sopenharmony_ci 792e41f4b71Sopenharmony_ci## sim.getCardTypeSync<sup>10+</sup> 793e41f4b71Sopenharmony_ci 794e41f4b71Sopenharmony_cigetCardTypeSync\(slotId: number\): CardType 795e41f4b71Sopenharmony_ci 796e41f4b71Sopenharmony_ciObtains the type of the SIM card in the specified slot. 797e41f4b71Sopenharmony_ci 798e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 799e41f4b71Sopenharmony_ci 800e41f4b71Sopenharmony_ci**Parameters** 801e41f4b71Sopenharmony_ci 802e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 803e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 804e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 805e41f4b71Sopenharmony_ci 806e41f4b71Sopenharmony_ci**Return value** 807e41f4b71Sopenharmony_ci 808e41f4b71Sopenharmony_ci| Type | Description | 809e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ | 810e41f4b71Sopenharmony_ci| [CardType](#cardtype7) | Type of the SIM card in the specified slot.| 811e41f4b71Sopenharmony_ci 812e41f4b71Sopenharmony_ci 813e41f4b71Sopenharmony_ci**Example** 814e41f4b71Sopenharmony_ci 815e41f4b71Sopenharmony_ci```ts 816e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 817e41f4b71Sopenharmony_ci 818e41f4b71Sopenharmony_cilet cardType: sim.CardType = sim.getCardTypeSync(0); 819e41f4b71Sopenharmony_ciconsole.log(`the card type is:` + cardType); 820e41f4b71Sopenharmony_ci``` 821e41f4b71Sopenharmony_ci 822e41f4b71Sopenharmony_ci 823e41f4b71Sopenharmony_ci## sim.hasSimCard<sup>7+</sup> 824e41f4b71Sopenharmony_ci 825e41f4b71Sopenharmony_cihasSimCard\(slotId: number, callback: AsyncCallback\<boolean\>\): void 826e41f4b71Sopenharmony_ci 827e41f4b71Sopenharmony_ciChecks whether the SIM card in the specified slot is installed. This API uses an asynchronous callback to return the result. 828e41f4b71Sopenharmony_ci 829e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 830e41f4b71Sopenharmony_ci 831e41f4b71Sopenharmony_ci**Parameters** 832e41f4b71Sopenharmony_ci 833e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 834e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | -------------------------------------- | 835e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 836e41f4b71Sopenharmony_ci| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** indicates that the SIM card in the specified slot is installed, and the value **false** indicates the opposite. | 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ci**Error codes** 839e41f4b71Sopenharmony_ci 840e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 841e41f4b71Sopenharmony_ci 842e41f4b71Sopenharmony_ci| ID| Error Message | 843e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 844e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 845e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 846e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 847e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 848e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 849e41f4b71Sopenharmony_ci 850e41f4b71Sopenharmony_ci**Example** 851e41f4b71Sopenharmony_ci 852e41f4b71Sopenharmony_ci```ts 853e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 854e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 855e41f4b71Sopenharmony_ci 856e41f4b71Sopenharmony_cisim.hasSimCard(0, (err: BusinessError, data: boolean) => { 857e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 858e41f4b71Sopenharmony_ci}); 859e41f4b71Sopenharmony_ci``` 860e41f4b71Sopenharmony_ci 861e41f4b71Sopenharmony_ci 862e41f4b71Sopenharmony_ci## sim.hasSimCard<sup>7+</sup> 863e41f4b71Sopenharmony_ci 864e41f4b71Sopenharmony_cihasSimCard\(slotId: number\): Promise\<boolean\> 865e41f4b71Sopenharmony_ci 866e41f4b71Sopenharmony_ciChecks whether the SIM card in the specified slot is installed. This API uses a promise to return the result. 867e41f4b71Sopenharmony_ci 868e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 869e41f4b71Sopenharmony_ci 870e41f4b71Sopenharmony_ci**Parameters** 871e41f4b71Sopenharmony_ci 872e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 873e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 874e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 875e41f4b71Sopenharmony_ci 876e41f4b71Sopenharmony_ci**Return value** 877e41f4b71Sopenharmony_ci 878e41f4b71Sopenharmony_ci| Type | Description | 879e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- | 880e41f4b71Sopenharmony_ci| Promise<boolean> | Promise used to return the result. The value **true** indicates that the SIM card in the specified slot is installed, and the value **false** indicates the opposite.| 881e41f4b71Sopenharmony_ci 882e41f4b71Sopenharmony_ci**Error codes** 883e41f4b71Sopenharmony_ci 884e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 885e41f4b71Sopenharmony_ci 886e41f4b71Sopenharmony_ci| ID| Error Message | 887e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 888e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 889e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 890e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 891e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 892e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 893e41f4b71Sopenharmony_ci 894e41f4b71Sopenharmony_ci**Example** 895e41f4b71Sopenharmony_ci 896e41f4b71Sopenharmony_ci```ts 897e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 898e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 899e41f4b71Sopenharmony_ci 900e41f4b71Sopenharmony_cisim.hasSimCard(0).then((data: boolean) => { 901e41f4b71Sopenharmony_ci console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`); 902e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 903e41f4b71Sopenharmony_ci console.error(`hasSimCard failed, promise: err->${JSON.stringify(err)}`); 904e41f4b71Sopenharmony_ci}); 905e41f4b71Sopenharmony_ci``` 906e41f4b71Sopenharmony_ci 907e41f4b71Sopenharmony_ci## sim.hasSimCardSync<sup>10+</sup> 908e41f4b71Sopenharmony_ci 909e41f4b71Sopenharmony_cihasSimCardSync\(slotId: number\): boolean 910e41f4b71Sopenharmony_ci 911e41f4b71Sopenharmony_ciChecks whether the SIM card in the specified slot is installed. 912e41f4b71Sopenharmony_ci 913e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 914e41f4b71Sopenharmony_ci 915e41f4b71Sopenharmony_ci**Parameters** 916e41f4b71Sopenharmony_ci 917e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 918e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 919e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 920e41f4b71Sopenharmony_ci 921e41f4b71Sopenharmony_ci**Return value** 922e41f4b71Sopenharmony_ci 923e41f4b71Sopenharmony_ci| Type | Description | 924e41f4b71Sopenharmony_ci| --------------------- | ---------------------------------- | 925e41f4b71Sopenharmony_ci| boolean | Boolean value indicating whether the SIM card in the specified slot is installed. The value **true** means yes and the value **false** means no.| 926e41f4b71Sopenharmony_ci 927e41f4b71Sopenharmony_ci**Example** 928e41f4b71Sopenharmony_ci 929e41f4b71Sopenharmony_ci```ts 930e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 931e41f4b71Sopenharmony_ci 932e41f4b71Sopenharmony_cilet hasSimCard: boolean = sim.hasSimCardSync(0); 933e41f4b71Sopenharmony_ciconsole.log(`has sim card: ` + hasSimCard); 934e41f4b71Sopenharmony_ci``` 935e41f4b71Sopenharmony_ci 936e41f4b71Sopenharmony_ci## sim.getSimAccountInfo<sup>10+</sup> 937e41f4b71Sopenharmony_ci 938e41f4b71Sopenharmony_cigetSimAccountInfo\(slotId: number, callback: AsyncCallback\<IccAccountInfo\>\): void 939e41f4b71Sopenharmony_ci 940e41f4b71Sopenharmony_ciObtains account information of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 941e41f4b71Sopenharmony_ci 942e41f4b71Sopenharmony_ci**Required permission**: ohos.permission.GET_TELEPHONY_STATE 943e41f4b71Sopenharmony_ci 944e41f4b71Sopenharmony_ci>**NOTE** 945e41f4b71Sopenharmony_ci> 946e41f4b71Sopenharmony_ci>The **GET_TELEPHONY_STATE** permission is required only when you need to obtain the ICCID and phone number. Such information is sensitive and not open to third-party applications. When this API is called, the returned ICCID and phone number are empty. 947e41f4b71Sopenharmony_ci 948e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 949e41f4b71Sopenharmony_ci 950e41f4b71Sopenharmony_ci**Parameters** 951e41f4b71Sopenharmony_ci 952e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 953e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | -------------------------------------- | 954e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 955e41f4b71Sopenharmony_ci| callback | AsyncCallback<[IccAccountInfo](#iccaccountinfo10)> | Yes | Callback used to return the result. | 956e41f4b71Sopenharmony_ci 957e41f4b71Sopenharmony_ci**Error codes** 958e41f4b71Sopenharmony_ci 959e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 960e41f4b71Sopenharmony_ci 961e41f4b71Sopenharmony_ci| ID| Error Message | 962e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 963e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 964e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 965e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 966e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 967e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 968e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 969e41f4b71Sopenharmony_ci| 8301002 | The SIM card failed to read or update data. | 970e41f4b71Sopenharmony_ci 971e41f4b71Sopenharmony_ci**Example** 972e41f4b71Sopenharmony_ci 973e41f4b71Sopenharmony_ci```ts 974e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 975e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 976e41f4b71Sopenharmony_ci 977e41f4b71Sopenharmony_cisim.getSimAccountInfo(0, (err:BusinessError , data: sim.IccAccountInfo) => { 978e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 979e41f4b71Sopenharmony_ci}); 980e41f4b71Sopenharmony_ci``` 981e41f4b71Sopenharmony_ci 982e41f4b71Sopenharmony_ci 983e41f4b71Sopenharmony_ci## sim.getSimAccountInfo<sup>10+</sup> 984e41f4b71Sopenharmony_ci 985e41f4b71Sopenharmony_cigetSimAccountInfo\(slotId: number\): Promise\<IccAccountInfo\> 986e41f4b71Sopenharmony_ci 987e41f4b71Sopenharmony_ciObtains account information of the SIM card in the specified slot. This API uses a promise to return the result. 988e41f4b71Sopenharmony_ci 989e41f4b71Sopenharmony_ci**Required permission**: ohos.permission.GET_TELEPHONY_STATE 990e41f4b71Sopenharmony_ci 991e41f4b71Sopenharmony_ci>**NOTE** 992e41f4b71Sopenharmony_ci> 993e41f4b71Sopenharmony_ci>The **GET_TELEPHONY_STATE** permission is required only when you need to obtain the ICCID and phone number. Such information is sensitive and not open to third-party applications. When this API is called, the returned ICCID and phone number are empty. 994e41f4b71Sopenharmony_ci 995e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 996e41f4b71Sopenharmony_ci 997e41f4b71Sopenharmony_ci**Parameters** 998e41f4b71Sopenharmony_ci 999e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 1000e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 1001e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1002e41f4b71Sopenharmony_ci 1003e41f4b71Sopenharmony_ci**Return value** 1004e41f4b71Sopenharmony_ci 1005e41f4b71Sopenharmony_ci| Type | Description | 1006e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------------------------ | 1007e41f4b71Sopenharmony_ci| Promise<[IccAccountInfo](#iccaccountinfo10)> | Promise used to return the result.| 1008e41f4b71Sopenharmony_ci 1009e41f4b71Sopenharmony_ci**Error codes** 1010e41f4b71Sopenharmony_ci 1011e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1012e41f4b71Sopenharmony_ci 1013e41f4b71Sopenharmony_ci| ID| Error Message | 1014e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1015e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1016e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1017e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1018e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1019e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 1020e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1021e41f4b71Sopenharmony_ci| 8301002 | The SIM card failed to read or update data. | 1022e41f4b71Sopenharmony_ci 1023e41f4b71Sopenharmony_ci**Example** 1024e41f4b71Sopenharmony_ci 1025e41f4b71Sopenharmony_ci```ts 1026e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1027e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1028e41f4b71Sopenharmony_ci 1029e41f4b71Sopenharmony_cisim.getSimAccountInfo(0).then((data: sim.IccAccountInfo) => { 1030e41f4b71Sopenharmony_ci console.log(`getSimAccountInfo success, promise: data->${JSON.stringify(data)}`); 1031e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 1032e41f4b71Sopenharmony_ci console.error(`getSimAccountInfo failed, promise: err->${JSON.stringify(err)}`); 1033e41f4b71Sopenharmony_ci}); 1034e41f4b71Sopenharmony_ci``` 1035e41f4b71Sopenharmony_ci 1036e41f4b71Sopenharmony_ci## sim.getActiveSimAccountInfoList<sup>10+</sup> 1037e41f4b71Sopenharmony_ci 1038e41f4b71Sopenharmony_cigetActiveSimAccountInfoList\(callback: AsyncCallback\<Array\<IccAccountInfo\>\>\): void 1039e41f4b71Sopenharmony_ci 1040e41f4b71Sopenharmony_ciObtains the list of activated SIM card accounts. This API uses an asynchronous callback to return the result. 1041e41f4b71Sopenharmony_ci 1042e41f4b71Sopenharmony_ci**Required permission**: ohos.permission.GET_TELEPHONY_STATE 1043e41f4b71Sopenharmony_ci 1044e41f4b71Sopenharmony_ci>**NOTE** 1045e41f4b71Sopenharmony_ci> 1046e41f4b71Sopenharmony_ci>The **GET_TELEPHONY_STATE** permission is required only when you need to obtain the ICCID and phone number. Such information is sensitive and not open to third-party applications. When this API is called, the returned ICCID and phone number are empty. 1047e41f4b71Sopenharmony_ci 1048e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1049e41f4b71Sopenharmony_ci 1050e41f4b71Sopenharmony_ci**Parameters** 1051e41f4b71Sopenharmony_ci 1052e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 1053e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------------- | ---- | ---------- | 1054e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[IccAccountInfo](#iccaccountinfo10)>> | Yes | Callback used to return the result. | 1055e41f4b71Sopenharmony_ci 1056e41f4b71Sopenharmony_ci**Error codes** 1057e41f4b71Sopenharmony_ci 1058e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1059e41f4b71Sopenharmony_ci 1060e41f4b71Sopenharmony_ci| ID| Error Message | 1061e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1062e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1063e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1064e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1065e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1066e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 1067e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1068e41f4b71Sopenharmony_ci 1069e41f4b71Sopenharmony_ci**Example** 1070e41f4b71Sopenharmony_ci 1071e41f4b71Sopenharmony_ci```ts 1072e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1073e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1074e41f4b71Sopenharmony_ci 1075e41f4b71Sopenharmony_cisim.getActiveSimAccountInfoList((err: BusinessError, data: Array<sim.IccAccountInfo>) => { 1076e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1077e41f4b71Sopenharmony_ci}); 1078e41f4b71Sopenharmony_ci``` 1079e41f4b71Sopenharmony_ci 1080e41f4b71Sopenharmony_ci## sim.getMaxSimCount<sup>7+</sup> 1081e41f4b71Sopenharmony_ci 1082e41f4b71Sopenharmony_cigetMaxSimCount\(\): number 1083e41f4b71Sopenharmony_ci 1084e41f4b71Sopenharmony_ciObtains the number of card slots. 1085e41f4b71Sopenharmony_ci 1086e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1087e41f4b71Sopenharmony_ci 1088e41f4b71Sopenharmony_ci**Return value** 1089e41f4b71Sopenharmony_ci 1090e41f4b71Sopenharmony_ci| Type | Description | 1091e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ | 1092e41f4b71Sopenharmony_ci| number | Number of card slots.| 1093e41f4b71Sopenharmony_ci 1094e41f4b71Sopenharmony_ci**Example** 1095e41f4b71Sopenharmony_ci 1096e41f4b71Sopenharmony_ci```ts 1097e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1098e41f4b71Sopenharmony_ci 1099e41f4b71Sopenharmony_ciconsole.log("Result: "+ sim.getMaxSimCount()); 1100e41f4b71Sopenharmony_ci``` 1101e41f4b71Sopenharmony_ci 1102e41f4b71Sopenharmony_ci 1103e41f4b71Sopenharmony_ci## sim.getActiveSimAccountInfoList<sup>10+</sup> 1104e41f4b71Sopenharmony_ci 1105e41f4b71Sopenharmony_cigetActiveSimAccountInfoList\(\): Promise\<Array\<IccAccountInfo\>\> 1106e41f4b71Sopenharmony_ci 1107e41f4b71Sopenharmony_ciObtains the list of activated SIM card accounts. This API uses a promise to return the result. 1108e41f4b71Sopenharmony_ci 1109e41f4b71Sopenharmony_ci**Required permission**: ohos.permission.GET_TELEPHONY_STATE 1110e41f4b71Sopenharmony_ci 1111e41f4b71Sopenharmony_ci>**NOTE** 1112e41f4b71Sopenharmony_ci> 1113e41f4b71Sopenharmony_ci>The **GET_TELEPHONY_STATE** permission is required only when you need to obtain the ICCID and phone number. Such information is sensitive and not open to third-party applications. When this API is called, the returned ICCID and phone number are empty. 1114e41f4b71Sopenharmony_ci 1115e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1116e41f4b71Sopenharmony_ci 1117e41f4b71Sopenharmony_ci**Return value** 1118e41f4b71Sopenharmony_ci 1119e41f4b71Sopenharmony_ci| Type | Description | 1120e41f4b71Sopenharmony_ci| ---------------------------------------------------- | ---------------------------------------------- | 1121e41f4b71Sopenharmony_ci| Promise<Array<[IccAccountInfo](#iccaccountinfo10)>> | Promise used to return the result.| 1122e41f4b71Sopenharmony_ci 1123e41f4b71Sopenharmony_ci**Error codes** 1124e41f4b71Sopenharmony_ci 1125e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1126e41f4b71Sopenharmony_ci 1127e41f4b71Sopenharmony_ci| ID| Error Message | 1128e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1129e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1130e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1131e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 1132e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1133e41f4b71Sopenharmony_ci 1134e41f4b71Sopenharmony_ci**Example** 1135e41f4b71Sopenharmony_ci 1136e41f4b71Sopenharmony_ci```ts 1137e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1138e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1139e41f4b71Sopenharmony_ci 1140e41f4b71Sopenharmony_cisim.getActiveSimAccountInfoList().then((data: Array<sim.IccAccountInfo>) => { 1141e41f4b71Sopenharmony_ci console.log(`getActiveSimAccountInfoList success, promise: data->${JSON.stringify(data)}`); 1142e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 1143e41f4b71Sopenharmony_ci console.error(`getActiveSimAccountInfoList failed, promise: err->${JSON.stringify(err)}`); 1144e41f4b71Sopenharmony_ci}); 1145e41f4b71Sopenharmony_ci``` 1146e41f4b71Sopenharmony_ci 1147e41f4b71Sopenharmony_ci 1148e41f4b71Sopenharmony_ci## sim.getOpKey<sup>9+</sup> 1149e41f4b71Sopenharmony_ci 1150e41f4b71Sopenharmony_cigetOpKey\(slotId: number, callback: AsyncCallback\<string\>): void 1151e41f4b71Sopenharmony_ci 1152e41f4b71Sopenharmony_ciObtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 1153e41f4b71Sopenharmony_ci 1154e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1155e41f4b71Sopenharmony_ci 1156e41f4b71Sopenharmony_ci**Parameters** 1157e41f4b71Sopenharmony_ci 1158e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 1159e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | -------------------------------------- | 1160e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1161e41f4b71Sopenharmony_ci| callback | AsyncCallback<string\> | Yes | Callback used to return the result. | 1162e41f4b71Sopenharmony_ci 1163e41f4b71Sopenharmony_ci**Error codes** 1164e41f4b71Sopenharmony_ci 1165e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1166e41f4b71Sopenharmony_ci 1167e41f4b71Sopenharmony_ci| ID| Error Message | 1168e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1169e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1170e41f4b71Sopenharmony_ci| 801 | Capability not supported. | 1171e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1172e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1173e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1174e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1175e41f4b71Sopenharmony_ci 1176e41f4b71Sopenharmony_ci**Example** 1177e41f4b71Sopenharmony_ci 1178e41f4b71Sopenharmony_ci```ts 1179e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1180e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1181e41f4b71Sopenharmony_ci 1182e41f4b71Sopenharmony_citry { 1183e41f4b71Sopenharmony_ci sim.getOpKey(0, (err: BusinessError, data: string) => { 1184e41f4b71Sopenharmony_ci if (err) { 1185e41f4b71Sopenharmony_ci console.error("getOpKey failed, err: " + JSON.stringify(err)); 1186e41f4b71Sopenharmony_ci } else { 1187e41f4b71Sopenharmony_ci console.log('getOpKey successfully, data: ' + JSON.stringify(data)); 1188e41f4b71Sopenharmony_ci } 1189e41f4b71Sopenharmony_ci }); 1190e41f4b71Sopenharmony_ci} catch (err) { 1191e41f4b71Sopenharmony_ci console.error("getOpKey err: " + JSON.stringify(err)); 1192e41f4b71Sopenharmony_ci} 1193e41f4b71Sopenharmony_ci``` 1194e41f4b71Sopenharmony_ci 1195e41f4b71Sopenharmony_ci 1196e41f4b71Sopenharmony_ci## sim.getOpKey<sup>9+</sup> 1197e41f4b71Sopenharmony_ci 1198e41f4b71Sopenharmony_cigetOpKey\(slotId: number\): Promise\<string\> 1199e41f4b71Sopenharmony_ci 1200e41f4b71Sopenharmony_ciObtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result. 1201e41f4b71Sopenharmony_ci 1202e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1203e41f4b71Sopenharmony_ci 1204e41f4b71Sopenharmony_ci**Parameters** 1205e41f4b71Sopenharmony_ci 1206e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 1207e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 1208e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1209e41f4b71Sopenharmony_ci 1210e41f4b71Sopenharmony_ci**Return value** 1211e41f4b71Sopenharmony_ci 1212e41f4b71Sopenharmony_ci| Type | Description | 1213e41f4b71Sopenharmony_ci| ---------------- | ----------------------------------------- | 1214e41f4b71Sopenharmony_ci| Promise<string\> | Promise used to return the result.| 1215e41f4b71Sopenharmony_ci 1216e41f4b71Sopenharmony_ci**Error codes** 1217e41f4b71Sopenharmony_ci 1218e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1219e41f4b71Sopenharmony_ci 1220e41f4b71Sopenharmony_ci| ID| Error Message | 1221e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1222e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1223e41f4b71Sopenharmony_ci| 801 | Capability not supported. | 1224e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1225e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1226e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1227e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1228e41f4b71Sopenharmony_ci 1229e41f4b71Sopenharmony_ci**Example** 1230e41f4b71Sopenharmony_ci 1231e41f4b71Sopenharmony_ci```ts 1232e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1233e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1234e41f4b71Sopenharmony_ci 1235e41f4b71Sopenharmony_cisim.getOpKey(0).then((data: string) => { 1236e41f4b71Sopenharmony_ci console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`); 1237e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 1238e41f4b71Sopenharmony_ci console.error(`getOpKey failed, promise: err->${JSON.stringify(err)}`); 1239e41f4b71Sopenharmony_ci}); 1240e41f4b71Sopenharmony_ci``` 1241e41f4b71Sopenharmony_ci 1242e41f4b71Sopenharmony_ci## sim.getOpKeySync<sup>10+</sup> 1243e41f4b71Sopenharmony_ci 1244e41f4b71Sopenharmony_cigetOpKeySync\(slotId: number\): string 1245e41f4b71Sopenharmony_ci 1246e41f4b71Sopenharmony_ciObtains the opkey of the SIM card in the specified slot. 1247e41f4b71Sopenharmony_ci 1248e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1249e41f4b71Sopenharmony_ci 1250e41f4b71Sopenharmony_ci**Parameters** 1251e41f4b71Sopenharmony_ci 1252e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 1253e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 1254e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1255e41f4b71Sopenharmony_ci 1256e41f4b71Sopenharmony_ci**Return value** 1257e41f4b71Sopenharmony_ci 1258e41f4b71Sopenharmony_ci| Type | Description | 1259e41f4b71Sopenharmony_ci| ---------------- | ----------------------------------------- | 1260e41f4b71Sopenharmony_ci| string | opkey of the SIM card in the specified slot.| 1261e41f4b71Sopenharmony_ci 1262e41f4b71Sopenharmony_ci 1263e41f4b71Sopenharmony_ci**Example** 1264e41f4b71Sopenharmony_ci 1265e41f4b71Sopenharmony_ci```ts 1266e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1267e41f4b71Sopenharmony_ci 1268e41f4b71Sopenharmony_cilet data: string = sim.getOpKeySync(0); 1269e41f4b71Sopenharmony_ciconsole.log(`getOpKey success, promise: data->${JSON.stringify(data)}`); 1270e41f4b71Sopenharmony_ci``` 1271e41f4b71Sopenharmony_ci 1272e41f4b71Sopenharmony_ci## sim.getOpName<sup>9+</sup> 1273e41f4b71Sopenharmony_ci 1274e41f4b71Sopenharmony_cigetOpName\(slotId: number, callback: AsyncCallback\<string\>\): void 1275e41f4b71Sopenharmony_ci 1276e41f4b71Sopenharmony_ciObtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 1277e41f4b71Sopenharmony_ci 1278e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1279e41f4b71Sopenharmony_ci 1280e41f4b71Sopenharmony_ci**Parameters** 1281e41f4b71Sopenharmony_ci 1282e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 1283e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | -------------------------------------- | 1284e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1285e41f4b71Sopenharmony_ci| callback | AsyncCallback<string\> | Yes | Callback used to return the result. | 1286e41f4b71Sopenharmony_ci 1287e41f4b71Sopenharmony_ci**Error codes** 1288e41f4b71Sopenharmony_ci 1289e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1290e41f4b71Sopenharmony_ci 1291e41f4b71Sopenharmony_ci| ID| Error Message | 1292e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1293e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1294e41f4b71Sopenharmony_ci| 801 | Capability not supported. | 1295e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1296e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1297e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1298e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1299e41f4b71Sopenharmony_ci 1300e41f4b71Sopenharmony_ci**Example** 1301e41f4b71Sopenharmony_ci 1302e41f4b71Sopenharmony_ci```ts 1303e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1304e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1305e41f4b71Sopenharmony_ci 1306e41f4b71Sopenharmony_citry { 1307e41f4b71Sopenharmony_ci sim.getOpName(0, (err: BusinessError, data: string) => { 1308e41f4b71Sopenharmony_ci if (err) { 1309e41f4b71Sopenharmony_ci console.error("getOpName failed, err: " + JSON.stringify(err)); 1310e41f4b71Sopenharmony_ci } else { 1311e41f4b71Sopenharmony_ci console.log('getOpName successfully, data: ' + JSON.stringify(data)); 1312e41f4b71Sopenharmony_ci } 1313e41f4b71Sopenharmony_ci }); 1314e41f4b71Sopenharmony_ci} catch (err) { 1315e41f4b71Sopenharmony_ci console.error("getOpName err: " + JSON.stringify(err)); 1316e41f4b71Sopenharmony_ci} 1317e41f4b71Sopenharmony_ci``` 1318e41f4b71Sopenharmony_ci 1319e41f4b71Sopenharmony_ci 1320e41f4b71Sopenharmony_ci## sim.getOpName<sup>9+</sup> 1321e41f4b71Sopenharmony_ci 1322e41f4b71Sopenharmony_cigetOpName\(slotId: number\): Promise\<string\> 1323e41f4b71Sopenharmony_ci 1324e41f4b71Sopenharmony_ciObtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result. 1325e41f4b71Sopenharmony_ci 1326e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1327e41f4b71Sopenharmony_ci 1328e41f4b71Sopenharmony_ci**Parameters** 1329e41f4b71Sopenharmony_ci 1330e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 1331e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 1332e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1333e41f4b71Sopenharmony_ci 1334e41f4b71Sopenharmony_ci**Return value** 1335e41f4b71Sopenharmony_ci 1336e41f4b71Sopenharmony_ci| Type | Description | 1337e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------ | 1338e41f4b71Sopenharmony_ci| Promise<string\> | Promise used to return the result.| 1339e41f4b71Sopenharmony_ci 1340e41f4b71Sopenharmony_ci**Error codes** 1341e41f4b71Sopenharmony_ci 1342e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1343e41f4b71Sopenharmony_ci 1344e41f4b71Sopenharmony_ci| ID| Error Message | 1345e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1346e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1347e41f4b71Sopenharmony_ci| 801 | Capability not supported. | 1348e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1349e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1350e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1351e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1352e41f4b71Sopenharmony_ci 1353e41f4b71Sopenharmony_ci**Example** 1354e41f4b71Sopenharmony_ci 1355e41f4b71Sopenharmony_ci```ts 1356e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1357e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1358e41f4b71Sopenharmony_ci 1359e41f4b71Sopenharmony_cisim.getOpName(0).then((data: string) => { 1360e41f4b71Sopenharmony_ci console.log(`getOpName success, promise: data->${JSON.stringify(data)}`); 1361e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 1362e41f4b71Sopenharmony_ci console.error(`getOpName failed, promise: err->${JSON.stringify(err)}`); 1363e41f4b71Sopenharmony_ci}); 1364e41f4b71Sopenharmony_ci``` 1365e41f4b71Sopenharmony_ci 1366e41f4b71Sopenharmony_ci## sim.getOpNameSync<sup>10+</sup> 1367e41f4b71Sopenharmony_ci 1368e41f4b71Sopenharmony_cigetOpNameSync\(slotId: number\): string 1369e41f4b71Sopenharmony_ci 1370e41f4b71Sopenharmony_ciObtains the OpName of the SIM card in the specified slot. 1371e41f4b71Sopenharmony_ci 1372e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1373e41f4b71Sopenharmony_ci 1374e41f4b71Sopenharmony_ci**Parameters** 1375e41f4b71Sopenharmony_ci 1376e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 1377e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------------------------- | 1378e41f4b71Sopenharmony_ci| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| 1379e41f4b71Sopenharmony_ci 1380e41f4b71Sopenharmony_ci**Return value** 1381e41f4b71Sopenharmony_ci 1382e41f4b71Sopenharmony_ci| Type | Description | 1383e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------ | 1384e41f4b71Sopenharmony_ci| string | OpName of the SIM card in the specified slot.| 1385e41f4b71Sopenharmony_ci 1386e41f4b71Sopenharmony_ci 1387e41f4b71Sopenharmony_ci**Example** 1388e41f4b71Sopenharmony_ci 1389e41f4b71Sopenharmony_ci```ts 1390e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1391e41f4b71Sopenharmony_ci 1392e41f4b71Sopenharmony_cilet data: string = sim.getOpNameSync(0); 1393e41f4b71Sopenharmony_ciconsole.log(`getOpName success, promise: data->${JSON.stringify(data)}`); 1394e41f4b71Sopenharmony_ci``` 1395e41f4b71Sopenharmony_ci 1396e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSimId<sup>10+</sup> 1397e41f4b71Sopenharmony_ci 1398e41f4b71Sopenharmony_cigetDefaultVoiceSimId\(callback: AsyncCallback\<number\>\): void 1399e41f4b71Sopenharmony_ci 1400e41f4b71Sopenharmony_ciObtains the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result. 1401e41f4b71Sopenharmony_ci 1402e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1403e41f4b71Sopenharmony_ci 1404e41f4b71Sopenharmony_ci**Parameters** 1405e41f4b71Sopenharmony_ci 1406e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 1407e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ---------- | 1408e41f4b71Sopenharmony_ci| callback | AsyncCallback<number> | Yes | Callback used to return the result.<br>The return value is bound to the SIM card and increases from 1.| 1409e41f4b71Sopenharmony_ci 1410e41f4b71Sopenharmony_ci**Error codes** 1411e41f4b71Sopenharmony_ci 1412e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1413e41f4b71Sopenharmony_ci 1414e41f4b71Sopenharmony_ci| ID| Error Message | 1415e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1416e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1417e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1418e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1419e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1420e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 1421e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1422e41f4b71Sopenharmony_ci| 8301001 | SIM card is not activated. | 1423e41f4b71Sopenharmony_ci 1424e41f4b71Sopenharmony_ci**Example** 1425e41f4b71Sopenharmony_ci 1426e41f4b71Sopenharmony_ci```ts 1427e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1428e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1429e41f4b71Sopenharmony_ci 1430e41f4b71Sopenharmony_cisim.getDefaultVoiceSimId((err: BusinessError, data: number) => { 1431e41f4b71Sopenharmony_ci console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); 1432e41f4b71Sopenharmony_ci}); 1433e41f4b71Sopenharmony_ci``` 1434e41f4b71Sopenharmony_ci 1435e41f4b71Sopenharmony_ci## sim.getDefaultVoiceSimId<sup>10+</sup> 1436e41f4b71Sopenharmony_ci 1437e41f4b71Sopenharmony_cigetDefaultVoiceSimId\(\): Promise\<number\> 1438e41f4b71Sopenharmony_ci 1439e41f4b71Sopenharmony_ciObtains the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result. 1440e41f4b71Sopenharmony_ci 1441e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1442e41f4b71Sopenharmony_ci 1443e41f4b71Sopenharmony_ci**Return value** 1444e41f4b71Sopenharmony_ci 1445e41f4b71Sopenharmony_ci| Type | Description | 1446e41f4b71Sopenharmony_ci| ----------------- | --------------------------------------- | 1447e41f4b71Sopenharmony_ci| Promise\<number\> | Promise used to return the result.<br>The return value is bound to the SIM card and increases from 1.| 1448e41f4b71Sopenharmony_ci 1449e41f4b71Sopenharmony_ci**Error codes** 1450e41f4b71Sopenharmony_ci 1451e41f4b71Sopenharmony_ciFor details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 1452e41f4b71Sopenharmony_ci 1453e41f4b71Sopenharmony_ci| ID| Error Message | 1454e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | 1455e41f4b71Sopenharmony_ci| 8300001 | Invalid parameter value. | 1456e41f4b71Sopenharmony_ci| 8300002 | Service connection failed. | 1457e41f4b71Sopenharmony_ci| 8300003 | System internal error. | 1458e41f4b71Sopenharmony_ci| 8300004 | No SIM card found. | 1459e41f4b71Sopenharmony_ci| 8300999 | Unknown error. | 1460e41f4b71Sopenharmony_ci| 8301001 | SIM card is not activated. | 1461e41f4b71Sopenharmony_ci 1462e41f4b71Sopenharmony_ci**Example** 1463e41f4b71Sopenharmony_ci 1464e41f4b71Sopenharmony_ci```ts 1465e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 1466e41f4b71Sopenharmony_ciimport { sim } from '@kit.TelephonyKit'; 1467e41f4b71Sopenharmony_ci 1468e41f4b71Sopenharmony_cilet promise = sim.getDefaultVoiceSimId(); 1469e41f4b71Sopenharmony_cipromise.then((data: number) => { 1470e41f4b71Sopenharmony_ci console.log(`getDefaultVoiceSimId success, promise: data->${JSON.stringify(data)}`); 1471e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 1472e41f4b71Sopenharmony_ci console.error(`getDefaultVoiceSimId failed, promise: err->${JSON.stringify(err)}`); 1473e41f4b71Sopenharmony_ci}); 1474e41f4b71Sopenharmony_ci``` 1475e41f4b71Sopenharmony_ci 1476e41f4b71Sopenharmony_ci 1477e41f4b71Sopenharmony_ci## SimState 1478e41f4b71Sopenharmony_ci 1479e41f4b71Sopenharmony_ciEnumerates SIM card states. 1480e41f4b71Sopenharmony_ci 1481e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1482e41f4b71Sopenharmony_ci 1483e41f4b71Sopenharmony_ci| Name | Value | Description | 1484e41f4b71Sopenharmony_ci| --------------------- | ---- | ---------------------------------------------------------- | 1485e41f4b71Sopenharmony_ci| SIM_STATE_UNKNOWN | 0 | The SIM card is in **unknown** state; that is, the SIM card status cannot be obtained. | 1486e41f4b71Sopenharmony_ci| SIM_STATE_NOT_PRESENT | 1 | The SIM card is in **not present** state; that is, no SIM card is inserted into the card slot. | 1487e41f4b71Sopenharmony_ci| SIM_STATE_LOCKED | 2 | The SIM card is in **locked** state; that is, the SIM card is locked by the personal identification number (PIN), PIN unblocking key (PUK), or network. | 1488e41f4b71Sopenharmony_ci| SIM_STATE_NOT_READY | 3 | The SIM card is in **not ready** state; that is, the SIM card has been installed but cannot work properly. | 1489e41f4b71Sopenharmony_ci| SIM_STATE_READY | 4 | The SIM card is in **ready** state; that is, the SIM card has been installed and is working properly. | 1490e41f4b71Sopenharmony_ci| SIM_STATE_LOADED | 5 | The SIM card is in **loaded** state; that is, the SIM card is present and all its files have been loaded.| 1491e41f4b71Sopenharmony_ci 1492e41f4b71Sopenharmony_ci## CardType<sup>7+</sup> 1493e41f4b71Sopenharmony_ci 1494e41f4b71Sopenharmony_ciEnumerates SIM card types. 1495e41f4b71Sopenharmony_ci 1496e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1497e41f4b71Sopenharmony_ci 1498e41f4b71Sopenharmony_ci| Name| Value| Description| 1499e41f4b71Sopenharmony_ci| ----- | ----- | ----- | 1500e41f4b71Sopenharmony_ci|UNKNOWN_CARD | -1 | Unknown type.| 1501e41f4b71Sopenharmony_ci|SINGLE_MODE_SIM_CARD | 10 | Single-card (SIM).| 1502e41f4b71Sopenharmony_ci|SINGLE_MODE_USIM_CARD | 20 | Single-card (USIM).| 1503e41f4b71Sopenharmony_ci|SINGLE_MODE_RUIM_CARD | 30 | Single-card (RUIM).| 1504e41f4b71Sopenharmony_ci|DUAL_MODE_CG_CARD | 40 | Dual-card (CDMA+GSM).| 1505e41f4b71Sopenharmony_ci|CT_NATIONAL_ROAMING_CARD | 41 | China Telecom internal roaming card.| 1506e41f4b71Sopenharmony_ci|CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card.| 1507e41f4b71Sopenharmony_ci|DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card.| 1508e41f4b71Sopenharmony_ci|DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM).| 1509e41f4b71Sopenharmony_ci|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | Single-card (ISIM).| 1510e41f4b71Sopenharmony_ci 1511e41f4b71Sopenharmony_ci## IccAccountInfo<sup>10+</sup> 1512e41f4b71Sopenharmony_ci 1513e41f4b71Sopenharmony_ciICC account information. 1514e41f4b71Sopenharmony_ci 1515e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Telephony.CoreService 1516e41f4b71Sopenharmony_ci 1517e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 1518e41f4b71Sopenharmony_ci| ---------- | ------- | ---- | ---------------- | 1519e41f4b71Sopenharmony_ci| simId | number | Yes | SIM card ID. | 1520e41f4b71Sopenharmony_ci| slotIndex | number | Yes | Card slot ID. | 1521e41f4b71Sopenharmony_ci| isEsim | boolean | Yes | Whether the SIM card is an eSim card.| 1522e41f4b71Sopenharmony_ci| isActive | boolean | Yes | Whether the card is activated. | 1523e41f4b71Sopenharmony_ci| iccId | string | Yes | ICCID number. | 1524e41f4b71Sopenharmony_ci| showName | string | Yes | SIM card display name. | 1525e41f4b71Sopenharmony_ci| showNumber | string | Yes | SIM card display number. | 1526