├── .gitignore ├── .npmignore ├── .travis.yml ├── Example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── App.js ├── __tests__ │ ├── App-test.js │ └── __snapshots__ │ │ └── App-test.js.snap ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── build_defs.bzl │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── metro.config.js ├── package-lock.json └── package.json ├── LICENSE ├── README.md ├── android ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── eu │ └── sigrlami │ └── rnsimdata │ ├── RNSimDataModule.java │ └── RNSimDataReactPackage.java ├── extend.d.ts ├── index.ts ├── package-lock.json ├── package.json ├── prepare.sh └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | node_modules 3 | 4 | # Mobile Tools for Java (J2ME) 5 | .mtj.tmp/ 6 | 7 | android/build 8 | 9 | # Package Files # 10 | *.jar 11 | !gradle/wrapper/gradle-wrapper.jar 12 | *.war 13 | *.ear 14 | 15 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 16 | hs_err_pid* 17 | 18 | index.d.ts 19 | index.js.map 20 | index.js -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | android/build 2 | tsconfig.json 3 | index.ts 4 | Example 5 | prepare.sh 6 | .travis.yml -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | sudo: required 3 | cache: 4 | directories: 5 | - $HOME/.gradle/caches/ 6 | - $HOME/.gradle/wrapper/ 7 | before_install: 8 | - yes | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28" 9 | - yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;28.0.3" 10 | - nvm install 12 11 | - node --version 12 | - npm i typescript react-native-cli -g --progress=false 13 | install: 14 | - chmod +x ./prepare.sh 15 | script: ./prepare.sh 16 | android: 17 | components: 18 | # Uncomment the lines below if you want to 19 | # use the latest revision of Android SDK Tools 20 | - tools 21 | - platform-tools 22 | 23 | # The BuildTools version used by your project 24 | - build-tools-26.0.1 25 | - android-26 26 | 27 | # Additional components 28 | - extra-google-google_play_services 29 | - extra-google-m2repository 30 | - extra-android-m2repository 31 | - addon-google_apis-google-24 32 | 33 | # Specify at least one system image, 34 | # if you need to run emulator(s) during your tests 35 | - sys-img-armeabi-v7a-google_apis-25 36 | - extra-android-support 37 | 38 | licenses: 39 | - android-sdk-preview-license-.+ 40 | - android-sdk-license-.+ 41 | - google-gdk-license-.+ 42 | node_js: 43 | - "12" -------------------------------------------------------------------------------- /Example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; -------------------------------------------------------------------------------- /Example/.flowconfig: -------------------------------------------------------------------------------- 1 | node_modules/react-native/Libraries/react-native/React.js 2 | node_modules/react-native/Libraries/polyfills/.* 3 | ; These should not be required directly 4 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 5 | node_modules/warning/.* 6 | ; Flow doesn't support platforms 7 | .*/Libraries/Utilities/HMRLoadingView.js 8 | [untyped] 9 | .*/node_modules/@react-native-community/cli/.*/.* 10 | 11 | [include] 12 | 13 | [options] 14 | emoji=true 15 | 16 | esproposal.optional_chaining=enable 17 | esproposal.nullish_coalescing=enable 18 | module.file_ext=.js 19 | module.file_ext=.json 20 | module.file_ext=.ios.js 21 | 22 | module.system=haste 23 | module.system.haste.use_name_reducers=true 24 | # get basename 25 | module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' 26 | # strip .js or .js.flow suffix 27 | module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' 28 | # strip .ios suffix 29 | module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' 30 | module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' 31 | module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' 32 | module.system.haste.paths.blacklist=.*/__tests__/.* 33 | module.system.haste.paths.blacklist=.*/__mocks__/.* 34 | module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* 35 | module.system.haste.paths.whitelist=/node_modules/react-native/RNTester/.* 36 | module.system.haste.paths.whitelist=/node_modules/react-native/IntegrationTests/.* 37 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/react-native/react-native-implementation.js 38 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* 39 | 40 | munge_underscores=true 41 | 42 | suppress_type=$FlowFixMe 43 | suppress_type=$FlowFixMeProps 44 | suppress_type=$FlowFixMeState 45 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 46 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 48 | 49 | [lints] 50 | sketchy-null-number=warn 51 | sketchy-null-mixed=warn 52 | sketchy-number=warn 53 | untyped-type-import=warn 54 | nonstrict-import=warn 55 | deprecated-type=warn 56 | unsafe-getters-setters=warn 57 | inexact-spread=warn 58 | unnecessary-invariant=warn 59 | signature-verification-failure=warn 60 | deprecated-utility=error 61 | [strict] 62 | deprecated-type 63 | nonstrict-import 64 | sketchy-null 65 | unclear-type 66 | unsafe-getters-setters 67 | untyped-import 68 | untyped-type-import 69 | 70 | [version] 71 | ^0.98.0 -------------------------------------------------------------------------------- /Example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | # Bundle artifact 39 | *.jsbundle 40 | 41 | # BUCK 42 | buck-out/ 43 | \.buckd/ 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/Preview.html 54 | fastlane/screenshots 55 | 56 | !index.js -------------------------------------------------------------------------------- /Example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Example/App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | * @flow 7 | */ 8 | 9 | import React, { Component } from 'react'; 10 | import { 11 | StyleSheet, 12 | Text, 13 | View 14 | } from 'react-native'; 15 | import RNSimData from 'react-native-sim-data' 16 | 17 | export default class Example extends Component { 18 | render() { 19 | return ( 20 | 21 | 22 | {JSON.stringify(RNSimData.getSimInfo())} 23 | 24 | 25 | ); 26 | } 27 | } 28 | 29 | const styles = StyleSheet.create({ 30 | container: { 31 | flex: 1, 32 | justifyContent: 'center', 33 | alignItems: 'center', 34 | backgroundColor: '#F5FCFF', 35 | }, 36 | welcome: { 37 | fontSize: 20, 38 | textAlign: 'center', 39 | margin: 10, 40 | }, 41 | instructions: { 42 | textAlign: 'center', 43 | color: '#333333', 44 | marginBottom: 5, 45 | }, 46 | }); 47 | -------------------------------------------------------------------------------- /Example/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import Index from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | const tree = renderer.create( 14 | 15 | ); 16 | expect(tree).toMatchSnapshot() 17 | }); 18 | -------------------------------------------------------------------------------- /Example/__tests__/__snapshots__/App-test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`renders correctly 1`] = ` 4 | 14 | 23 | 24 | `; 25 | -------------------------------------------------------------------------------- /Example/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | create_jar_targets(glob(["libs/*.jar"])) 17 | 18 | android_library( 19 | name = "all-libs", 20 | exported_deps = lib_deps, 21 | ) 22 | 23 | android_library( 24 | name = "app-code", 25 | srcs = glob([ 26 | "src/main/java/**/*.java", 27 | ]), 28 | deps = [ 29 | ":all-libs", 30 | ":build_config", 31 | ":res", 32 | ], 33 | ) 34 | 35 | android_build_config( 36 | name = "build_config", 37 | package = "com.example", 38 | ) 39 | 40 | android_resource( 41 | name = "res", 42 | package = "com.example", 43 | res = "src/main/res", 44 | ) 45 | 46 | android_binary( 47 | name = "app", 48 | keystore = "//android/keystores:debug", 49 | manifest = "src/main/AndroidManifest.xml", 50 | package_type = "debug", 51 | deps = [ 52 | ":app-code", 53 | ], 54 | ) 55 | -------------------------------------------------------------------------------- /Example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | project.ext.react = [ 76 | entryFile: "index.js", 77 | enableHermes: false, // clean and rebuild if changing 78 | ] 79 | 80 | apply from: "../../node_modules/react-native/react.gradle" 81 | 82 | /** 83 | * Set this to true to create two separate APKs instead of one: 84 | * - An APK that only works on ARM devices 85 | * - An APK that only works on x86 devices 86 | * The advantage is the size of the APK is reduced by about 4MB. 87 | * Upload all the APKs to the Play Store and people will download 88 | * the correct one based on the CPU architecture of their device. 89 | */ 90 | def enableSeparateBuildPerCPUArchitecture = false 91 | 92 | /** 93 | * Run Proguard to shrink the Java bytecode in release builds. 94 | */ 95 | def enableProguardInReleaseBuilds = false 96 | 97 | /** 98 | * The preferred build flavor of JavaScriptCore. 99 | * 100 | * For example, to use the international variant, you can use: 101 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 102 | * 103 | * The international variant includes ICU i18n library and necessary data 104 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 105 | * give correct results when using with locales other than en-US. Note that 106 | * this variant is about 6MiB larger per architecture than default. 107 | */ 108 | def jscFlavor = 'org.webkit:android-jsc:+' 109 | /** 110 | * Whether to enable the Hermes VM. 111 | * 112 | * This should be set on project.ext.react and mirrored here. If it is not set 113 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 114 | * and the benefits of using Hermes will therefore be sharply reduced. 115 | */ 116 | def enableHermes = project.ext.react.get("enableHermes", false); 117 | 118 | android { 119 | compileSdkVersion rootProject.ext.compileSdkVersion 120 | 121 | compileOptions { 122 | sourceCompatibility JavaVersion.VERSION_1_8 123 | targetCompatibility JavaVersion.VERSION_1_8 124 | } 125 | 126 | defaultConfig { 127 | applicationId "com.example" 128 | minSdkVersion rootProject.ext.minSdkVersion 129 | targetSdkVersion rootProject.ext.targetSdkVersion 130 | versionCode 1 131 | versionName "1.0" 132 | } 133 | splits { 134 | abi { 135 | reset() 136 | enable enableSeparateBuildPerCPUArchitecture 137 | universalApk false // If true, also generate a universal APK 138 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 139 | } 140 | } 141 | signingConfigs { 142 | debug { 143 | storeFile file('debug.keystore') 144 | storePassword 'android' 145 | keyAlias 'androiddebugkey' 146 | keyPassword 'android' 147 | } 148 | } 149 | buildTypes { 150 | debug { 151 | signingConfig signingConfigs.debug 152 | } 153 | release { 154 | signingConfig signingConfigs.debug 155 | minifyEnabled enableProguardInReleaseBuilds 156 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 157 | } 158 | } 159 | // applicationVariants are e.g. debug, release 160 | applicationVariants.all { variant -> 161 | variant.outputs.each { output -> 162 | // For each separate APK per architecture, set a unique version code as described here: 163 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 164 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 165 | def abi = output.getFilter(OutputFile.ABI) 166 | if (abi != null) { // null for the universal-debug, universal-release variants 167 | output.versionCodeOverride = 168 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 169 | } 170 | } 171 | } 172 | 173 | packagingOptions { 174 | pickFirst '**/armeabi-v7a/libc++_shared.so' 175 | pickFirst '**/x86/libc++_shared.so' 176 | pickFirst '**/arm64-v8a/libc++_shared.so' 177 | pickFirst '**/x86_64/libc++_shared.so' 178 | pickFirst '**/x86/libjsc.so' 179 | pickFirst '**/armeabi-v7a/libjsc.so' 180 | } 181 | } 182 | 183 | dependencies { 184 | implementation fileTree(dir: "libs", include: ["*.jar"]) 185 | implementation "com.facebook.react:react-native:+" // From node_modules 186 | if (enableHermes) { 187 | def hermesPath = "../../node_modules/hermesvm/android/"; 188 | debugImplementation files(hermesPath + "hermes-debug.aar") 189 | releaseImplementation files(hermesPath + "hermes-release.aar") 190 | } else { 191 | implementation jscFlavor 192 | } 193 | } 194 | 195 | // Run this once to be able to run the application with BUCK 196 | // puts all compile dependencies into folder libs for BUCK to use 197 | task copyDownloadableDepsToLibs(type: Copy) { 198 | from configurations.compile 199 | into 'libs' 200 | } 201 | 202 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 203 | -------------------------------------------------------------------------------- /Example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pocesar/react-native-sim-data/63ce01e96ebb70a0bdf5d573e4c703a62a83caf4/Example/android/app/debug.keystore -------------------------------------------------------------------------------- /Example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | -------------------------------------------------------------------------------- /Example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Example/android/app/src/main/java/com/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "Example"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Example/android/app/src/main/java/com/example/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.PackageList; 7 | import com.facebook.hermes.reactexecutor.HermesExecutorFactory; 8 | import com.facebook.react.bridge.JavaScriptExecutorFactory; 9 | import com.facebook.react.ReactApplication; 10 | import com.facebook.react.ReactNativeHost; 11 | import com.facebook.react.ReactPackage; 12 | import com.facebook.soloader.SoLoader; 13 | 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for example: 29 | // packages.add(new MyReactNativePackage()); 30 | return packages; 31 | } 32 | 33 | @Override 34 | protected String getJSMainModuleName() { 35 | return "index"; 36 | } 37 | }; 38 | 39 | @Override 40 | public ReactNativeHost getReactNativeHost() { 41 | return mReactNativeHost; 42 | } 43 | 44 | @Override 45 | public void onCreate() { 46 | super.onCreate(); 47 | SoLoader.init(this, /* native exopackage */ false); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pocesar/react-native-sim-data/63ce01e96ebb70a0bdf5d573e4c703a62a83caf4/Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pocesar/react-native-sim-data/63ce01e96ebb70a0bdf5d573e4c703a62a83caf4/Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pocesar/react-native-sim-data/63ce01e96ebb70a0bdf5d573e4c703a62a83caf4/Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pocesar/react-native-sim-data/63ce01e96ebb70a0bdf5d573e4c703a62a83caf4/Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example 3 | 4 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "28.0.3" 6 | minSdkVersion = 16 7 | compileSdkVersion = 28 8 | targetSdkVersion = 28 9 | supportLibVersion = "28.0.0" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:3.4.1") 17 | 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | mavenLocal() 26 | maven { 27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 28 | url("$rootDir/../node_modules/react-native/android") 29 | } 30 | maven { 31 | // Android JSC is installed from npm 32 | url("$rootDir/../node_modules/jsc-android/dist") 33 | } 34 | google() 35 | jcenter() 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Example/android/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | def create_aar_targets(aarfiles): 3 | for aarfile in aarfiles: 4 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 5 | lib_deps.append(":" + name) 6 | android_prebuilt_aar( 7 | name = name, 8 | aar = aarfile, 9 | ) 10 | def create_jar_targets(jarfiles): 11 | for jarfile in jarfiles: 12 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 13 | lib_deps.append(":" + name) 14 | prebuilt_jar( 15 | name = name, 16 | binary_jar = jarfile, 17 | ) -------------------------------------------------------------------------------- /Example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | -------------------------------------------------------------------------------- /Example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pocesar/react-native-sim-data/63ce01e96ebb70a0bdf5d573e4c703a62a83caf4/Example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /Example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | # Attempt to set APP_HOME 11 | # Resolve links: $0 may be a link 12 | PRG="$0" 13 | # Need this for relative symlinks. 14 | while [ -h "$PRG" ] ; do 15 | ls=`ls -ld "$PRG"` 16 | link=`expr "$ls" : '.*-> \(.*\)$'` 17 | if expr "$link" : '/.*' > /dev/null; then 18 | PRG="$link" 19 | else 20 | PRG=`dirname "$PRG"`"/$link" 21 | fi 22 | done 23 | SAVED="`pwd`" 24 | cd "`dirname \"$PRG\"`/" >/dev/null 25 | APP_HOME="`pwd -P`" 26 | cd "$SAVED" >/dev/null 27 | 28 | APP_NAME="Gradle" 29 | APP_BASE_NAME=`basename "$0"` 30 | 31 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 32 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 33 | 34 | # Use the maximum available, or set MAX_FD != -1 to use that value. 35 | MAX_FD="maximum" 36 | 37 | warn ( ) { 38 | echo "$*" 39 | } 40 | 41 | die ( ) { 42 | echo 43 | echo "$*" 44 | echo 45 | exit 1 46 | } 47 | 48 | # OS specific support (must be 'true' or 'false'). 49 | cygwin=false 50 | msys=false 51 | darwin=false 52 | nonstop=false 53 | case "`uname`" in 54 | CYGWIN* ) 55 | cygwin=true 56 | ;; 57 | Darwin* ) 58 | darwin=true 59 | ;; 60 | MINGW* ) 61 | msys=true 62 | ;; 63 | NONSTOP* ) 64 | nonstop=true 65 | ;; 66 | esac 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | JAVACMD=`cygpath --unix "$JAVACMD"` 118 | 119 | # We build the pattern for arguments to be converted via cygpath 120 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 121 | SEP="" 122 | for dir in $ROOTDIRSRAW ; do 123 | ROOTDIRS="$ROOTDIRS$SEP$dir" 124 | SEP="|" 125 | done 126 | OURCYGPATTERN="(^($ROOTDIRS))" 127 | # Add a user-defined pattern to the cygpath arguments 128 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 129 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 130 | fi 131 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 132 | i=0 133 | for arg in "$@" ; do 134 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 135 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 136 | 137 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 138 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 139 | else 140 | eval `echo args$i`="\"$arg\"" 141 | fi 142 | i=$((i+1)) 143 | done 144 | case $i in 145 | (0) set -- ;; 146 | (1) set -- "$args0" ;; 147 | (2) set -- "$args0" "$args1" ;; 148 | (3) set -- "$args0" "$args1" "$args2" ;; 149 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 150 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 151 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 152 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 153 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 154 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 155 | esac 156 | fi 157 | 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | 163 | APP_ARGS=$(save "$@") 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 167 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 168 | cd "$(dirname "$0")" 169 | fi 170 | 171 | exec "$JAVACMD" "$@" -------------------------------------------------------------------------------- /Example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | 64 | :execute 65 | @rem Setup the command line 66 | 67 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 68 | 69 | @rem Execute Gradle 70 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 71 | 72 | :end 73 | @rem End local scope for the variables with windows NT shell 74 | if "%ERRORLEVEL%"=="0" goto mainEnd 75 | 76 | :fail 77 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 78 | rem the _cmd.exe /c_ return code! 79 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 80 | exit /b 1 81 | 82 | :mainEnd 83 | if "%OS%"=="Windows_NT" endlocal 84 | 85 | :omega 86 | -------------------------------------------------------------------------------- /Example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Example' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Example", 3 | "displayName": "Example" 4 | } -------------------------------------------------------------------------------- /Example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; -------------------------------------------------------------------------------- /Example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /Example/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | module.exports = { 8 | transformer: { 9 | getTransformOptions: async () => ({ 10 | transform: { 11 | experimentalImportSupport: false, 12 | inlineRequires: false, 13 | }, 14 | }), 15 | }, 16 | }; -------------------------------------------------------------------------------- /Example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "react-native start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "^16.8.6", 11 | "react-native": "^0.60.4", 12 | "react-native-sim-data": "*" 13 | }, 14 | "devDependencies": { 15 | "@babel/core": "^7.5.0", 16 | "@babel/runtime": "^7.5.0", 17 | "@react-native-community/eslint-config": "^0.0.3", 18 | "metro-react-native-babel-preset": "^0.54.1", 19 | "react-native-cli": "^2.0.1", 20 | "babel-jest": "^24.8.0", 21 | "babel-preset-react-native": "^4.0.1", 22 | "jest": "^24.8.0", 23 | "react-test-renderer": "^16.8.6" 24 | }, 25 | "jest": { 26 | "preset": "react-native" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Sergey Bushnyak 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/pocesar/react-native-sim-data.svg?branch=master)](https://travis-ci.org/pocesar/react-native-sim-data) [![npm version](https://badge.fury.io/js/react-native-sim-data.svg)](https://badge.fury.io/js/react-native-sim-data) 2 | 3 | # react-native-sim-data 4 | 5 | React Native plugin to get the device's SIM data (carrier name, mcc mnc, country code, phone number, etc) 6 | 7 | ## Installation 8 | 9 | ``` 10 | $ npm i react-native-sim-data 11 | $ react-native link react-native-sim-data 12 | ``` 13 | 14 | ## Supported Platforms 15 | 16 | - Android 17 | 18 | ## Usage 19 | 20 | ```es6 21 | import RNSimData from 'react-native-sim-data' 22 | 23 | RNSimData.getSimInfo().deviceId0 24 | /** 25 | the object has the following info (change 0 to access more than 1 SIM): 26 | 27 | carrierName0: string; 28 | displayName0: string; 29 | countryCode0: string; 30 | mcc0: string; 31 | mnc0: string; 32 | isNetworkRoaming0: string; 33 | isDataRoaming0: string; 34 | simSlotIndex0: string; 35 | phoneNumber0: string; 36 | deviceId0: string; 37 | simSerialNumber0: string; 38 | subscriptionId0: string; 39 | */ 40 | 41 | //shortcut for RNSimData.getSimInfo().phoneNumber0 42 | RNSimData.getTelephoneNumber() 43 | //shortcut for RNSimData.getSimInfo().carrierName0 44 | RNSimData.getCarrierName() 45 | //shortcut for RNSimData.getSimInfo().countryCode0 46 | RNSimData.getCountryCode() 47 | ``` 48 | 49 | NOTE: React Native "Modules", when having only constants, work with getters, and the result of `getSimInfo()` is 50 | undefined, you need to access the properties to get any info 51 | 52 | ### Caveats 53 | 54 | Might crash if tries to use in a phone without any SIM cards. 55 | 56 | ### Permissions 57 | 58 | **WARNING: Minimum API Level is 22** 59 | 60 | This plugin uses two different Android APIs to receive SIM data: 61 | - `TelephonyManager` (since API level 1) 62 | - `SubscriptionManager` (since API level 22) 63 | 64 | Since Android 6 (API level 23) a few methods of `TelephonyManager` require permission `READ_PHONE_STATE`. 65 | 66 | All methods of `SubscriptionManager` require permission `READ_PHONE_STATE`. 67 | 68 | `SubscriptionManager` is able to access multiple SIM data. 69 | 70 | 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) 71 | 72 | 73 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | def safeExtGet(prop, fallback) { 4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 5 | } 6 | 7 | android { 8 | compileSdkVersion safeExtGet('compileSdkVersion', 26) 9 | buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3') 10 | 11 | defaultConfig { 12 | minSdkVersion 16 13 | targetSdkVersion safeExtGet('targetSdkVersion', 26) 14 | versionCode 1 15 | versionName "1.0" 16 | } 17 | lintOptions { 18 | warning 'InvalidPackage' 19 | } 20 | } 21 | 22 | dependencies { 23 | compileOnly 'com.facebook.react:react-native:+' 24 | compileOnly 'com.google.android.gms:play-services-gcm:+' 25 | } 26 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/src/main/java/eu/sigrlami/rnsimdata/RNSimDataModule.java: -------------------------------------------------------------------------------- 1 | package eu.sigrlami.rnsimdata; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.List; 6 | 7 | import android.content.Context; 8 | import android.telephony.TelephonyManager; 9 | import android.telephony.SubscriptionInfo; 10 | import android.telephony.SubscriptionManager; 11 | 12 | import com.facebook.react.bridge.ReactApplicationContext; 13 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 14 | import com.facebook.react.bridge.ReactMethod; 15 | import com.facebook.react.bridge.Callback; 16 | 17 | public class RNSimDataModule extends ReactContextBaseJavaModule { 18 | 19 | ReactApplicationContext reactContext; 20 | 21 | public RNSimDataModule(ReactApplicationContext reactContext) { 22 | super(reactContext); 23 | this.reactContext = reactContext; 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return "RNSimDataModule"; 29 | } 30 | 31 | @Override 32 | public Map getConstants() { 33 | 34 | final Map constants = new HashMap<>(); 35 | 36 | try { 37 | TelephonyManager telManager = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE); 38 | 39 | SubscriptionManager manager = (SubscriptionManager) this.reactContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); 40 | List subscriptionInfos = manager.getActiveSubscriptionInfoList(); 41 | 42 | int sub = 0; 43 | for (SubscriptionInfo subInfo : subscriptionInfos) { 44 | CharSequence carrierName = subInfo.getCarrierName(); 45 | String countryIso = subInfo.getCountryIso(); 46 | int dataRoaming = subInfo.getDataRoaming(); // 1 is enabled ; 0 is disabled 47 | CharSequence displayName = subInfo.getDisplayName(); 48 | String iccId = subInfo.getIccId(); 49 | int mcc = subInfo.getMcc(); 50 | int mnc = subInfo.getMnc(); 51 | String number = subInfo.getNumber(); 52 | int simSlotIndex = subInfo.getSimSlotIndex(); 53 | int subscriptionId = subInfo.getSubscriptionId(); 54 | boolean networkRoaming = telManager.isNetworkRoaming(); 55 | String deviceId = telManager.getDeviceId(simSlotIndex); 56 | //String deviceId = telManager.getImei(simSlotIndex) || telManager.getMeid(simSlotIndex); 57 | 58 | constants.put("carrierName" + sub, carrierName.toString()); 59 | constants.put("displayName" + sub, displayName.toString()); 60 | constants.put("countryCode" + sub, countryIso); 61 | constants.put("mcc" + sub, mcc); 62 | constants.put("mnc" + sub, mnc); 63 | constants.put("isNetworkRoaming" + sub, networkRoaming); 64 | constants.put("isDataRoaming" + sub, (dataRoaming == 1)); 65 | constants.put("simSlotIndex" + sub, simSlotIndex); 66 | constants.put("phoneNumber" + sub, number); 67 | constants.put("deviceId" + sub, deviceId); 68 | constants.put("simSerialNumber" + sub, iccId); 69 | constants.put("subscriptionId" + sub, subscriptionId); 70 | sub++; 71 | } 72 | } catch (Exception e) { 73 | e.printStackTrace(); 74 | } 75 | 76 | return constants; 77 | } 78 | } -------------------------------------------------------------------------------- /android/src/main/java/eu/sigrlami/rnsimdata/RNSimDataReactPackage.java: -------------------------------------------------------------------------------- 1 | package eu.sigrlami.rnsimdata; 2 | 3 | import java.util.Arrays; 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.bridge.NativeModule; 10 | import com.facebook.react.bridge.ReactApplicationContext; 11 | import com.facebook.react.uimanager.ViewManager; 12 | import com.facebook.react.bridge.JavaScriptModule; 13 | 14 | public class RNSimDataReactPackage implements ReactPackage { 15 | 16 | @Override 17 | public List createNativeModules(ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | modules.add(new RNSimDataModule(reactContext)); 20 | return modules; 21 | } 22 | 23 | public List> createJSModules() { 24 | return Collections.emptyList(); 25 | } 26 | 27 | @Override 28 | public List createViewManagers(ReactApplicationContext reactContext) { 29 | return Collections.emptyList(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /extend.d.ts: -------------------------------------------------------------------------------- 1 | import { RNSimData } from './index' 2 | import 'react-native' 3 | 4 | declare module 'react-native' { 5 | export interface NativeModulesStatic { 6 | RNSimDataModule: RNSimData 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | 'use strict' 4 | 5 | import { NativeModules } from 'react-native' 6 | 7 | export interface RNSimData { 8 | carrierName0: string; 9 | displayName0: string; 10 | countryCode0: string; 11 | mcc0: string; 12 | mnc0: string; 13 | isNetworkRoaming0: string; 14 | isDataRoaming0: string; 15 | simSlotIndex0: string; 16 | phoneNumber0: string; 17 | deviceId0: string; 18 | simSerialNumber0: string; 19 | subscriptionId0: string; 20 | carrierName1: string; 21 | displayName1: string; 22 | countryCode1: string; 23 | mcc1: string; 24 | mnc1: string; 25 | isNetworkRoaming1: string; 26 | isDataRoaming1: string; 27 | simSlotIndex1: string; 28 | phoneNumber1: string; 29 | deviceId1: string; 30 | simSerialNumber1: string; 31 | subscriptionId1: string; 32 | } 33 | 34 | const RNSimData = NativeModules.RNSimDataModule 35 | 36 | export default { 37 | getSimInfo() { 38 | return RNSimData 39 | }, 40 | getTelephoneNumber() { 41 | return RNSimData.phoneNumber0 42 | }, 43 | getCarrierName() { 44 | return RNSimData.carrierName0 45 | }, 46 | getCountryCode() { 47 | return RNSimData.countryCode0 48 | } 49 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-sim-data", 3 | "version": "2.0.4", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-sim-data", 3 | "version": "3.0.0", 4 | "description": "React Native plugin to get the device's SIM data (carrier name, mcc mnc, country code, phone number, etc)", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/pocesar/react-native-sim-data" 9 | }, 10 | "scripts": { 11 | "compile": "tsc -p tsconfig.json", 12 | "prepublishOnly": "npm run compile" 13 | }, 14 | "typings": "index.d.ts", 15 | "keywords": [ 16 | "react-component", 17 | "react-native", 18 | "android", 19 | "device", 20 | "sim", 21 | "phone number" 22 | ], 23 | "peerDependencies": { 24 | "@types/react": "*", 25 | "@types/react-native": "*", 26 | "react": "*", 27 | "react-native": "*" 28 | }, 29 | "author": "Sergey Bushnyak (https://github.com/sigrlami)", 30 | "license": "MIT" 31 | } 32 | -------------------------------------------------------------------------------- /prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | npm install react react-native @types/react @types/react-native --no-save 4 | npm run compile 5 | npm link 6 | cd Example 7 | npm install 8 | npm link react-native-sim-data 9 | #react-native link react-native-sim-data 10 | cd android && chmod +x gradlew && ./gradlew clean && ./gradlew assembleDebug && cd .. 11 | npm test 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "noImplicitAny": true, 6 | "sourceMap": true, 7 | "strict": true, 8 | "removeComments": false, 9 | "declaration": true, 10 | "inlineSourceMap": false, 11 | "lib": [ 12 | "es6" 13 | ], 14 | "moduleResolution": "node" 15 | }, 16 | "files": [ 17 | "./index.ts" 18 | ] 19 | } --------------------------------------------------------------------------------