1.0.19 • Published 7 years ago

cordova-plugin-sim2 v1.0.19

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

cordova-plugin-sim

Code Climate

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.

Installation

cordova plugin add cordova-plugin-sim2

Supported Platforms

  • Android
  • iOS
  • Windows Phone 7 and 8

Usage

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
  window.plugins.sim.getSimInfo(successCallback, errorCallback);
}

The plugin returns a JSON object. Return values:

  • carrierName: String - the Service Provider Name (SPN)
  • countryCode: String - the ISO country code equivalent for the SIM provider's country code
  • mcc: String - the MCC (mobile country code) of the provider of the SIM
  • mnc: String - the MNC (mobile network code) of the provider of the SIM

Field carrierName may remain empty, dependent on the mobile provider.

On Windows Phone access to countryCode, MCC and MNC is not made provided (returns empty string).

You can extract country and carrier data from MCC and MNC codes, read further on Wikipedia and ITU-T.

Android Quirks

Additional return values:

  • phoneNumber: String - phone number string for line 1, for example, the MSISDN 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

Notice: the content of phoneNumber is unreliable (see this and this article).

List of Call State Codes and Meanings

CodeConstantMeaning
0CALL_STATE_IDLENo activity
1CALL_STATE_RINGINGRinging. A new call arrived and is ringing or waiting. In the latter case, another call is already active.
2CALL_STATE_OFFHOOKOff-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.

List of Data Activity Codes and Meanings

CodeConstantMeaning
0DATA_ACTIVITY_NONENo traffic.
1DATA_ACTIVITY_INCurrently receiving IP PPP traffic.
2DATA_ACTIVITY_OUTCurrently sending IP PPP traffic.
3DATA_ACTIVITY_INOUTCurrently both sending and receiving IP PPP traffic.
4DATA_ACTIVITY_DORMANTData connection is active, but physical link is down

List of Network Type Codes and Meanings

CodeConstantMeaning
0NETWORK_TYPE_UNKNOWNunknown
1NETWORK_TYPE_GPRSGPRS
2NETWORK_TYPE_EDGEEDGE
3NETWORK_TYPE_UMTSUMTS
4NETWORK_TYPE_CDMACDMA: Either IS95A or IS95B
5NETWORK_TYPE_EVDO_0EVDO revision 0
6NETWORK_TYPE_EVDO_AEVDO revision A
7NETWORK_TYPE_1xRTT1xRTT
8NETWORK_TYPE_HSDPAHSDPA
9NETWORK_TYPE_HSUPAHSUPA
10NETWORK_TYPE_HSPAHSPA
11NETWORK_TYPE_IDENiDen
12NETWORK_TYPE_EVDO_BEVDO revision B
13NETWORK_TYPE_LTELTE
14NETWORK_TYPE_EHRPDeHRPD
15NETWORK_TYPE_HSPAPHSPA+

List of Phone Type Codes and Meanings

CodeConstantMeaning
0PHONE_TYPE_NONEnone
1PHONE_TYPE_GSMGSM
2PHONE_TYPE_CDMACDMA
3PHONE_TYPE_SIPSIP

List of SIM State Codes and Meanings

CodeConstantMeaning
0SIM_STATE_UNKNOWNUnknown. Signifies that the SIM is in transition between states. For example, when the user inputs the SIM pin under PIN_REQUIRED state, a query for sim status returns this state before turning to SIM_STATE_READY.
1SIM_STATE_ABSENTNo SIM card is available in the device
2SIM_STATE_PIN_REQUIREDLocked: requires the user's SIM PIN to unlock
3SIM_STATE_PUK_REQUIREDLocked: requires the user's SIM PUK to unlock
4SIM_STATE_NETWORK_LOCKEDLocked: requires a network PIN to unlock
5SIM_STATE_READYReady

iOS Quirks

Additional return value:

  • allowsVOIP: Boolean - indicates if the carrier allows VoIP calls to be made on its network

Windows Phone Quirks

Additional return values:

  • isCellularDataEnabled: Boolean - indicates whether the network is cellular data enabled
  • isCellularDataRoamingEnabled: Boolean - indicates whether the network allows data roaming
  • IsNetworkAvailable: Boolean - indicates whether the network is available
  • isWiFiEnabled: Boolean - indicates whether the network is Wi-Fi enabled

Author

Peter Bakondy

LICENSE

cordova-plugin-sim is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.