This is a Nativescript plugin to get data from the SIM card like the carrier name, mcc, mnc and country code and other system dependent additional info.
Peter Bakondy for his work on cordova-plugin-sim. Basically this is his plugin. I followed his source code as a guide.
- Android
- iOS
tns plugin add nativescript-telephony
import {Telephony} from 'nativescript-telephony';
Telephony().then(function(resolved) {
console.log('resolved >', resolved)
console.dir(resolved);
}).catch(function(error) {
console.error('error >', error)
console.dir(error);
})
If you are unfamiliar with Promises, read up on these:
{
"carrierName": String,
"countryCode": String,
"mcc": String,
"mnc": String,
"allowsVOIP": Boolean,
}
Sadly there's nothing more we can get here.
When using an emulator or a sim card does not exist.
All permission dialogues are built into the Telephony
function.
{
"countryCode": String,
"simOperator": String,
"carrierName": String,
"callState": Number,
"dataActivity": Number,
"networkType": Number,
"phoneType": Number,
"simState": Number,
"isNetworkRoaming": Boolean,
"mcc": String,
"mnc": String,
}
{
// START GRANTED PERMISSIONS
"phoneNumber": String,
"deviceId": String,
"deviceSoftwareVersion": String,
"simSerialNumber": String,
"subscriberId": String,
// END GRANTED PERMISSIONS
"countryCode": String,
"simOperator": String,
"carrierName": String,
"callState": Number,
"dataActivity": Number,
"networkType": Number,
"phoneType": Number,
"simState": Number,
"isNetworkRoaming": Boolean,
"mcc": String,
"mnc": String,
}
Never.
npm run setup
# iOS
npm run demo.ios
# Android
npm run demo.android
This plugin is licensed under the MITlicense by Rob Laverty