Getting Started
Ein Setup-Vorlage kopieren, die die Installationsanweisungen und die vollständige Markdown-Anleitung für diesen Plugin enthält.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-sim`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/sim/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installieren
Abschnitt mit dem Titel “Installieren”Sie können unser AI-gestütztes Setup verwenden, um das Plugin zu installieren. Fügen Sie die Capgo-Fähigkeiten zu Ihrem AI-Tool hinzu, indem Sie folgenden Befehl ausführen:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsVerwenden Sie dann die folgende Anweisung:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-sim` plugin in my project.Wenn Sie die manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und die untenstehenden plattform-spezifischen Anweisungen befolgen:
bun add @capgo/capacitor-simbunx cap syncImportieren
Abschnitt mit der Überschrift „Importieren“import { Sim } from '@capgo/capacitor-sim';API Übersicht
Abschnitt mit der Überschrift „API Übersicht“getSimCards
Abschnitt mit der Überschrift „getSimCards“Get information from the device’s SIM cards.
Abrufen von Informationen aus den SIM-Karten des Geräts.
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
Abschnitt mit dem Titel “checkPermissions”SIM-Karten-Zugriffsrechte überprüfen.
Copy to clipboard
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
SIM-Karten-Zugriffsrechte anfordern.Copy to clipboard
Typenreferenz
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();}Typenreferenz
Abschnitt mit dem Titel “Typenreferenz”GetSimCardsResult
Abschnitt mit dem Titel “GetSimCardsErgbnis”Ergbnis, das durch . zurückgegeben wird.
export interface GetSimCardsResult { simCards: SimCard[];}PermissionStatus
Abschnitt mit dem Titel “Zugriffsstatus”Ergbnis einer Zugriffsprüfung oder -anfrage.
export interface PermissionStatus { readSimCard: PermissionState;}Eine SIM-Kartenbeschreibung.
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;}Abschnitt mit dem Titel “Quelle der Wahrheit”
Abschnitt mit dem Titel “Quelle der Wahrheit”Diese Seite wurde aus dem Plugin generiert. src/definitions.ts. Wenn sich die öffentliche API im Hintergrund ändert, führen Sie die Synchronisierung erneut durch.
Weiter geht es von Getting Started
Abschnitt mit dem Titel “Weiter geht es von Getting Started”Wenn Sie "Getting Started" verwenden, um das Dashboard und die __CAPGO_KEEP_0__-Operationen zu planen, verbinden Sie es mit Mit @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-sim für die native Fähigkeit in Mit @API/__CAPGO_KEEP_1__-sim Using @capgo/capacitor-sim for the native capability in Using @capgo/capacitor-sim, API Overview Wenn Sie "Getting Started" verwenden, um das Dashboard und die API-Operationen zu planen, verbinden Sie es mit Mit @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-sim für die Implementierungsdetails in Einführung, API Schlüssel für die Implementierungsdetails in API Schlüssel, und Geräte für die Implementierungsdetails in Geräte.