cordova-plugin-sim
Advanced tools
Comparing version 1.2.1 to 1.3.0
{ | ||
"name": "cordova-plugin-sim", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, imei, etc)", | ||
@@ -5,0 +5,0 @@ "cordova": { |
# cordova-plugin-sim | ||
[](https://codeclimate.com/github/pbakondy/cordova-plugin-sim) | ||
 | ||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=R7STJ6V2PNEMA) | ||
@@ -52,19 +54,58 @@ This is a cordova plugin to get data from the SIM card like the carrier name, mcc, mnc and country code and other system dependent additional info. | ||
You can find the name of mobile provider using [mcc-mnc-list](https://www.npmjs.com/package/mcc-mnc-list) npm package. | ||
## Android Quirks | ||
Additional return values: | ||
### Requirements | ||
* `phoneNumber`: String - phone number string for line 1, for example, the [MSISDN](http://en.wikipedia.org/wiki/MSISDN) for a GSM phone <sup>1</sup> | ||
* `deviceId`: String - the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones | ||
* `deviceSoftwareVersion`: String - the software version number for the device, for example, the IMEI/SV for GSM phones | ||
* `simSerialNumber`: String - the serial number of the SIM, if applicable | ||
* `subscriberId`: String - the unique subscriber ID, for example, the IMSI for a GSM phone | ||
* `callState`: Number - the call state (cellular) on the device | ||
* `dataActivity`: Number - the type of activity on a data connection (cellular) | ||
* `networkType`: Number - the NETWORK_TYPE_xxxx for current data connection | ||
* `phoneType`: Number - the device phone type. This indicates the type of radio used to transmit voice calls | ||
* `simState`: Number - the state of the device SIM card | ||
* `isNetworkRoaming`: Boolean - true if the device is considered roaming on the current network, for GSM purposes | ||
Install `Extras` / `Android Support Library` from Android SDK. | ||
### Under the hood | ||
This plugin uses two different Android APIs to receive SIM data: | ||
- `TelephonyManager` (since API level 1) | ||
- `SubscriptionManager` (since API level 22) | ||
Since Android 6 (API level 23) a few methods of `TelephonyManager` require permission `READ_PHONE_STATE`. | ||
All methods of `SubscriptionManager` require permission `READ_PHONE_STATE`. | ||
`SubscriptionManager` is able to access multiple SIM data. The return object of this cordova plugin provides the details of the available sim cards in an array (`cards`). | ||
### Return object | ||
- `carrierName`: {String} Service Provider Name (SPN) | ||
- `countryCode`: {String} ISO country code equivalent for the SIM provider's country code | ||
- `mcc`: {String} MCC (mobile country code) of the provider of the SIM | ||
- `mnc`: {String} MNC (mobile network code) of the provider of the SIM | ||
- `callState`: {Number} call state (cellular) on the device | ||
- `dataActivity`: {Number} type of activity on a data connection (cellular) | ||
- `networkType`: {Number} the NETWORK_TYPE_xxxx for current data connection | ||
- `phoneType`: {Number} device phone type. This indicates the type of radio used to transmit voice calls | ||
- `simState`: {Number} the state of the device SIM card | ||
- `isNetworkRoaming`: {Boolean} true if the device is considered roaming on the current network, for GSM purposes | ||
- `phoneCount`: {Number} the number of phones available. Returns 0 if none of voice, sms, data is not supported. Returns 1 for Single standby mode (Single SIM functionality). Returns 2 for Dual standby mode (Dual SIM functionality) | ||
- `activeSubscriptionInfoCount`: {Number} [`READ_PHONE_STATE`] the current number of active subscriptions | ||
- `activeSubscriptionInfoCountMax`: {Number} [`READ_PHONE_STATE`] the maximum number of active subscriptions | ||
- `phoneNumber`: {String} [`READ_PHONE_STATE`] - phone number string for line 1, for example, the [MSISDN](http://en.wikipedia.org/wiki/MSISDN) for a GSM phone <sup>1</sup> | ||
- `deviceId`: {String} [`READ_PHONE_STATE`] the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones | ||
- `deviceSoftwareVersion`: {String} [`READ_PHONE_STATE`] the software version number for the device, for example, the IMEI/SV for GSM phones | ||
- `simSerialNumber`: {String} [`READ_PHONE_STATE`] the serial number of the SIM, if applicable | ||
- `subscriberId`: {String} [`READ_PHONE_STATE`] the unique subscriber ID, for example, the IMSI for a GSM phone | ||
- `cards`: {Array} [`READ_PHONE_STATE`] List of SIM cards | ||
- `carrierName`: {String} the name displayed to the user that identifies Subscription provider name | ||
- `displayName`: {String} the name displayed to the user that identifies this subscription | ||
- `countryCode`: {String} the ISO country code | ||
- `mcc`: {String} MCC (mobile country code) of the provider of the SIM | ||
- `mnc`: {String} MNC (mobile network code) of the provider of the SIM | ||
- `isNetworkRoaming`: {Boolean} Returns true if the device is considered roaming on the current network for a subscription | ||
- `isDataRoaming`: {Boolean} the data roaming state for this subscription | ||
- `simSlotIndex`: {Number} the slot index of this Subscription's SIM card | ||
- `phoneNumber`: {String} the number of this subscription | ||
- `deviceId`: {String} the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones | ||
- `simSerialNumber`: {String} ICC ID | ||
- `subscriptionId`: {String} Subscription Identifier, this is a device unique number | ||
<sup>1)</sup> Notice: the content of phoneNumber is unreliable (see [this](http://stackoverflow.com/questions/7922734/getting-reliable-msisdn-from-android-phone-voicemailnumber-line1number) and [this](http://stackoverflow.com/questions/25861064/retrieving-line1-number-from-telephonymanager-in-android) article). | ||
@@ -185,6 +226,18 @@ Sometimes phoneNumber is only an empty string. | ||
* `subscriberId` | ||
* `activeSubscriptionInfoCount` | ||
* `activeSubscriptionInfoCountMax` | ||
* multiple SIM card data | ||
Wiki: [How to test permissions](https://github.com/pbakondy/cordova-plugin-sim/wiki/Testing-Android-API-23-Permissions) | ||
### Build conflict with `phonegap-facebook-plugin` | ||
Android SDK uses Gradle build tool to create Android builds. `phonegap-facebook-plugin` does not implement `android-support-v4` dependency the recommended way, Gradle is not able to resolve the dependencies. The build process will fail. | ||
I suggest to use another plugin for facebook usage: | ||
- https://github.com/Telerik-Verified-Plugins/Facebook | ||
- https://github.com/jeduan/cordova-plugin-facebook4 | ||
## iOS Quirks | ||
@@ -214,3 +267,3 @@ | ||
* `isCellularDataRoamingEnabled`: Boolean - indicates whether the network allows data roaming | ||
* `IsNetworkAvailable`: Boolean - indicates whether the network is available | ||
* `isNetworkAvailable`: Boolean - indicates whether the network interface is available | ||
* `isWiFiEnabled`: Boolean - indicates whether the network is Wi-Fi enabled | ||
@@ -217,0 +270,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34129
17
242
279