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

Overview

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)

Comments
  • Error compiling with React Native 0.57.0

    Error compiling with React Native 0.57.0

    After updating to the last version of React Native (0.57.0) I can not compile and build the APK because of the error below:

    :react-native-carrier-info:verifyReleaseResources
    error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
    error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
    /root/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/1f4e1fccb69ec83f875c934344078536/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
        
    /root/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/1f4e1fccb69ec83f875c934344078536/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.
        
    /root/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/1f4e1fccb69ec83f875c934344078536/res/values-v26/values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
        
    /root/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/1f4e1fccb69ec83f875c934344078536/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontStyle not found.
        
    /root/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/1f4e1fccb69ec83f875c934344078536/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/font not found.
        
    /root/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/1f4e1fccb69ec83f875c934344078536/res/values/values.xml:251:5-69: AAPT: error: resource android:attr/fontWeight not found.
        
    error: failed linking references.
    :react-native-carrier-info:verifyReleaseResources FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':react-native-carrier-info:verifyReleaseResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute aapt
    

    Any solution for that?

    opened by enoler 6
  • feat: add cocoapods support for react-native 0.60 auto-linking

    feat: add cocoapods support for react-native 0.60 auto-linking

    This appears to work for me in my app - note that it is different than the default recommended podspec template from the react-native 0.60 upgrade docs (they recommend react-native-webview) in that the iOS folder here has a demo project in it, so instead of doing a **/*.{h,m} I specified the actual sub-folder

    opened by mikehardy 5
  • Release 1.1.2 is not on releases

    Release 1.1.2 is not on releases

    Hello I'm updating the lib because I need it for RN 0.60. I see the commit, and I see that the last commit says release 1.1.2. But I can't see that on the releases section of github (says last is 1.1.2). Is it possible that the tag was not added?

    opened by raimonkh 3
  • Safely access getSimOperator in case of empty string

    Safely access getSimOperator in case of empty string

    I have a tablet that returns an empty string from getSimOperator but we only check for null - this makes the module's APIs safe in case of empty strings

    opened by mikehardy 1
  • Use external gradle dependencies if available, current ones if not

    Use external gradle dependencies if available, current ones if not

    This PR converts the module to the style most react-native modules are using now - first it looks for external versions, and only defaults to internal (updated now) versions if the external ones don't exist

    Should fix #9

    opened by mikehardy 1
  • Roaming

    Roaming

    When the users device is roaming i.e. they are in another country (e.g. UK) to their normal "home" (e.g. USA) country, does the device return the roaming network?

    opened by domwebb 1
  • Updated Android project to match iOS functions

    Updated Android project to match iOS functions

    On iOS, the mobileNetworkCode and related fields always return information based on the SIM installed in the device. This means the actual network code that the device is using is not available.

    On Android we have a choice between getting the SIM or the actual network MCC & MNC data. The SIM and network code are different when the device is roaming for example.

    To be consistent between the platforms, the functions should use the SIM information exclusively on Android.

    opened by drash-course 1
  • Support for dual sim

    Support for dual sim

    When the following method is used on a dual sim device with two active sim cards inserted, the method below returns the second sim's MCC + MNC. When the second sim is removed, the first sim's MCC + MNC is reported correctly. I am writing to check if it is possible to request a feature to get both sims' results.

    CarrierInfo.mobileNetworkOperator()
    .then((result) => {
      Alert.alert('MCC + MNC', result);
    });
    
    opened by melvinchng 1
Owner
React Native WebRTC
A home for all things around React Native and WebRTC
React Native WebRTC
A react-native interface for Touch 3D home screen quick actions

React Native Quick Actions Support for the new 3D Touch home screen quick actions for your React Native apps! This project currently supports iOS 9+ a

Jordan Byron 1000 Sep 22, 2022
Creating secure routes and saving user information in SecureStore

React Native, sistema de login social nativo usando uma conta do Google Primeiro passo clonar o repositório git clone [email protected]:r-santtos/Stu

Ricardo Santos 1 Dec 11, 2021
React Native bridge to InApp Billing on Android.

InApp Billing for Android React Native Billing is built to provide an easy interface to InApp Billing on Android, accomplished by wrapping anjlab's In

Idéhub 637 Sep 1, 2022
React Native Library for OneSignal Push Notifications Service

React Native OneSignal SDK OneSignal is a free push notification service for mobile apps. This SDK makes it easy to integrate your native React-Native

OneSignal 1.4k Sep 24, 2022
React native geolocation service for iOS and android

React native geolocation service for iOS and android

Iftekhar Rifat 1.4k Sep 25, 2022
Device Information for React Native iOS and Android

react-native-device-info Device Information for React Native. TOC Installation Linking Usage API Troubleshooting Release Notes react-native-dom / reac

null 5.9k Sep 29, 2022
React Native plug-in that provides GPS location information

react-native-location Native GPS location support for React Native. You might decide to use this library over the built-in geolocation because it incl

Tim Park 833 Sep 20, 2022
Simple React hook for displaying ENS names (Ethereum name service)

use-ens-name Simple React hook for displaying ENS names (Ethereum name service).

David Mihal 3 Apr 16, 2022
Get device heading information on iOS or Android

React Native Heading Get device heading information on iOS or Android What Report back device orientation in degrees, 0-360, with 0 being North. Examp

Yonah Forst 37 Nov 4, 2021
react-native native module for In App Purchase.

Announcement React Native IAP hook is out. You can see medium post on how to use it. The react-native-iap module hasn't been maintained well recently.

dooboolab 2.2k Sep 23, 2022
react native module for firebase cloud messaging and local notification

Deprecated I'm not longer able to maintain this repo. check react-native-firebase instead To existing react-native-fcm users react-native-firebase now

Libin Lu 1.7k Sep 15, 2022
React Native Module for IOS Calendar Reminders

React Native Calendar Reminders React Native Module for IOS Calendar Reminders Install npm install --save react-native-calendar-reminders Link Librar

Will McMahan 87 Apr 21, 2022
A react native android module to list/send sms.

Sms for react-native android A react native android module to list/send sms. Setup There are five steps in the setup process. Install the module via n

Mohammed Makhlouf 58 Sep 9, 2022
This is a react native module that sends a basic sms text message to a phone number for android.

react-native-sms-android This is a react native module that sends a sms message to a phone number. There are two options for sending a sms: 1) directl

G. Haker 52 Feb 9, 2022
This simple React Native module for Android Text To Speech functionality.

React Native Android Text To Speech A react native android wrapper for Text To speech Purpose Currently , React Native doesn't have inbuilt support fo

Mihir Soni 47 Nov 10, 2020
The SearchApi module gives you a general React Native interface to interact with the iOS Search API, Core Spotlight.

React Native Search Api module The SearchApi module gives you a general React Native interface to interact with the iOS Search API, Core Spotlight. Fo

Ombori Group 35 Sep 27, 2022
React Native Module for MapKit Local Search

React-Native-LocalSearch React Native Module for IOS MapKit Local Search Install npm install --save react-native-localsearch Then add RNLocalSearch t

Will McMahan 19 Oct 25, 2021
A simple react native module to interact with OpenVPN

react-native-simple-openvpn English | 简体中文 A simple react native module to interact with OpenVPN Versions RNSimpleOpenvpn React Native 0.56 ~ 0.65 Pre

Nor Cod 30 Sep 16, 2022
Module Onboarding react native

react-native-onboarding A simple and fully customizable React Native component that implements a onboardin stepper. Try this example on Snack. Install

Mateo Nieto Hoyos 4 Aug 29, 2022