0

I am opening setting from my application viewcontroller like this

if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

And after turning notifications on for my app, when I tap on back button on status bar (I repeat status bar that is on top with sim and battery information) to comeback to my app. Now I want to know that how my app will know that user is back. willappear and didappear is not called.

Yawar
  • 1,924
  • 3
  • 29
  • 39
  • Your app will receive `willEnterForeground` App delegate call and notification – Paulw11 Sep 03 '18 at 13:19
  • Your `AppDelegate` will tell you when you are leaving/coming to your application. – Kamran Sep 03 '18 at 13:20
  • so I cannot handle it in my view controller? – Yawar Sep 03 '18 at 13:20
  • 1
    Fire notification from `AppDelegate` and listen in your `ViewController`. – Kamran Sep 03 '18 at 13:21
  • 2
    Your view controller can subscribe to the relevant notification; https://stackoverflow.com/questions/24910765/ios-nsnotificationcenter-to-check-whether-the-app-came-from-background-to-foregr – Paulw11 Sep 03 '18 at 13:23

1 Answers1

1

Your app delegate methods are colled that time:

func applicationWillEnterForeground(_ application: UIApplication)
func applicationDidBecomeActive(_ application: UIApplication)
Jogendar Choudhary
  • 3,476
  • 1
  • 12
  • 26