Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liuy97/ns-sim-info
nativescript get information of sim cards
https://github.com/liuy97/ns-sim-info
Last synced: 9 days ago
JSON representation
nativescript get information of sim cards
- Host: GitHub
- URL: https://github.com/liuy97/ns-sim-info
- Owner: liuy97
- License: apache-2.0
- Created: 2022-11-30T08:40:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-15T08:03:52.000Z (about 2 years ago)
- Last Synced: 2024-12-14T20:49:10.962Z (about 1 month ago)
- Language: TypeScript
- Size: 1.13 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ns-sim-info
This plugin is forked from [nativescript-sim-info](https://github.com/erodriguezh/nativescript-sim-info). This plugin uses @nativescript/plugin-seed. The plugin will not request phone number in Android in order to reduce requested permissions. manager.getLine1Number requires permissions for SMS and phone numbers in Android, which are difficult to grant in play store. iOS does not provide phone numbers.
```javascript
ns plugin add ns-sim-info
```## Usage
```typescript
import { SimInfo } from "ns-sim-info";load(): void {
const simInfo = new SimInfo();
simInfo.getData()
.then((simData) => {
console.log(simData)
}).catch((error) => {
console.error(error);
});
}
```### Android Output
#### Single Sim
```json
[
{
"isoCountryCode": "at",
"simOperator": "23XXX",
"carrierName": "A1",
"callState": null,
"dataActivity": null,
"phoneType": 1,
"simState": 5,
"isNetworkRoaming": true,
"mcc": 232,
"mnc": 1,
"phoneNumber": "",
"deviceSoftwareVersion": "01",
"simSerialNumber": "894301561923869XXXX",
"subscriberId": "23201163022XXXX",
"isDefaultSim": true,
"networkType": 13,
"deviceImei": "35404611160XXXX",
"deviceMeid": "",
"subscriptionId": 1
}
]
```#### Dual Sim
```json
[
{
"isoCountryCode": "at",
"simOperator": "23XXX",
"carrierName": "spusu",
"callState": null,
"dataActivity": 4,
"phoneType": 1,
"simState": 5,
"isNetworkRoaming": true,
"mcc": 232,
"mnc": 17,
"phoneNumber": "",
"deviceSoftwareVersion": "00",
"simSerialNumber": "894317008000176XXXX",
"subscriberId": "23217004025XXXX",
"isDefaultSim": true,
"networkType": 13,
"deviceImei": "86760103133XXXX",
"deviceMeid": "9900111506XXXX",
"subscriptionId": 1
},
{
"isoCountryCode": "at",
"carrierName": "A1",
"isNetworkRoaming": true,
"phoneNumber": "",
"mcc": 232,
"mnc": 1,
"subscriptionId": 4,
"simSerialNumber": "894301561520280XXXX",
"isDefaultSim": false
}
]
```Possible errors
The plugin will request more or less permission items depending on the Android version. If any of the permissions are rejected by the user, an object will be returned as a rejected promise.
```json
{
"android.permission.READ_PHONE_STATE": false,
}
```### iOS Output
#### Single Sim
```json
[
{
"mnc": "232",
"isoCountryCode": "at",
"carrierName": "A1",
"allowsVOIP": true,
"mcc": "1"
}
]
```## API
| Property | Platform | Android Version | iOS Version | Type | Description |
|-----------------------|----------|-----------------|-------------|------------------------|-------------------------------------------------------------------------------------------------------------------------|
| isoCountryCode | common | 1 | 1 | string | Returns the ISO-3166 country code equivalent for the SIM provider's country code. |
| carrierName | common | 1 | 1 | string | Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM. 5 or 6 decimal digits. |
| mcc | common | 1 | 1 | string - number - null | Returns the mobile country code (MCC). |
| mnc | common | 1 | 1 | string - number - null | Returns the mobile network code (MNC). |
| simOperator | android | 1 | - | string | Returns the Service Provider Name (SPN). |
| callState | android | 1 | - | number - null | Returns the state of all calls on the device. |
| dataActivity | android | 1 | - | number - null | Returns a constant indicating the type of activity on a data connection (cellular). |
| phoneType | android | 1 | - | number - null | Returns a constant indicating the device phone type. |
| simState | android | 1 | - | number - null | Returns a constant indicating the state of the default SIM card. |
| isNetworkRoaming | android | 1 | - | boolean - null | Returns true if the device is considered roaming on the current network, for GSM purposes. |
| phoneNumber | android | - | - | string | Returns the phone number string for line 1, for example, the MSISDN for a GSM phone. Returns null or "" if it is unavailable. |
| deviceSoftwareVersion | android | 1 | - | string | Returns the software version number for the device, for example, the IMEI/SV for GSM phones. |
| simSerialNumber | android | 1 | - | string | Returns the serial number of the SIM, if applicable. |
| subscriberId | android | 1 | - | string | Returns the unique subscriber ID, for example, the IMSI for a GSM phone. |
| subscriptionId | android | 5.1 (Api: 22) | - | number - null | Returns the subscription. |
| simSerialNumber | android | 5.1 (Api: 22) | - | string | Returns SIM unique serial number (ICCID). |
| networkType | android | 7 (Api: 24) | - | number - null | Returns a constant indicating the radio technology (network type) currently in use on the device for data transmission. |
| deviceImei | android | 8 (Api: 26) | - | string | returns IMEI for GSM. |
| isDefaultSim | android | - | - | boolean - null | Returns true if the sim is considered the default. |
| allowsVOIP | ios | - | 1 | boolean - null | Indicates if the carrier allows making VoIP calls on its network. | |### Android
#### Dual-Sim Support
From Api Level 22, A.K.A LOLLIPOP_MR1 or Android 5.1, there is support for dual sim. I would like to point out that there is a difference in number of information attributes between what Android considers the default subscription (TelephonyManager) and the subscriptions (SubscriptionManager).
### iOS
#### Dual-Sim Support
From iOS 12 on, Apple supports dual sim. The available information attributes are the same for the default and secondary sim.
#### Phone Number
Apple does not allow the access to the phone number under any circumstance. More information on this topic can be found under the point 2.5.2 of the [guidelines](https://developer.apple.com/app-store/review/guidelines/#software-requirements).
## Testing phones
- Mi 9
- Galaxy S9
- Galaxy S20
- iPhone 5s
- iPhone Xs Max (iOS 16.2) with eSim
```json
[{
"mnc": "01",
"isoCountryCode": "no",
"carrierName": "Telenor",
"allowsVOIP": true,
"mcc": "242"
}, {
"mnc": "01",
"isoCountryCode": "no",
"carrierName": "Telenor",
"allowsVOIP": true,
"mcc": "242"
}]
```
- deactivate eSim
```json
[{
"mnc": "",
"isoCountryCode": "",
"carrierName": "Telenor",
"allowsVOIP": true,
"mcc": ""
}, {
"mnc": "01",
"isoCountryCode": "no",
"carrierName": "Telenor",
"allowsVOIP": true,
"mcc": "242"
}]
```## Acknowledgements
[nativescript-sim-info](https://github.com/erodriguezh/nativescript-sim-info)## License
Apache License Version 2.0