アサイコターを試告してきるの組縮
このプラグインのインストール手順と完全なマークダウンガイドを含むセットアップコマンドをコピーしてください。
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.
インストール
「インストール」のセクションbun add @capgo/capacitor-simbunx cap syncインポート
「インポート」のセクションimport { Sim } from '@capgo/capacitor-sim';API オーバービュー
「API オーバービュー」のセクションgetSimCards
「getSimCards」のセクション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
「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
「requestPermissions」セクションSIMカード情報へのアクセスを許可するようにユーザーに求めます。 Androidでは、READ_PHONE_STATE権限を求めます。 iOSでは、常に許可されます。 Webでは、拒否状態が維持されます。
クリップボードにコピー
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」セクションGetSimCardsResult
SIMカード情報へのアクセスを許可する結果クリップボードにコピー
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 がアップストリームで変更された場合に再度同期してください。
はじめから始める
セクション「はじめから始める」Capgoを使用している場合 Getting Started APIのダッシュボードと操作を計画するには、APIを Using @capgo/capacitor-sim for the native capability in Using @capgo/capacitor-sim, API Overview for the implementation detail in API Overview, Capacitorの実装詳細 Capacitorの概要 API Keys for the implementation detail in API Keys, and Capacitorのキー __CAPGO_KEEP_0__の実装詳細については、デバイスのページを参照してください。