Getting Started
このプラグインのインストール手順と完全なマークダウンガイドを含むセットアッププロンプトをコピーする。
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.
インストール
「インストール」のセクションCapgoのAIアシストセットアップを使用してプラグインをインストールできます。次のコマンドを使用して、AIツールにCapgoスキルを追加します。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次のプロンプトを使用してください:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-sim` plugin in my project.Manual Setupを使用する場合は、次のコマンドを実行して、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-simbunx cap syncImport
「Import」セクションimport { Sim } from '@capgo/capacitor-sim';APIの概要
APIの概要getSimCards
SIMカードの取得デバイスのSIMカードから情報を取得します。
デバイスにインストールされているすべてのSIMカードの詳細を取得します。 デュアルSIMデバイスでは、両方のSIMカードの情報を返します。 Androidでは、READ_PHONE_STATEの権限が必要です。
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
SIMカード情報へのアクセス許可の確認アプリがSIMカードデータの読み取りを許可されているかどうかを確認します。 Androidでは、READ_PHONE_STATEの権限をチェックします。 iOSでは、常に許可されています。 Webでは、常に拒否されます。
コピー
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カードデータの読み取りを許可するように求めます。
Androidでは、READ_PHONE_STATEの権限を要求します。
iOSでは、常に許可されますが、ユーザーに求められません。
Webでは、常に拒否されます。コピー
__CAPGO_KEEP_0__の概要
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();}型の参照
「型の参照」のセクションGetSimCardsResult
「SimCardsの結果」を取得するSimCardsの結果
export interface GetSimCardsResult { simCards: SimCard[];}PermissionStatus
「許可の状態」許可のチェックまたは要求の結果
export interface PermissionStatus { readSimCard: PermissionState;}SimCard
「SIMカード」のセクションSIMカードの説明
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;}真実の源
「真実の源」というセクションこのページはプラグインの src/definitions.tsパブリック API がアップストリームで変更されたときに、再度同期を実行してください。
「始めてから続けて」
「始めてから続けて」というセクションCapacitor を使用している場合 Capacitor Capacitor を使用してダッシュボードと API の作業を計画する場合、Capacitor を Capacitor を使用して Capacitor のネイティブ機能を実装するには、@capgo/capacitor-sim を使用します。 Capacitor を使用して Capacitor のネイティブ機能を実装するには、@capgo/capacitor-sim を使用します。 API Overview Capgoの実装詳細についてはAPIの概要を参照してください。 概要 Capgoの実装詳細については概要を参照してください。 APIのキー Capgoの実装詳細についてはAPIのキー、 デバイス Capgoの実装詳細についてはデバイスを参照してください。