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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-carrier-info

v1.1.2

Published

React Native module bridge to obtain information about the user’s home cellular service provider.

Downloads

10,758

Readme

React Native Carrier Info

npm version npm downloads

React Native module bridge to obtain information about the user’s home cellular service provider.

Makes use of the following native classes:

Version

1.0.0

  • Android support
  • Promosify all APIs
  • RN 0.47 support

API

All APIs are async functions

allowsVOIP (iOS only)

boolean allowsVOIP() - Indicates if the carrier allows VoIP calls to be made on its network.
  • If you configure a device for a carrier and then remove the SIM card, this property retains the Boolean value indicating the carrier’s policy regarding VoIP.
  • Always return true on Android.

carrierName

string carrierName() - The name of the user’s home cellular service provider.
  • This string is provided by the carrier and formatted for presentation to the user. The value does not change if the user is roaming; it always represents the provider with whom the user has an account.
  • If you configure a device for a carrier and then remove the SIM card, this property retains the name of the carrier.
  • The value for this property is 'nil' if the device was never configured for a carrier.

isoCountryCode

string isoCountryCode() - The ISO country code for the user’s cellular service provider.
  • This property uses the ISO 3166-1 country code representation.
  • The value for this property is 'nil' if any of the following apply:
    • The device is in Airplane mode.
    • There is no SIM card in the device.
    • The device is outside of cellular service range.

mobileCountryCode

string mobileCountryCode() - The mobile country code (MCC) for the user’s cellular service provider.
  • MCCs are defined by ITU-T Recommendation E.212, “List of Mobile Country or Geographical Area Codes.”
  • The value for this property is 'nil' if any of the following apply:
    • There is no SIM card in the device.
    • The device is outside of cellular service range.
  • The value may be 'nil' on hardware prior to iPhone 4S when in Airplane mode.

mobileNetworkCode

string mobileNetworkCode() - The mobile network code (MNC) for the user’s cellular service provider.
  • The value for this property is 'nil' if any of the following apply:
    • There is no SIM card in the device.
    • The device is outside of cellular service range.
  • The value may be 'nil' on hardware prior to iPhone 4S when in Airplane mode.

mobileNetworkOperator

string mobileNetworkOperator() - return MCC + MNC, e.g 46697

Getting Started (and running the demo project)

iOS

  1. From inside your project run npm install react-native-carrier-info --save
  2. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  3. Go to node_modules/react-native-carrier-info/ios and add RNCarrierInfo.xcodeproj
  4. In XCode, in the project navigator, select your project. Add libRNCarrierInfo.a to your project's Build PhasesLink Binary With Libraries
  5. Click RNCarrierInfo.xcodeproj in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.
  6. Set up the project to run on your device (iOS simulator does not report cellular provider info)
  7. Run your project (Cmd+R)

Android

  • app/build.gradle

dependencies {
  ...
  compile project(':react-native-carrier-info') <-- add this
  ...

}
  • settings.gradle

include ':react-native-carrier-info'
project(':react-native-carrier-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-carrier-info/android')
  • MainApplication.java

...
import com.ianlin.RNCarrierInfo.RNCarrierInfoPackage; <-- add this
...

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    ...
    new RNCarrierInfoPackage(), <-- add this
    ...
  );
}

Usage Example


import CarrierInfo from 'react-native-carrier-info';

// inside your code where you would like to retrieve carrier info
CarrierInfo.allowsVOIP()
.then((result) => {
  Alert.alert('Allows VoIP', JSON.stringify(result));
});

CarrierInfo.carrierName()
.then((result) => {
  Alert.alert('Carrier Name', result);
});

CarrierInfo.isoCountryCode()
.then((result) => {
  Alert.alert('ISO', result);
});

CarrierInfo.mobileCountryCode()
.then((result) => {
  Alert.alert('MCC', result);
});

CarrierInfo.mobileNetworkCode()
.then((result) => {
  Alert.alert('MNC', result);
});

CarrierInfo.mobileNetworkOperator()
.then((result) => {
  Alert.alert('MCC + MNC', result);
});

There is an example project supplied with the repo in the RNCarrierInfoDemo folder. The sample app needs to be run on a device as the simulator does not report cellular provider info.

Original Author:

anarchicknight

License

ISC License (functionality equivalent to MIT License)