diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4a7ea30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/README.md b/README.md index bfa7825..6358c99 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,14 @@ document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { window.plugins.sim.getSimInfo(successCallback, errorCallback); } + +function successCallback(result) { + console.log(result); +} + +function errorCallback(error) { + console.log(error); +} ``` The plugin returns a JSON object. Return values: @@ -46,14 +54,20 @@ You can extract country and carrier data from MCC and MNC codes, read further on Additional return values: -* `phoneNumber`: String - phone number string for line 1, for example, the [MSISDN](http://en.wikipedia.org/wiki/MSISDN) for a GSM phone +* `phoneNumber`: String - phone number string for line 1, for example, the [MSISDN](http://en.wikipedia.org/wiki/MSISDN) for a GSM phone 1 +* `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 -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). +1) 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). +Sometimes phoneNumber value is only an empty string. ### List of Call State Codes and Meanings diff --git a/package.json b/package.json index 94ea6eb..85d3516 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-sim", - "version": "1.0.2", + "version": "1.1.0", "description": "A plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc)", "cordova": { "id": "cordova-plugin-sim", @@ -8,7 +8,8 @@ "android", "ios", "wp7", - "wp8" + "wp8", + "windows" ] }, "repository": { @@ -26,8 +27,6 @@ "ecosystem:cordova", "cordova-android", "cordova-ios", - "cordova-wp7", - "cordova-wp8", "cordova-windows" ], "engines": [ diff --git a/plugin.xml b/plugin.xml index bd7c2cb..1e22d4c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.1.0"> SIM A plugin to get the device's SIM data (carrier name, mcc mnc, country code, telephonenumber, etc) MIT diff --git a/src/android/com/pbakondy/Sim.java b/src/android/com/pbakondy/Sim.java index 5d98f9f..d2e25b8 100644 --- a/src/android/com/pbakondy/Sim.java +++ b/src/android/com/pbakondy/Sim.java @@ -33,12 +33,19 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo String simOperator = manager.getSimOperator(); String carrierName = manager.getSimOperatorName(); + String deviceId = manager.getDeviceId(); + String deviceSoftwareVersion = manager.getDeviceSoftwareVersion(); + String simSerialNumber = manager.getSimSerialNumber(); + String subscriberId = manager.getSubscriberId(); + int callState = manager.getCallState(); int dataActivity = manager.getDataActivity(); int networkType = manager.getNetworkType(); int phoneType = manager.getPhoneType(); int simState = manager.getSimState(); + boolean isNetworkRoaming = manager.isNetworkRoaming(); + String mcc = ""; String mnc = ""; @@ -47,7 +54,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo mnc = simOperator.substring(3); } - JSONObject result = new JSONObject(); result.put("carrierName", carrierName); @@ -56,12 +62,19 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo result.put("mnc", mnc); result.put("phoneNumber", phoneNumber); + result.put("deviceId", deviceId); + result.put("deviceSoftwareVersion", deviceSoftwareVersion); + result.put("simSerialNumber", simSerialNumber); + result.put("subscriberId", subscriberId); + result.put("callState", callState); result.put("dataActivity", dataActivity); result.put("networkType", networkType); result.put("phoneType", phoneType); result.put("simState", simState); + result.put("isNetworkRoaming", isNetworkRoaming); + callbackContext.success(result); return true;