Getting Started
Install
Section titled “Install”bun add @capgo/capacitor-simbunx cap syncImport
Section titled “Import”import { Sim } from '@capgo/capacitor-sim';API Overview
Section titled “API Overview”getSimCards
Section titled “getSimCards”Get information from the device’s SIM cards.
Retrieves details about all SIM cards installed in the device. On dual-SIM devices, returns information for both SIM cards. Requires READ_PHONE_STATE permission on Android.
import { Sim } from '@capgo/capacitor-sim';
const { simCards } = await SimPlugin.getSimCards();simCards.forEach((sim, index) => { console.log(`SIM ${index + 1}:`); console.log(` Carrier: ${sim.carrierName}`); console.log(` Country: ${sim.isoCountryCode}`); console.log(` MCC: ${sim.mobileCountryCode}`); console.log(` MNC: ${sim.mobileNetworkCode}`);});checkPermissions
Section titled “checkPermissions”Check permission to access SIM card information.
Checks if the app has permission to read SIM card data. On Android, checks READ_PHONE_STATE permission. On iOS, the status is always granted. On Web, the status is always denied.
import { Sim } from '@capgo/capacitor-sim';
const status = await SimPlugin.checkPermissions();if (status.readSimCard === 'granted') { console.log('Permission granted');} else { console.log('Permission not granted');}requestPermissions
Section titled “requestPermissions”Request permission to access SIM card information.
Prompts the user to grant permission to read SIM card data. On Android, requests READ_PHONE_STATE permission. On iOS, the status is always granted without prompting. On Web, the status remains denied.
import { Sim } from '@capgo/capacitor-sim';
const status = await SimPlugin.requestPermissions();if (status.readSimCard === 'granted') { // Now you can call getSimCards() const simCards = await SimPlugin.getSimCards();}Type Reference
Section titled “Type Reference”GetSimCardsResult
Section titled “GetSimCardsResult”Result returned by .
export interface GetSimCardsResult { simCards: SimCard[];}PermissionStatus
Section titled “PermissionStatus”Result of a permission check or request.
export interface PermissionStatus { readSimCard: PermissionState;}SimCard
Section titled “SimCard”A SIM card description.
export interface SimCard { /** * Android only: Phone number for this SIM slot, when available. * * @since 1.0.0 */ number?: string;
/** * Android only: Unique subscription identifier. * * @since 1.1.0 */ subscriptionId?: string;
/** * Android only: Physical SIM slot index for this subscription. * * @since 1.1.0 */ simSlotIndex?: number;
/** * iOS only: Indicates whether the carrier supports VoIP. * * @since 1.0.0 */ allowsVOIP?: boolean;
/** * Display name of the cellular service provider. * * On iOS 16.4+ the system may return placeholder values such as `--`. * See https://github.com/jonz94/capacitor-sim/issues/8 for details. * * @since 1.0.0 */ carrierName: string;
/** * ISO 3166-1 alpha-2 country code of the service provider. * * On iOS 16.4+ the system may return an empty string or `--`. * See https://github.com/jonz94/capacitor-sim/issues/8 for details. * * @since 1.0.0 */ isoCountryCode: string;
/** * Mobile Country Code (MCC) of the service provider. * * On iOS 16.4+ the system may return placeholder values such as `65535`. * See https://github.com/jonz94/capacitor-sim/issues/8 for details. * * @since 1.0.0 */ mobileCountryCode: string;
/** * Mobile Network Code (MNC) of the service provider. * * On iOS 16.4+ the system may return placeholder values such as `65535`. * See https://github.com/jonz94/capacitor-sim/issues/8 for details. * * @since 1.0.0 */ mobileNetworkCode: string;}Source Of Truth
Section titled “Source Of Truth”This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.