react-native-esim

November 18, 2020 · View on GitHub

This package exposes iOS API to install eSIM plans. Android support is planned in the future.

Warning: This API won't work without eSIM entitlement. You can read more about it here

Note: At the moment (iOS 14.2) there might a bug in iOS SDK which returns uknown result before eSIM setup completion. More about it here

Installation

npm install react-native-esim

You then need to link the native parts of the library for the platforms you are using.

Linking in React Native >= 0.60

Linking the package is not required anymore with Autolinking.

  • iOS Platform:

    $ npx pod-install

Linking in React Native < 0.60

The easiest way to link the library is using the CLI tool by running this command from the root of your project:

react-native link react-native-esim

If you can't or don't want to use the CLI tool, you can also manually link the library using the instructions below (click on the arrow to show them):

Manually link the library on iOS

Either follow the instructions in the React Native documentation to manually link the framework or link using Cocoapods by adding this to your Podfile:

pod 'react-native-esim', :path => '../node_modules/react-native-esim'

Usage

import EsimManager from "react-native-esim";

// ...
EsimManager.isEsimSupported()
  .then((result) => {
    // result might be true or false
  })
  .catch((error) => {
    // you might get and error if app wasn't configured correctly
    // or device iOS version is lower than required minimum
  });
  
const config = {
  address: "";
  confirmationCode: "";
  eid: "";
  iccid: "";
  matchingId: "";
  oid: "";
}
  
EsimManager.setupEsim(config)
  .then((result) => {
    // result might be success/fail/uknown
  })
  .catch((error) => {
    // you might get an error if app wasn't configured correctly
    // or passed configuration is invalid
  });

API

Methods

MethodParameterDescription
isEsimSupportedvoidThis method only checks to ensure that the device supports eSIM installation. Returns boolean. Might throw an error.
setupEsimEsimConfigStarts the provisioning process for a specified eSIM. Might throw and error. Returns EsimSetupResultStatus

EsimConfig

PropertyTypeRequiredDescription
addressstringtrueThe address of the carrier network’s eSIM server.
confirmationCodestringfalseThe provisioning request’s confirmation code, provided by the network operator when initiating an eSIM download.
eidstringfalseThe provisioning request’s eUICC identifier (EID).
iccidstringfalseThe provisioning request’s Integrated Circuit Card Identifier (ICCID).
matchingIdstringfalseThe provisioning request’s matching identifier (MatchingID).
oidstringfalseThe provisioning request’s Object Identifier (OID).

EsimSetupResultStatus

StatusTypeValue
Unknown0
Fail1
Success2

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT