내용으로 건너뛰기

SIM 카드 저장소

GitHub

플러그인을 설치할 수 있습니다. AI-Assisted Setup을 사용하세요. 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.

만들기 설정을 선호하시면, 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요.

터미널 창
bun add @capgo/capacitor-sim
bunx cap sync
import { Sim } from '@capgo/capacitor-sim';

장치의 SIM 카드에서 정보를 가져옵니다.

장치에 설치된 모든 SIM 카드에 대한 세부 정보를 반환합니다. 듀얼-SIM 장치에서는 두 개의 SIM 카드에 대한 정보를 반환합니다. Android에서는 READ_PHONE_STATE 권한이 필요합니다.

import { Sim } from '@capgo/capacitor-sim';
const { simCards } = await Sim.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 카드 데이터를 읽어올 수 있는 앱의 권한을 확인합니다. 안드로이드에서는 READ_PHONE_STATE 권한을 확인합니다. iOS에서는 항상 허용됩니다. 웹에서는 항상 거부됩니다.

import { Sim } from '@capgo/capacitor-sim';
const status = await Sim.checkPermissions();
if (status.readSimCard === 'granted') {
console.log('Permission granted');
} else {
console.log('Permission not granted');
}

requestPermissions

권한 확인

SIM 카드 정보에 접근할 수 있는 권한을 요청합니다.

SIM 카드 데이터를 읽어올 수 있는 사용자의 허가를 요청합니다. 안드로이드에서는 READ_PHONE_STATE 권한을 요청합니다. iOS에서는 항상 허용됩니다. 웹에서는 허용되지 않습니다.

import { Sim } from '@capgo/capacitor-sim';
const status = await Sim.requestPermissions();
if (status.readSimCard === 'granted') {
// Now you can call getSimCards()
const simCards = await Sim.getSimCards();
}

타입 참조

타입 참조

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

공개 __CAPGO_KEEP_0__이 업스트림에서 변경될 때 다시 싱크를 실행하세요. src/definitions.ts. 업스트림에서 API이 변경되면 다시 싱크를 실행하세요.

Getting Started

Getting Started

만약에 시작하기 계획 대시보드와 API 연산을 위해 Using @capgo/capacitor-sim Using @capgo/capacitor-sim API 개요 API Overview Introduction Introduction API 키 API Keys 장치 장치 구현 세부 사항