콘텐츠로 건너뛰기

Getting Started

이 콘텐츠는 아직 귀하의 언어로 제공되지 않습니다.

  1. Install the plugin

    Terminal window
    npm i @capgo/capacitor-sim
  2. Sync platforms

    Terminal window
    npx cap sync

Permissions

  • Android: Ensure android.permission.READ_PHONE_STATE (and on Android 13+, READ_BASIC_PHONE_STATE) is granted. Capacitor includes the manifest declarations, but you must request the permission before calling getSimCards.
  • iOS: Carrier information is available automatically; the platform does not prompt for additional permissions. Be mindful of the limited data returned on iOS 16.4+ due to OS restrictions.

Request runtime access (Android)

import { Sim } from '@capgo/capacitor-sim';
const status = await Sim.checkPermissions();
if (status.readSimCard !== 'granted') {
const updated = await Sim.requestPermissions();
if (updated.readSimCard !== 'granted') {
throw new Error('Telephony permission denied');
}
}

Read SIM cards

const { simCards } = await Sim.getSimCards();
simCards.forEach((card, index) => {
console.log(`Slot ${card.simSlotIndex ?? index}:`, {
carrier: card.carrierName,
mcc: card.mobileCountryCode,
mnc: card.mobileNetworkCode,
country: card.isoCountryCode,
subscriptionId: card.subscriptionId,
});
});

Platform considerations

  • Dual SIM devices: Iterate through the returned array; each entry corresponds to a slot. When present, subscriptionId helps you interact with Android’s telephony APIs.
  • iOS 16.4+: Apple redacts several carrier attributes. Expect placeholder values (--, 65535) and plan fallbacks in your UI.
  • Web: The plugin resolves with empty data because browsers cannot access SIM information.