pocesar / react-native-sim-data Goto Github PK
View Code? Open in Web Editor NEWReact Native plugin to get the device's SIM data (carrier name, mcc mnc, country code, phone number, etc)
License: MIT License
React Native plugin to get the device's SIM data (carrier name, mcc mnc, country code, phone number, etc)
License: MIT License
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
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.
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:+'
}
When I try to use this package, getSimInfo() is undefined. Any solution?
it is returning phone number as null, we could able to get all the remaining values.
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
com.facebook.react.common.JavascriptException: C++ Exception in 'NativeModules': java.lang.NoSuchMethodError: android.telephony.TelephonyManager.getPhoneCount
react native - v44
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.
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
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.
Device: Honor 10 Lite
SIM: 2 sim card
Permission: Granted
Result: Returns Null
"react-native": "0.54.0",
"react-native-sim-data": "^3.0.0"
Granted Runtime PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE,
RNSimData.getSimInfo().phoneNumber0: null countryCode0 gives: ""
i am facing this issue for phone number and carrier name also
undefind is not an object (evaluating '_reactNativeSimData.default.getSimInfo().carrierName0')
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()…)
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.
Is there anyway for using in IOS Device?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.