For AI agents: the complete documentation index is available at /react-native-nitro-device-info/ko/llms.txt, the full documentation bundle is available at /react-native-nitro-device-info/ko/llms-full.txt, and this page is available as Markdown at /react-native-nitro-device-info/ko/guide/quick-start.md.

빠른 시작

먼저 시작하기 또는 Expo 설정을 완료하고 네이티브 앱을 다시 빌드하세요.

이 페이지는 패키지 루트의 네이티브 API를 사용합니다. react-native-device-info 형식의 함수는 /compat API을 사용하세요.

속성과 메서드, Promise 사용하기

import { DeviceInfoModule } from 'react-native-nitro-device-info';

// Properties: no parentheses and no await.
const model = DeviceInfoModule.model;
const isTablet = DeviceInfoModule.isTablet;

// Synchronous methods: parentheses, no await.
const batteryLevel = DeviceInfoModule.getBatteryLevel();
const hasGms = DeviceInfoModule.getHasGms();

// Promise-based methods: await inside an async function.
async function readNetworkInfo() {
  try {
    const [ipAddress, carrier] = await Promise.all([
      DeviceInfoModule.getIpAddress(),
      DeviceInfoModule.getCarrier(),
    ]);
    console.log({ ipAddress, carrier });
  } catch (error) {
    console.error('Could not read network information', error);
  }
}

console.log({ model, isTablet, hasGms });
console.log(batteryLevel < 0
  ? 'Battery: unavailable'
  : `Battery: ${Math.round(batteryLevel * 100)}%`);
void readNetworkInfo();

getBatteryLevel()은 값을 읽을 수 없을 때 -1을 반환합니다. getHasGms()는 iOS에서 false를 반환합니다. Promise를 반환한다고 해서 정해진 시간 안에 작업이 완료되는 것은 아닙니다.

React에서 값이 바뀔 때 화면 갱신하기

getter를 직접 호출하면 그 시점의 값을 읽습니다. 값이 바뀔 때 컴포넌트도 갱신해야 한다면 훅을 사용하세요.

import { Text, View } from 'react-native';
import {
  DeviceInfoModule,
  useBatteryLevel,
} from 'react-native-nitro-device-info';

export default function DeviceInfoScreen() {
  const batteryLevel = useBatteryLevel();

  return (
    <View>
      <Text>Model: {DeviceInfoModule.model}</Text>
      <Text>OS: {DeviceInfoModule.systemVersion}</Text>
      <Text>Battery: {batteryLevel === null
        ? 'Loading or unavailable'
        : `${Math.round(batteryLevel * 100)}%`}</Text>
    </View>
  );
}

useBatteryLevel()은 마운트 후 값을 읽고 5초마다 폴링합니다. 처음 읽기 전이나 배터리 잔량을 읽을 수 없을 때는 null을 반환합니다. 갱신 간격과 훅별 반환 타입은 React 훅에서 확인하세요.

단위와 미지원 값 확인

값단위 또는 의미사용 전 확인 사항
totalMemory, getUsedMemory()바이트. 각각 기기 RAM과 현재 앱 메모리플랫폼에 따라 지원 여부가 다릅니다.
getBatteryLevel()0~1의 비율-1은 조회 불가를 뜻합니다.
getBrightness()iOS에서 0~1의 비율Android에서는 -1입니다.
apiLevelAndroid API 수준iOS에서는 -1입니다.
uniqueIdiOS IDFV 또는 Android ANDROID_ID바뀔 수 있습니다. 계정이나 영구 기기 식별자로 사용하지 마세요.

정확한 시그니처, 캐시, 권한, 플랫폼 동작은 DeviceInfo 모듈을 참고하세요. 웹에서는 fallback 값을 사용합니다.

다음 단계