Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect if the notification center was opened

In a cocos2dx project, on iOS 10 devices, when the notification center is swiped down then up, a huge frame rate drop happens. As a result, when the animations resume ui elements whose motion depends on the delta t are moved to invalid positions. It looks to me that the OS is putting the app in some kind of a background mode but the applicationDidEnterBackground is not called. Is there a way to receive an event when the notification center is swiped down/up?

like image 519
Vahagn Avatar asked Jan 29 '23 15:01

Vahagn


1 Answers

Use

applicationWillResignActive(_:)

The above delegate gets called when ur app leaves foreground. This is the same delegate that gets called when ur app momentarily looses focus like on receiving call etc.

You can use

applicationWillEnterForeground(_:)

to figure out when ur app regains the focus.

read : https://developer.apple.com/documentation/uikit/uiapplicationdelegate

As these delegates are called on App's UIApplicationDelegate which is typically ur appDelegate file and most of the times you would like to get notified of these events in individual ViewControllers rather than in AppDelegate you can always use NotificationCenter and add observer for UIApplicationWillResignActiveNotification

read : How to access UIViewController's varaibles inside "func applicationWillResignActive"? Swift, iOS xcode

like image 199
Sandeep Bhandari Avatar answered Feb 04 '23 01:02

Sandeep Bhandari