iPad cover actions detection

I have a Swift 3 application where I need to distinguish between the two following actions:

Action 1: run in foreground by pressing the app icon OR opening the iPad cover

Action 2: run in background by presing the home button or closing the iPad cover


At the moment I am able to take actions by using the two AppDelegate.swift functions

func applicationWillEnterForeground(application: UIApplication) // When the app was launched by touching its icon OR the iPad cover was opened

func applicationDidEnterBackground(application: UIApplication) // When the Home button was pressed OR the iPad cover was closed


Question:


How can I recognize when the action is taken fby the Home button OR the iPad cover open/close ?


Beppe

You should probably look for the notification taht is sent by the system (if there is one specific to the cover)


This SO may give you a hint on how to proceed.


http : / / stackoverflow.com/questions/19595928/differentiate-between-screen-lock-and-home-button-press-on-ios7/39886725?noredirect=1#comment67060141_39886725

No way to detect the iPad cover actions.

Also, in the simulator the "open/close cover" command is not present.

The "Lock" (cmd+L) seems to be something else.


Read the suggested SO, but still ....messed up

iPad cover actions detection
 
 
Q