コンテンツにジャンプ

Getting Started

GitHub

AI-Assisted セットアップを使用してプラグインをインストールできます。次のコマンドを使用して、Capgo スキルをAIツールに追加します。

ターミナル画面
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 セットアップを使用する場合は、次のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の説明を参照してください。

ターミナル画面
bun add @capgo/capacitor-sim
bunx cap sync
import { Sim } from '@capgo/capacitor-sim';

API オーバービュー

APIの概要

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}`);
});

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');
}

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();
}

型式リファレンス

型式リファレンス

SIMカードの取得結果

export interface GetSimCardsResult {
simCards: SimCard[];
}

PermissionStatus

許可状態

許可状態の結果

export interface PermissionStatus {
readSimCard: PermissionState;
}

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上流でpublic APIが変更された場合、再度syncを実行してください。

Getting Startedから続けてください

「Getting Startedから続けてください」

Capacitorを使用している場合 Getting Started ダッシュボードとAPIの作業を計画するには、Capacitorを使用してください。 Using @capgo/capacitor-sim Using @capgo/capacitor-simで使用するネイティブ機能 APIの概要 APIの実装詳細についての概要 Introduction __CAPGO_KEEP_0__のキー APIの実装詳細についてのキー、そして for the implementation detail in API Keys, and __CAPGO_KEEP_0__の実装詳細についてのデバイス Edit page