본문으로 건너뛰기

getSafeAreaInsets

Deprecated

이 함수는 더 이상 사용되지 않습니다. SDK JSDoc에서 명시적으로 deprecated 처리되었습니다. 대신 SafeAreaInsets.get()을 사용하세요.

// 이전 (deprecated)
import { getSafeAreaInsets } from '@apps-in-toss/web-framework';
const inset = getSafeAreaInsets(); // number

// 권장 방법
import { SafeAreaInsets } from '@apps-in-toss/web-framework';
const insets = SafeAreaInsets.get(); // { top, bottom, left, right }

Safe Area 인셋 값을 숫자로 반환합니다. SafeAreaInsets.get(){ top, bottom, left, right } 객체를 반환하므로 더 세밀한 제어가 가능합니다.

시그니처

import { getSafeAreaInsets } from '@apps-in-toss/web-framework';

/** @deprecated 대신 SafeAreaInsets.get()을 사용하세요. */
declare function getSafeAreaInsets(): number;

파라미터

없음.

반환값

  • number — Safe Area 인셋 값 (단위: 픽셀). 방향별 세부 값은 반환하지 않습니다.

권한

권한이 필요하지 않습니다 — getSafeAreaInsets는 별도의 PermissionName에 바인딩되지 않습니다. 권한이 필요한 다른 네임스페이스의 일반적인 처리 흐름은 Guides — 권한 처리 패턴을 참고하세요.

마이그레이션 가이드

getSafeAreaInsets에서 SafeAreaInsets.get()으로 마이그레이션하는 방법은 다음과 같습니다.

// 이전 코드
import { getSafeAreaInsets } from '@apps-in-toss/web-framework';

function Page() {
const inset = getSafeAreaInsets();
return <div style={{ paddingBottom: inset }}>...</div>;
}
// 마이그레이션 후
import { SafeAreaInsets } from '@apps-in-toss/web-framework';
import { useState, useEffect } from 'react';

function Page() {
const [insets, setInsets] = useState(() => SafeAreaInsets.get());

useEffect(() => {
// 화면 모드 변경 시 safe area 업데이트를 구독합니다.
const cleanup = SafeAreaInsets.subscribe({
onEvent: (newInsets) => setInsets(newInsets),
});
return cleanup;
}, []);

return (
<div style={{
paddingTop: insets.top,
paddingBottom: insets.bottom,
paddingLeft: insets.left,
paddingRight: insets.right,
}}>
...
</div>
);
}

직접 실행해 보기

sdk-example에서 실행해 보기

관련 API

관련 가이드

외부 참조