Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access applicationDidEnterBackground from viewController

How can I call applicationDidEnterBackground that in AppDelegate from a viewController?

I want to run a function in the background of the app without pressing home button.

like image 858
Eman87 Avatar asked Dec 06 '22 01:12

Eman87


1 Answers

You are not supposed to call that function from anywhere. It is there to let you know when the app enters the background.

Do you simply want to know when the app enters the background? If so, then you can create a notification to help you with that:

[[NSNotificationCenter defaultCenter] addObserver: self
                                         selector: @selector(handleEnteredBackground:) 
                                             name: UIApplicationDidEnterBackgroundNotification
                                           object: nil];
like image 110
joelg Avatar answered May 16 '23 07:05

joelg