본문으로 건너뛰기

앱 이벤트 (Event)

Event 모듈은 앱의 생명주기 변화 등 시스템 이벤트를 감지합니다.

메서드

onAppStateChange

앱의 상태 변화(포그라운드/백그라운드 전환)를 구독합니다.

onAppStateChange(callback: (state: AppState) => void): Subscription
  • AppState 종류:
    • active: 앱이 포그라운드에 있음
    • background: 앱이 백그라운드에 있음
    • inactive: 앱이 비활성 상태 (iOS 멀티태스킹 등)

사용 예제

import { appify } from '@nolraunsoft/appify-sdk';

const subscription = appify.event.onAppStateChange((state) => {
if (state === 'active') {
console.log('앱이 다시 활성화되었습니다. 데이터를 새로고침합니다.');
} else if (state === 'background') {
console.log('앱이 백그라운드로 전환되었습니다.');
}
});

// 구독 해제 시
// subscription.unsubscribe();