When an iOS app directly enters the background state?
Can someone tell me a scenario when an iOS application directly enters the background state?.
Here I have quoted the lines from iOS Application Programming Document in multitasking section.
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.
In the iOS Application Programming Document if you see the figure 3.3 titled Launching an app into the background, the flow is like this User taps app icon -> main() -> UIApplicationMain() -> Enter background. Is there any chance when the app directly enters background when an user taps app icon. I interpreted the image like this. Is it correct?
Lets say you had registered your application for Local/Push notification. Then your application will launch in background run some code which have written inside your applicationDidEnterBackgroud: delegate method and then it terminates immediately.
Check listing 2
Applications might also find local notifications useful when they run in the background and some message, data, or other item arrives that might be of interest to the user. In this case, they should present the notification immediately using the UIApplication method presentLocalNotificationNow: (iOS gives an application a limited time to run in the background). Listing 2-2 illustrates how you might do this.
One scenario for a background launch (App X)
- X registered for location background mode in its Info.plist
- X is run by the user, and registers for significant location changes while running
- The user switches to another app Y, so X goes to background and is then suspended (it will be returned to background mode whenever there is a significant location change to handle, and then be suspended again)
- The app Y eats lots of memory, so suspended applications (including X) get kicked out of memory
- a significant location change comes in. Now X is launched into background.