Using addObserver func of NotificationCenter.default, subscribing to UIApplication.willEnterForegroundNotification does not work when the backgrounding is triggered from Notification Center (swipe down from top when app is active to get Notification Center). It also seems that UIApplication.willResignActiveNotification
is called twice, based on Print() logs, when Notification Center triggers the backgrounding.
If you background the app via lock screen or manual swipe, or switch to another app, the UIApplication.willEnterForegroundNotification
does get called, so it seems to be specific to Notification Center.
UIApplication.willResignActiveNotification does fire correctly but then resuming the app never calls the appMovedToForeground
func below:
notificationCenter.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification,object: nil)
occurs on: iOS 14.4.2, iPhone 11 & iOS 14.6, SE(2)