0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【SwiftUI】アプリがバックグラウンドになったことを検知する

Last updated at Posted at 2025-09-26

環境変数のscenePhaseを使うやり方がうまくいかなかった。

なので、代わりの方法を使ったので備忘録として残しておく。

.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { notification in
    print("***** バックグラウンドになった")
}

UIApplication.didEnterBackgroundNotificationを監視する。

実行環境

  • Xcode 16.0
  • iPhone12Pro(iOS16.6.1)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?