Type 'Notification.Name' (aka 'NSNotification.Name') has no member 'UIApplication'

Change

forName: Notification.Name.UIApplicationDidEnterBackground

to

forName: UIApplication.didEnterBackgroundNotification

Error with Type 'NSNotification' has no member 'UIApplication' in swift4.2

NotificationCenter.default.addObserver(self, selector:#selector(handleNotification), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil)

Need to Change accordingly

NotificationCenter.default.addObserver(self, selector:#selector(handleNotification), name: UIApplication.didEnterBackgroundNotification, object: nil)

If UIApplicaiton.didEnterBackgroundNotificaiton isn't working, try just .UIApplicationDidEnterBackground instead.


Xcode 11 , swift 5

UIApplication.didBecomeActiveNotification