๐Ÿ“ฑ react-native-sim-cards-manager

February 10, 2025 ยท View on GitHub

A unified library merging features from multiple SIM card management libraries:


๐Ÿš€ Why use this library?

โœ… Unified APIs for eSIM and SIM data management.
โœ… Bug fixes and enhancements for improved stability.
โœ… Simplified transition from previous libraries (requires some code adaptation).


๐Ÿ“ฆ Installation

Install the package using npm:

npm install react-native-sim-cards-manager

๐Ÿ›  Debugging

Android

To debug device logs during eSIM setup, use the following command:

adb logcat | grep "Euicc"

๐Ÿ” Permissions

Android

  • Minimum API Level: 22
  • Add the following permission in AndroidManifest.xml for TelephonyManager:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

For eSIM features:

  • For regular apps, follow the instructions in the carrier privileges guide.
  • For system apps, include the following permission:
<uses-permission android:name="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS" />

More details here.

iOS

  • Minimum API Level: 12 (eSIM features)
  • Requires eSIM entitlement. Learn more here.

โš ๏ธ Note: As of iOS 14.2, there is a known bug where an unknown result may be returned before completing eSIM setup. Details here.


๐Ÿ“– Usage

๐Ÿ“ฒ Retrieve SIM Cards

Fetch a list of SIM cards. The result may contain no elements (if no SIM cards are detected) or multiple entries.

๐Ÿ“Œ Method: getSimCards

Handles permission requests and accepts an optional _rationale_ parameter.

import SimCardsManagerModule from 'react-native-sim-cards-manager';

SimCardsManagerModule.getSimCards({
  title: 'App Permission',
  message: 'Custom message',
  buttonNeutral: 'Not now',
  buttonNegative: 'Not OK',
  buttonPositive: 'OK',
})
  .then((array: Array<any>) => {
    // Handle results
  })
  .catch((error) => {
    // Handle errors
  });

๐Ÿ“Œ Method: getSimCardsNative

Used internally by getSimCards. Does not handle permissions.

import SimCardsManagerModule from 'react-native-sim-cards-manager';

SimCardsManagerModule.getSimCardsNative()
  .then((array: Array<any>) => {
    // Handle results
  })
  .catch((error) => {
    // Handle errors
  });

๐Ÿ“Š Available Data

FieldiOSAndroid
carrierNameโœ…โœ…
displayNameโŒโœ…
isoCountryCodeโœ…โœ…
mobileCountryCodeโœ…โœ…
mobileNetworkCodeโœ…โœ…
isNetworkRoamingโŒโœ…
isDataRoamingโŒโœ…
simSlotIndexโŒโœ…
phoneNumberโŒโœ…
simSerialNumberโŒโœ…
subscriptionIdโŒโœ…
allowsVOIPโœ…โŒ

๐Ÿ” eSIM Support Check

Verify if the device supports eSIM functionality.

import SimCardsManagerModule from 'react-native-sim-cards-manager';

SimCardsManagerModule.isEsimSupported()
  .then((isSupported: boolean) => {
    // Handle result
  })
  .catch((error) => {
    // Handle errors
  });

โš™๏ธ eSIM Setup

Configure an eSIM using an activation code.

๐Ÿ“Œ Parameters

FieldMandatoryDescription
addressN/ACarrier network's eSIM server address.
confirmationCodeN/AConfirmation code for eSIM provisioning.
eidN/AeUICC identifier.
iccidN/AIntegrated Circuit Card Identifier.
matchingIdN/AMatching identifier for the eSIM profile.
oidN/AObject Identifier for the provisioning request.

โš ๏ธ Error Codes

CodeDescription
0Feature not available.
1Device does not support cellular plans.
2OS failed to add the plan.
3 (iOS)Unknown OS error.
3 (Android)OS or Intent/Activity error.
import SimCardsManagerModule from 'react-native-sim-cards-manager';

SimCardsManagerModule.setupEsim({
  confirmationCode,
  address: '',
})
  .then((isPlanAdded: boolean) => {
    // Handle success
  })
  .catch((error) => {
    // Handle errors
  });

๐Ÿ‘จโ€๐Ÿ’ป Contributing

Read the Contributing Guide for details on how to contribute to the project.


๐Ÿ“œ License

MIT License.