My work on Ultimate Password Manager version 3.0 has started. The first thing that I'm looking into is Fast Application switch and multitasking. In order for an iOS 4.0 based application to support Fast application switching, there is a few things that needs to be implemented or modified in Ultimate Password Manager code.
Many new application delegate methods needs to be in place:
- application:DidFinishLaunchingWithOptions: this is the first application delegate method called at launch time. Make it lightweight. This new delegate method replace applicationDidFinishLaunching method.
- applicationDidBecomeActive: this method is called when the application enters the foreground state. This could be the result of the application being started (after the application:DidFinishLaunchingWithOptions call) or coming from the background state. This methods needs to be implemented too as it is part of the application startup sequence (called after applicationDidFinishLaunchingWithOptions: method). This is where the data structures loading and initialization will take place.
- applicationWillResignActive: for Ultimate Password Manager, this method doesn't need to implement this at the next step is to be put in background, this is where we will do the work of saving the application state. BUT, since this method is called when an external event occurs (like SMS messages is received), if the user doesn't answer the incoming event, applicationDidBecomeActive: will be called but the application context being already live, we don't need in this case to reload it. I will have to implement a flag for that.
- applicationDidEnterBackground: replace entirely applicationWillTerminate method. Five (5) seconds is the time available to save application state. Most of the code here will come from applicationWillTerminate:.
- applicationWillEnterForeground: this is a transition state and the next step is a call to applicationDidBecomeActive. I don't need to do much there.
- applicationWillTerminate: this method should stay implemented but most of the content must be put in applicationDidEnterBackground. Even under iOS4-based app that don't run on iOS 3.x, this method can be called by the operating system when the application is in background and needs to terminate the app. I think this doesn't apply for my app as no background task will be executing while in background (there is no long lasting task in Ultimate Password Manager). I may need to test that or ask the expert in forums.
- Cleaning up resources for active alerts when going in background: what do we have to do in code to take care of presented UIActionSheet or UIAlert before going to the backup.
- Removing sensitive information from the screen when method applicationDidEnterBackground because a screenshot is taken by iOS in order to present it back when the application returns to the foreground. In Ultimate Password Manager case, this includes removing any passwords that could be shown in a password safe entry...
- While the application is in background, UIApplicationExitsOnSuspend needs to be handled.
- Also while the application is in background, NSUserDefaultsDidChangeNotification needs some processing in order to adjust the UI for the new locale.
- The application can be (and will be launched) after a local notification is received.
- I also need to remove the UIApplicationExitsOnSuspend key from the info.plist that was there in order to prevent my application to be put in background as it wasn't ready to support the new delegate methods in iOS 4.