iOS Notice when my app's been background

운영 체제: macOS Ventura 13.4.1
사용 버전: Xcode 14.3.1, Swift, SwiftUI

iOS Notice when my app's been background를 알아보겠습니다.

앱이 백그라운드로 들어가는 것을 아는 방법은 여러가지 있습니다.

1. AppDelegate 사용.


2. onReceive NotificationCenter를 사용.


3. scenePhase를 사용.

그중 오늘은 scenePhase를 사용하는 방법을 알아봅시다.


12 번째 줄처럼 @Environment를 사용하여 scenePhase를 정의합니다.






16 번째 줄처럼 onChange를 적어줍니다. 그리고 of에는 scenePhase를 적어줍니다.






18 번째 줄처럼 switch를 사용합니다.

background이면, background 상태입니다.

inactive이면 inactive 상태입니다.

active이면 active 상태입니다.





끝.


카테고리: iOS

댓글

이 블로그의 인기 게시물

Python OpenCV 빈 화면 만들기

Python urllib.parse.quote()

Python bytes.fromhex()

Android AVD Ram size change

Forensics .pyc 파일 .py로 복구하기

Android Minimum touch target size

KiCad 시작하기 7 (FreeRoute 사용하기 2)

Android Notification with Full Screen

C++ OpenCV 모폴로지 침식, 팽창

KiCad 시작하기 2 (PCB 만들기)