How to detect user pressing HOME key in iOS?

iOSMobile DevelopmentApps/Applications

It is very important to know when user is pressing home key as it puts the application to background, here we will be seeing how to identify or get a call when user presses home key.

In you AppDelegate.swift, there are delegates methods.

Open your AppDelegate.swift and in applicationWillResignActive(_ application: UIApplication) and applicationDidEnterBackground(_ application: UIApplication), write print statement and put a breakpoint as shown.

Run the application, once the app is launch tap the home button, applicationWillResignActive will be called and then applicationDidEnterBackground.

raja
Published on 07-Aug-2019 17:29:26
Advertisements