Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI 특정 뷰에서 background → Foreground 진입 시점 확인하는 방법 #89

Closed
kimkyuchul opened this issue Sep 24, 2024 · 0 comments
Assignees
Labels

Comments

@kimkyuchul
Copy link
Owner

.onReceive(NotificationCenter.default.publisher(
    for: UIScene.willEnterForegroundNotification)) { _ in 
    print("백그라운드에 있다가 앱으로 다시 진입 시 호출됨")
}
  • onReceive 를 활용해 willEnterForegroundNotification 시점을 확인하는 방법이다.
  • @Environment(\.scenePhase)var scenePhaseonChange 에서 불러서 쓰는 방법이 대다수지만, 특정 뷰에서만 필요할 때 위의 방법을 사용하면 간편한 거 같다.

https://stackoverflow.com/questions/73524435/how-to-tell-if-app-entered-background-on-ios14-swiftui

@kimkyuchul kimkyuchul self-assigned this Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant