openharmony 鸿蒙 js-apis-esim

2025-06-12 浏览 (1)

@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

NameTypeMandatoryDescription
slotIdnumberYesCard slot ID.
- 0: card slot 1.
- 1: card slot 2

Returns

TypeDescription
booleanA 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.

IDError Message
401Invalid parameter value.
3120001Service connection failed.
3120002System 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

NameTypeMandatoryDescription
profileDownloadableProfileYesProfile that can be downloaded.

Returns

TypeDescription
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.

IDError Message
201Permission denied.
401Invalid parameter value.
801Capability not supported.
3120001Service connection failed.
3120002System 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)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/YOboF9