Giter Site home page Giter Site logo

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

View Code? Open in Web Editor NEW
61.0 9.0 29.0 865 KB

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

License: MIT License

Java 60.71% TypeScript 10.60% JavaScript 19.05% Shell 3.23% Starlark 6.41%
react-native java javascript mobile carrier phone typescript

react-native-sim-data's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-sim-data's Issues

Android Studio and compile warnings

Enviroment

  • React Native: 0.60.4
  • React Native Sim Data: 2.0.3
  • Android Studio: 3.4.1
  • Gradle: 5.4.1
  • Build Tools: 28.0.1

Problem

  1. Configuration 'compile' is obsolete and has been replaced with 'implementation':
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: react-native-sim-data
  1. The specified Android SDK Build Tools is ignored:
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

Solution

Just update the build.gradle:

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
    // compileSdkVersion 23
    compileSdkVersion safeExtGet('compileSdkVersion', 23)
    // buildToolsVersion "23.0.1"
    buildToolsVersion safeExtGet('buildToolsVersion', '23.0.1')

    // ...
}

dependencies {
    // provided 'com.facebook.react:react-native:+'
    compileOnly 'com.facebook.react:react-native:+'
    // provided 'com.google.android.gms:play-services-gcm:+'
    compileOnly 'com.google.android.gms:play-services-gcm:+'
}

phoneNumber0

it is returning phone number as null, we could able to get all the remaining values.

.getSimInfo() method is giving null object error.

After creating an object of the
const simData = RNSimData.getSimInfo();
while accessing the method, the method returns
[TypeError: null is not an object (evaluating 'simData.simSerialNumber0')] error.
Permission has been given in AndroidManifest file

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

app forcefully closed with this error on os version < 21

app forcefully closed with this error on os version < 21

com.facebook.react.common.JavascriptException: C++ Exception in 'NativeModules': java.lang.NoSuchMethodError: android.telephony.TelephonyManager.getPhoneCount

react native - v44

Showing old Sim data

If app is in background or in foreground and I change the Sim card, it keeps showing old Sim's details. I had to kill the app and re-open it to get latest data. Can we pull latest Sim details on the run instead of on App start.

Android 10 version issue in emulator

RNSimData.getSimInfo() return undefined in android 10 emulator
check real device in android 9 working fine , but android 10 emulator not working.

Please suggest me. how to get sim info above android 9 version

Thanks

App gets Sim data on second load

Install the app on your phone and you wont get the Sim details at first load. Kill the app and reopen or reload it then only you will get the Sim data.

undefind is not an object

i am facing this issue for phone number and carrier name also
undefind is not an object (evaluating '_reactNativeSimData.default.getSimInfo().carrierName0')

react native sim data doesn’t work in ejected project

unfortunately react-native-sim-data doesnt work in ejected project.
I Try this module in a new react native project and it works fine.
But when try to use It in ejected project It returns null.
with this code

  <Button title="permission" onPress={()=>{   PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE);}}></Button>
          <Button title="sss" onPress={()=>{  var x=RNSimData.getSimInfo().deviceId0;
  if(x!=null)alert(x); else alert('nooooo');}}></Button>

first Butoon for getting permission and second one for getting device Id But it returns:

null is not an Object(evaluating _reactnativesimdata getinfo()…)

FAILURE: Build failed with an exception.

Since I linked the package my app wont build anymore.

the ... in path is a placeholder for the real path of the project.

.../MainApplication.java:19: error: package eu.sigrlami.rsnsimdata does not exist
import eu.sigrlami.rsnsimdata.RNSimDataReactPackage;

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

settings.gradle:

include ':react-native-sim-data'
project(':react-native-sim-data').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sim-data/android')

build.gradle:

    compile 'com.google.android.gms:play-services-gcm:+'
    compile project(':react-native-sim-data')

MainApplication.java:

import eu.sigrlami.rsnsimdata.RNSimDataReactPackage;

 @Override
  public List<ReactPackage> createAdditionalReactPackages() {

    // Add additional packages you require here
    return Arrays.<ReactPackage>asList(
            // eg. new VectorIconsPackage()
              ....
            new RNSimDataReactPackage()

    );

Am I missing something here?
All other dependencies I got work fine this way.

RN: 0.55.4
RNSiMData: 2.0.3

node module package is installed successfully.

EDIT:

the import in MainApplication did not get set by link, so i set it manually and ended up with rsnsimdata instead of rnsimdata...
Now it builds just fine.

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.