Coder Social home page Coder Social logo

aachauhan2009 / react-native-sim-data Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pocesar/react-native-sim-data

1.0 1.0 0.0 410 KB

React Native plugin to get the device's SIM data (carrier name, mcc mnc, country code, phone number, etc)

License: MIT License

Java 56.10% TypeScript 10.81% JavaScript 23.27% Shell 3.29% Starlark 6.53%

react-native-sim-data's Introduction

Build Status npm version

react-native-sim-data

React Native plugin to get the device's SIM data (carrier name, mcc mnc, country code, phone number, etc)

Installation

$ npm i react-native-sim-data
$ react-native link react-native-sim-data

Supported Platforms

  • Android

Usage

import RNSimData from 'react-native-sim-data'

RNSimData.getSimInfo().deviceId0
/**
  the object has the following info (change 0 to access more than 1 SIM):

  carrierName0: string;
  displayName0: string;
  countryCode0: string;
  mcc0: string;
  mnc0: string;
  isNetworkRoaming0: string;
  isDataRoaming0: string;
  simSlotIndex0: string;
  phoneNumber0: string;
  deviceId0: string;
  simSerialNumber0: string;
  subscriptionId0: string;
*/

//shortcut for RNSimData.getSimInfo().phoneNumber0
RNSimData.getTelephoneNumber()
//shortcut for RNSimData.getSimInfo().carrierName0
RNSimData.getCarrierName()
//shortcut for RNSimData.getSimInfo().countryCode0
RNSimData.getCountryCode()

NOTE: React Native "Modules", when having only constants, work with getters, and the result of getSimInfo() is undefined, you need to access the properties to get any info

Caveats

Might crash if tries to use in a phone without any SIM cards.

Permissions

WARNING: Minimum API Level is 22

This plugin uses two different Android APIs to receive SIM data:

  • TelephonyManager (since API level 1)
  • SubscriptionManager (since API level 22)

Since Android 6 (API level 23) a few methods of TelephonyManager require permission READ_PHONE_STATE.

All methods of SubscriptionManager require permission READ_PHONE_STATE.

SubscriptionManager is able to access multiple SIM data.

You'll also need to include implementation 'com.google.android.gms:play-services-gcm:+' in your android/app/build.gradle (or any version that suits you)

react-native-sim-data's People

Contributors

pocesar avatar sigrlami avatar aachauhan2009 avatar dependabot[bot] avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.