npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cordova-plugin-siminfo

v1.0.0

Published

Cordova plugin to fetch SIM card and device information on Android and iOS

Readme

cordova-plugin-siminfo

A Cordova plugin to retrieve SIM card and device information on Android and iOS platforms.

Features

  • ✅ Get SIM card information (carrier, country code, subscription ID)
  • ✅ Support for dual SIM devices
  • ✅ Device ID retrieval
  • ✅ eSIM availability detection (Android)
  • ✅ SIM slot status checking
  • ✅ Cross-platform support (Android & iOS)

Installation

Install from npm

cordova plugin add cordova-plugin-siminfo

Install from GitHub

cordova plugin add https://github.com/nikhilbhanda/cordova-plugin-siminfo.git

Install locally

cordova plugin add /path/to/cordova-plugin-siminfo

Supported Platforms

  • Android (API 21+)
  • iOS (12.0+)

Usage

Basic Example

// Call the plugin method
SimInfo.getSimInfo(
    function(result) {
        console.log('SIM Info:', result);
        // Handle success
    },
    function(error) {
        console.error('Error:', error);
        // Handle error
    }
);

Response Format

Android Response

{
    "deviceId": "android_device_id",
    "eSimAvailable": true,
    "isSimInserted": true,
    "isBothSimInserted": false,
    "simSlotsWithSim": [0],
    "sims": [
        {
            "slot": 0,
            "carrier_id": "Carrier Name",
            "country_code": "us",
            "subscription_id": 12345
        },
        {
            "slot": 1,
            "info": "No SIM Installed"
        }
    ],
    "UniqueData": "deviceId=android_device_id_country_code=us_subscription_id=12345_carrier_id=Carrier Name"
}

iOS Response

{
    "default": {
        "carrierName": "Carrier Name",
        "mobileCountryCode": "310",
        "mobileNetworkCode": "260",
        "isoCountryCode": "us",
        "allowsVOIP": true
    }
}

Complete Integration Example

document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady() {
    // Check if plugin is available
    if (window.SimInfo) {
        getSimInformation();
    } else {
        console.error('SimInfo plugin not available');
    }
}

function getSimInformation() {
    SimInfo.getSimInfo(
        function(result) {
            console.log('Success! SIM Info received:');
            
            // Platform-specific handling
            if (device.platform === 'Android') {
                console.log('Device ID:', result.deviceId);
                console.log('eSIM Available:', result.eSimAvailable);
                console.log('SIM Inserted:', result.isSimInserted);
                console.log('Both SIMs Inserted:', result.isBothSimInserted);
                
                result.sims.forEach(function(sim, index) {
                    console.log('SIM Slot ' + sim.slot + ':', sim);
                });
            } else if (device.platform === 'iOS') {
                console.log('iOS Carrier Info:', result);
            }
        },
        function(error) {
            console.error('Failed to get SIM info:', error);
        }
    );
}

Permissions

Android

The plugin automatically adds the required permission to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Important: Starting from Android 6.0 (API level 23), you need to request this permission at runtime. You may want to use a permissions plugin like cordova-plugin-android-permissions to handle runtime permissions.

Runtime Permission Example

// Check if we have permission
var permissions = cordova.plugins.permissions;
permissions.checkPermission(
    permissions.READ_PHONE_STATE,
    function(status) {
        if (!status.hasPermission) {
            // Request permission
            permissions.requestPermission(
                permissions.READ_PHONE_STATE,
                function(status) {
                    if (status.hasPermission) {
                        // Permission granted, get SIM info
                        SimInfo.getSimInfo(successCallback, errorCallback);
                    }
                },
                errorCallback
            );
        } else {
            // Already have permission
            SimInfo.getSimInfo(successCallback, errorCallback);
        }
    },
    null
);

iOS

The plugin uses the CoreTelephony framework. No special permissions are required in most cases, but carrier information availability depends on iOS restrictions and carrier configurations.

API Reference

Methods

getSimInfo(successCallback, errorCallback)

Retrieves SIM and device information.

Parameters:

  • successCallback (Function): Called with the SIM information object
  • errorCallback (Function): Called with an error message string

Returns: void

Android Response Fields

| Field | Type | Description | |-------|------|-------------| | deviceId | String | Android device ID (ANDROID_ID) | | eSimAvailable | Boolean | Whether the device supports eSIM | | isSimInserted | Boolean | Whether at least one SIM is inserted | | isBothSimInserted | Boolean | Whether both SIM slots have SIMs (dual SIM devices) | | simSlotsWithSim | Array | Array of slot indices that have SIMs inserted | | sims | Array | Array of SIM information objects | | UniqueData | String | Concatenated unique identifier string |

iOS Response Fields

| Field | Type | Description | |-------|------|-------------| | carrierName | String | Name of the carrier | | mobileCountryCode | String | Mobile Country Code (MCC) | | mobileNetworkCode | String | Mobile Network Code (MNC) | | isoCountryCode | String | ISO country code | | allowsVOIP | Boolean | Whether the carrier allows VoIP |

Troubleshooting

Android

Issue: "Permission denied" error

  • Solution: Make sure you've requested the READ_PHONE_STATE permission at runtime on Android 6.0+

Issue: Getting "No SIM Installed" for all slots

  • Solution: Check if SIM cards are properly inserted and the device has cellular capability

Issue: Empty carrier information

  • Solution: Some carriers or devices may not provide complete information. This is a limitation of the Android API.

iOS

Issue: Empty carrier information

  • Solution: iOS restricts carrier information access. Some information may not be available depending on iOS version and carrier configuration.

Issue: Getting null values

  • Solution: Make sure the device has an active cellular connection and valid SIM card.

Platform Differences

| Feature | Android | iOS | |---------|---------|-----| | Device ID | ✅ ANDROID_ID | ❌ Not available | | Dual SIM support | ✅ Full support | ⚠️ Limited (iOS 12+) | | eSIM detection | ✅ Available | ❌ Not provided | | Subscription ID | ✅ Available | ❌ Not available | | SIM slot info | ✅ Available | ⚠️ Limited |

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

If you encounter any issues, please report them on the GitHub Issues page.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Nikhil Bhanda [email protected]

Changelog

1.0.0

  • Initial release
  • Android support with dual SIM
  • iOS support with CoreTelephony
  • eSIM detection (Android)
  • Device ID retrieval (Android)