harmony 鸿蒙@ohos.telephony.esim (eSIM Management)

  • 2025-06-12
  • 浏览 (5)

@ohos.telephony.esim (eSIM Management)

The esim module provides basic eSIM management capabilities, including checking whether a specified card slot supports the eSIM function.

NOTE

The initial APIs of this module are supported since API version 18. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { eSIM } from '@kit.TelephonyKit';

eSIM.isSupported18+

isSupported(slotId: number): boolean

Checks whether the specified card slot supports the eSIM function.

System capability: SystemCapability.Telephony.CoreService.Esim

Parameters

Name Type Mandatory Description
slotId number Yes Card slot ID.
- 0: card slot 1.
- 1: card slot 2

Returns

Type Description
boolean A boolean value indicating whether the specified card slot supports the eSIM function. The value true indicates that the card slot supports the eSIM function, and the value false indicates the opposite.

Error codes

For details about the error codes, see Universal Error Codes.

ID Error Message
401 Invalid parameter value.
3120001 Service connection failed.
3120002 System internal error.

Example

import { eSIM } from '@kit.TelephonyKit';

let isSupported: boolean = eSIM.isSupported(0);
console.log(`the esim is Supported:` + isSupported);

eSIM.addProfile18+

addProfile(profile: DownloadableProfile): Promise<boolean>

Launches the download page for the user to add a single profile. This API uses a promise to return the result.

Required permissions: ohos.permission.SET_TELEPHONY_ESIM_STATE_OPEN

System capability: SystemCapability.Telephony.CoreService.Esim

Parameters

Name Type Mandatory Description
profile DownloadableProfile Yes Profile that can be downloaded.

Returns

Type Description
Promise<boolean> Promise used to return the result. The value true indicates that the operation is successful, and the value false indicates the opposite.

Error codes

For details about the error codes, see Universal Error Codes.

ID Error Message
201 Permission denied.
401 Invalid parameter value.
801 Capability not supported.
3120001 Service connection failed.
3120002 System internal error.

Example

import { BusinessError } from '@kit.BasicServicesKit';
import { eSIM } from '@kit.TelephonyKit';

let profile: eSIM.DownloadableProfile = {
  activationCode:'1',
  confirmationCode:'1',
  carrierName:'test',
  accessRules:[{
    certificateHashHexStr:'test',
    packageName:'com.example.testcoreservice',
    accessType:0
  }]
};

eSIM.addProfile(profile).then(() => {
    console.log(`addProfile invoking succeeded.`);
}).catch((err: BusinessError) => {
    console.error(`addProfile, promise: err->${JSON.stringify(err)}`);
});

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Telephony Kit

harmony 鸿蒙Telephony_NetworkState

harmony 鸿蒙Telephony Error Codes

harmony 鸿蒙js-apis-call-sys

harmony 鸿蒙@ohos.telephony.call (Call)

harmony 鸿蒙@ohos.telephony.esim (eSIM Management) (System API)

harmony 鸿蒙@ohos.telephony.observer (Observer) (System API)

harmony 鸿蒙@ohos.telephony.observer (Observer)

harmony 鸿蒙@ohos.telephony.radio (Radio) (System API)

harmony 鸿蒙@ohos.telephony.radio (Network Search)

0  赞