@capawesome/capacitor-sim 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -3
- package/android/build.gradle +1 -1
- package/ios/Plugin/SimPlugin.swift +3 -1
- package/package.json +13 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Capacitor SIM Plugin
|
|
2
2
|
|
|
3
3
|
Capacitor plugin for reading SIM card and carrier information.
|
|
4
4
|
|
|
@@ -18,9 +18,14 @@ Capacitor plugin for reading SIM card and carrier information.
|
|
|
18
18
|
|
|
19
19
|
Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Use Cases
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
The SIM plugin is typically used when an app needs to know about the device's SIM cards or carrier, for example:
|
|
24
|
+
|
|
25
|
+
- **Carrier-specific features**: Enable or disable functionality depending on the carrier name or the MCC and MNC of the SIM card.
|
|
26
|
+
- **Country detection**: Use the SIM card's ISO country code to preselect a country or region in your app.
|
|
27
|
+
- **Multi-SIM handling**: Show which SIM slots are in use on devices with multiple SIM slots.
|
|
28
|
+
- **eSIM detection**: Detect whether a SIM card is an embedded SIM (eSIM).
|
|
24
29
|
|
|
25
30
|
## Compatibility
|
|
26
31
|
|
|
@@ -66,6 +71,12 @@ No configuration required for this plugin.
|
|
|
66
71
|
|
|
67
72
|
## Usage
|
|
68
73
|
|
|
74
|
+
The following examples show how to check and request permissions and read the SIM cards installed on the device.
|
|
75
|
+
|
|
76
|
+
### Check and request permissions
|
|
77
|
+
|
|
78
|
+
Reading the SIM cards requires the `READ_PHONE_STATE` runtime permission on Android. Check the current permission state and request the permission before calling `getSimCards(...)`. Only available on Android:
|
|
79
|
+
|
|
69
80
|
```typescript
|
|
70
81
|
import { Sim } from '@capawesome/capacitor-sim';
|
|
71
82
|
|
|
@@ -78,6 +89,14 @@ const requestPermissions = async () => {
|
|
|
78
89
|
const { readSimCards } = await Sim.requestPermissions();
|
|
79
90
|
return readSimCards;
|
|
80
91
|
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Read the SIM cards
|
|
95
|
+
|
|
96
|
+
Get information about the SIM cards installed on the device, such as the carrier name, country code, MCC and MNC. On devices with multiple SIM slots, all active SIM cards are returned. Only available on Android:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { Sim } from '@capawesome/capacitor-sim';
|
|
81
100
|
|
|
82
101
|
const getSimCards = async () => {
|
|
83
102
|
const { simCards } = await Sim.getSimCards();
|
|
@@ -193,6 +212,46 @@ Only available on Android.
|
|
|
193
212
|
|
|
194
213
|
</docgen-api>
|
|
195
214
|
|
|
215
|
+
## FAQ
|
|
216
|
+
|
|
217
|
+
### How is this plugin different from other similar plugins?
|
|
218
|
+
|
|
219
|
+
It reads the full picture of the device's SIM cards in a single call — carrier name, ISO country code, MCC and MNC, eSIM status, and the slot index for every active card on multi-SIM devices — through a fully typed API that handles the required Android runtime permission for you. It's honest about platform reality, too: SIM data is well supported on Android, while iOS no longer exposes it reliably, so the plugin focuses where the information is actually available. If you only need a rough country hint, a lighter approach may be enough; if you need dependable multi-SIM and carrier details, this plugin is built for exactly that.
|
|
220
|
+
|
|
221
|
+
### Why is the SIM plugin not available on iOS?
|
|
222
|
+
|
|
223
|
+
Apple deprecated the `CTCarrier` APIs of the Core Telephony framework with iOS 16, and they return placeholder values (e.g. `"--"` and `65535`) on iOS 16.4 and later. Because there is no reliable system API left for reading SIM card and carrier information, all methods reject as unimplemented on iOS. See the [iOS installation notes](#ios) for details.
|
|
224
|
+
|
|
225
|
+
### Which permissions are required to read the SIM cards?
|
|
226
|
+
|
|
227
|
+
The plugin requires the `READ_PHONE_STATE` permission on Android. It is declared in the plugin's `AndroidManifest.xml` and merged into your app automatically, so no manual manifest changes are needed. However, you must request the permission at runtime via the `requestPermissions` method before calling `getSimCards`.
|
|
228
|
+
|
|
229
|
+
### Why is the phone number `null`?
|
|
230
|
+
|
|
231
|
+
The `phoneNumber` property is often empty because carriers do not reliably store the phone number on the SIM card. In that case, the plugin returns `null`. Other properties such as `carrierName` or `isoCountryCode` may also be `null` if the information is not available.
|
|
232
|
+
|
|
233
|
+
### Does the plugin support dual-SIM devices?
|
|
234
|
+
|
|
235
|
+
Yes, on devices with multiple SIM slots, the `getSimCards` method returns all active SIM cards. Each SIM card includes a `slotIndex` property that indicates the index of the SIM slot on the device.
|
|
236
|
+
|
|
237
|
+
### Can I detect whether a SIM card is an eSIM?
|
|
238
|
+
|
|
239
|
+
Yes, each SIM card includes an `isEmbedded` property that indicates whether it is an embedded SIM (eSIM). The property returns `null` if the information is not available.
|
|
240
|
+
|
|
241
|
+
### Can I use this plugin with Ionic, React, Vue or Angular?
|
|
242
|
+
|
|
243
|
+
Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
|
|
244
|
+
|
|
245
|
+
## Related Plugins
|
|
246
|
+
|
|
247
|
+
- [Device Info](https://capawesome.io/docs/sdks/capacitor/device-info/): Read device information, such as the model, manufacturer, and operating system.
|
|
248
|
+
- [Network](https://capawesome.io/docs/sdks/capacitor/network/): Access network information.
|
|
249
|
+
- [Phone Dialer](https://capawesome.io/docs/sdks/capacitor/phone-dialer/): Open the native phone dialer prefilled with a phone number.
|
|
250
|
+
|
|
251
|
+
## Newsletter
|
|
252
|
+
|
|
253
|
+
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
|
|
254
|
+
|
|
196
255
|
## Changelog
|
|
197
256
|
|
|
198
257
|
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/sim/CHANGELOG.md).
|
package/android/build.gradle
CHANGED
|
@@ -30,7 +30,7 @@ android {
|
|
|
30
30
|
buildTypes {
|
|
31
31
|
release {
|
|
32
32
|
minifyEnabled false
|
|
33
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
lintOptions {
|
|
@@ -6,7 +6,9 @@ public class SimPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
6
6
|
public let identifier = "SimPlugin"
|
|
7
7
|
public let jsName = "Sim"
|
|
8
8
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
9
|
-
CAPPluginMethod(name: "
|
|
9
|
+
CAPPluginMethod(name: "checkPermissions", returnType: CAPPluginReturnPromise),
|
|
10
|
+
CAPPluginMethod(name: "getSimCards", returnType: CAPPluginReturnPromise),
|
|
11
|
+
CAPPluginMethod(name: "requestPermissions", returnType: CAPPluginReturnPromise)
|
|
10
12
|
]
|
|
11
13
|
|
|
12
14
|
@objc override public func checkPermissions(_ call: CAPPluginCall) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-sim",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Capacitor plugin for reading SIM card and carrier information.",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Capacitor plugin for reading SIM card and carrier information on Android.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
@@ -33,11 +33,20 @@
|
|
|
33
33
|
"url": "https://opencollective.com/capawesome"
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
|
-
"homepage": "https://capawesome.io/docs/
|
|
36
|
+
"homepage": "https://capawesome.io/docs/sdks/capacitor/sim/",
|
|
37
37
|
"keywords": [
|
|
38
38
|
"capacitor",
|
|
39
39
|
"plugin",
|
|
40
|
-
"native"
|
|
40
|
+
"native",
|
|
41
|
+
"capacitor-plugin",
|
|
42
|
+
"sim",
|
|
43
|
+
"sim card",
|
|
44
|
+
"esim",
|
|
45
|
+
"carrier",
|
|
46
|
+
"carrier information",
|
|
47
|
+
"dual sim",
|
|
48
|
+
"mcc",
|
|
49
|
+
"mnc"
|
|
41
50
|
],
|
|
42
51
|
"scripts": {
|
|
43
52
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|