$ yarn add @ammora/react-native-iccid
$ react-native link @ammora/react-native-iccid
-
Append the following lines to
android/settings.gradle
:include ':@ammora_react-native-iccid' project(':@ammora_react-native-iccid').projectDir = new File(rootProject.projectDir, '../node_modules/@ammora/react-native-iccid/android')
-
Add to
android/app/src/main/AndroidManifest.xml
the following permission:<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
-
Open up
android/app/src/main/java/.../MainApplication.java
- Add
import com.ammora.RNIccid.RNIccidPackage;
to the imports at the top of the file - Add
new RNIccidPackage()
to the list returned by thegetPackages()
method
import ICCID from '@ammora/react-native-iccid';
ICCID.getIccid(0) // Parameter slot is required
.then(iccid => {
console.log(`Simcard at slot #${slot} got ICCID ${iccid}`);
})
.catch(e => {
console.log(`Error trying to get ICCID from device simcard at slot #${slot}`);
console.log(e);
});