본문 바로가기
@capgo/capacitor-screen-orientation Device API 오픈 소스

화면 방향 Capacitor 플러그인

orientation lock 우회를 지원하는 Screen Orientation 플러그인

설치

bun add @capgo/capacitor-screen-orientation bunx cap sync
npm, pnpm 또는 yarn
  • npm install @capgo/capacitor-screen-orientation
  • pnpm add @capgo/capacitor-screen-orientation
  • yarn add @capgo/capacitor-screen-orientation

가이드

Capacitor에서 Screen Orientation 사용법

기기에서 테스트하기

Capgo 앱을 다운로드한 후 QR code을 스캔하세요.

Screen Orientation 플러그인 미리보기 QR code

@capgo/capacitor-screen-orientation 사용하기

Capacitor Screen Orientation 플러그인 인터페이스.

설치

bun add @capgo/capacitor-screen-orientation
bunx cap sync

bunx cap sync 플러그인의 네이티브 code를 네이티브 프로젝트에 복사합니다. 플러그인을 업그레이드할 때마다 다시 실행하세요.

가져오기

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

API 한눈에 보기

메서드 설명
orientation 현재 화면 방향을 가져옵니다.
lock 화면 방향을 특정 유형으로 고정합니다.
unlock 화면 방향 고정을 해제합니다.
startOrientationTracking 모션 센서로 기기 방향 추적을 시작합니다.
stopOrientationTracking 모션 센서를 사용한 기기 방향 추적을 중단합니다.
isOrientationLocked 현재 기기 방향 잠금이 활성화되어 있는지 확인합니다.
isDeviceFoldable 화면 방향 변경 이벤트를 감지합니다.
getFoldState 현재 폴드 상태를 읽습니다.
getHingeAngle 힌지 각도를 도(degree) 단위로 읽습니다.
getReservedRegions 폴드 상태 및 화면을 가리는 요소를 읽습니다.
getBarPlacement iPhone Duo의 네이티브 탭 바 및 툴바 위치를 읽습니다.
setVerticalBarBehavior iPhone Duo가 이 앱의 바를 측면으로 이동할 수 있도록 허용할지 선택하세요.
getSizeClass 윈도우 크기 클래스를 읽어옵니다.

예시

orientation()

현재 화면 방향을 가져옵니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

const result = await ScreenOrientation.orientation();
console.log('Current orientation:', result.type);

lock()

화면 방향을 특정 유형으로 고정합니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

// Standard lock
await ScreenOrientation.lock({ orientation: 'landscape' });

// Lock with motion tracking on iOS
await ScreenOrientation.lock({
  orientation: 'portrait',
  bypassOrientationLock: true
});

unlock()

화면 방향 고정을 해제합니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

await ScreenOrientation.unlock();

startOrientationTracking()

모션 센서로 기기 방향 추적을 시작합니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

await ScreenOrientation.startOrientationTracking({
  bypassOrientationLock: true
});

// Listen for changes
ScreenOrientation.addListener('screenOrientationChange', (result) => {
  console.log('Orientation changed:', result.type);
});

stopOrientationTracking()

모션 센서를 사용한 기기 방향 추적을 중단합니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

await ScreenOrientation.stopOrientationTracking();

isOrientationLocked()

현재 기기 방향 잠금이 활성화되어 있는지 확인합니다.

import { ScreenOrientation } from '@capgo/capacitor-screen-orientation';

// Start motion tracking first
await ScreenOrientation.startOrientationTracking({
  bypassOrientationLock: true
});

// Check lock status
const status = await ScreenOrientation.isOrientationLocked();
if (status.locked) {
  console.log('Orientation lock is ON');
  console.log('Physical:', status.physicalOrientation);
  console.log('UI:', status.uiOrientation);
}

위 표에는 13개의 핵심 메서드가 나열되어 있습니다. Listener와 version helper, 각 메서드의 전체 계약은 다음에 문서화되어 있습니다: GitHub 리포지토리.

이벤트 수신

addListener 핸들을 반환합니다. 호출하세요 handle.remove() 화면이 언마운트될 때, 또는 ScreenOrientation.removeAllListeners() 모든 리스너를 해제하려면.

전체 레퍼런스

@capgo/capacitor-screen-orientation 사용하기 다음 단계

사용 중이라면 @capgo/capacitor-screen-orientation 사용하기 네이티브 미디어 및 인터페이스 동작을 계획하려면, 이를 다음 항목과 연결하세요: @capgo/capacitor-screen-orientation @capgo/capacitor-screen-orientation의 구현 세부 사항에 대해서는, 시작하기 Getting Started의 구현 상세 내용은 @capgo/capacitor-live-activities 사용 @capgo/capacitor-live-activities 사용에서의 네이티브 기능, @capgo/capacitor-live-activities @capgo/capacitor-live-activities의 구현 세부 사항은, 그리고 @capgo/capacitor-video-player 사용 @capgo/capacitor-video-player. 사용하기에서의 네이티브 기능은

자주 묻는 질문

Screen Orientation 플러그인 FAQ

Capacitor 앱에 Screen Orientation 플러그인을 어떻게 설치하나요?

"bun add @capgo/capacitor-screen-orientation" (또는 "npm install @capgo/capacitor-screen-orientation")를 실행한 다음, "bunx cap sync"를 실행하여 iOS 및 Android 프로젝트에 네이티브 code가 반영되도록 하세요. 그 후 앱의 code에서 "@capgo/capacitor-screen-orientation"를 통해 import 하세요.

@capgo/capacitor-screen-orientation는 React, Vue, Angular와 함께 사용할 수 있나요?

네. Screen Orientation는 Capacitor 패키지이므로 Ionic, React, Vue, Angular, Svelte 및 일반 JavaScript를 포함하여 Capacitor에서 실행되는 모든 웹 프레임워크와 함께 사용할 수 있습니다.

@capgo/capacitor-screen-orientation은 어떤 Capacitor 버전을 지원하나요?

Capgo 플러그인은 Capacitor의 메이저 버전을 따릅니다. 사용 중인 Capacitor 메이저 버전과 일치하는 플러그인 메이저 버전을 사용하세요 (예: Capacitor 8에는 플러그인 v8). 유지 관리되는 버전은 GitHub README의 호환성 표에서 확인할 수 있습니다.

@capgo/capacitor-screen-orientation는 무료 오픈 소스인가요?

네. code 소스 코드는 GitHub의 https://github.com/Cap-go/capacitor-screen-orientation/ 에서 공개되어 있으며, npm에서 무료로 설치할 수 있습니다. 버그 리포트와 pull request는 언제나 환영합니다.

App Store 심사 없이 Screen Orientation을 사용하는 code를 업데이트할 수 있나요?

플러그인을 설치하거나 업그레이드하면 네이티브 code가 변경되므로 새로운 스토어 빌드가 필요합니다. 그 이후에는 플러그인을 호출하는 JavaScript, HTML, CSS 변경 사항을 Capgo live updates로 즉시 배포할 수 있습니다.

앱 심사 대기 없이 Screen Orientation 변경 사항을 즉시 배포하세요

스토어 빌드에 플러그인이 포함되면, Capgo live updates로 JavaScript, HTML, CSS 변경 사항을 몇 분 만에 사용자에게 푸시할 수 있습니다.

Capgo로 시작하기