Reputation: 3387
In the documentation (App States and Multitasking) which Apple provides:
If your app is launched into the background instead—usually to handle some type of background event—the launch cycle changes slightly to the one shown in Figure 3-3. The main difference is that instead of your app being made active, it enters the background state to handle the event and then is suspended shortly afterward. When launching into the background, the system still loads your app’s user interface files but it does not display the app’s window.
How to simulate to launch an app into the background in iOS Simulator?
If an app launched into the background, will the UIApplicationDelegate
method -applicationDidEnterBackground:
be called?
Upvotes: 2
Views: 3104
Reputation: 3970
No, applicationDidEnterBackground:
won't be called in this case.
You can't simulate real launch into background behaviour if Xcode is attached.
(But you can simulate launch with UIApplicationLaunchOptionsLocationKey
key using location simulation)
I tested significant location change API on real device and collected logs after tests. Results:
application:willFinishLaunchingWithOptions:
is called with UIApplicationLaunchOptionsLocationKey
key.
But applicationDidEnterBackground:
is not called.
Upvotes: 1
Reputation: 234
You just have to launch your app and then go to home screen in simulator - press cmd + shift + H
and the app is in background state and - (void)applicationDidEnterBackground:(UIApplication *)application
in appDelegate is called .
Upvotes: 0