Multitasking in iOS 7
At this WWDC-24 Tim Cook, CEO of Apple surprised the world with the launch of new iOS 7 that is the biggest change is iOS since the launch of iPhone. iOS 7 is completely decorated with a new flat beautiful design which look very simple and useful. iOS 7 design feature like full screen layout, transparent views, multilayer views etc. will give a pleasure to eyes of all iPhone lovers.
With a new design apple introduces some fascinating features in iOS 7. Like Control Centre, Airdrop, iTunes Radio, Multitasking, Siri, Photos and many more. Basically iOS 7 is power packed box with new design and new features.
In iOS 7 we have a quite new and beautiful layout of multitasking to switch between apps and close an app. When you press home button twice it will open a new screen where you can swipe left to right to choose the app, which you want to open. If you want to close just a swipe up it will be removed, no need to press and hold and wait till close button appear. It’s simple now.
Today we are going to talk about “Multitasking enhancement” in iOS 7. Multitasking is supported in iOS since iOS 4 but it was quite restricted as we can only do few things when app is in background mode like music, location and voip. This becomes very frustrating when we need to download some content for app in background, as it wasn’t supported. With iOS 7 apple provided multitasking for almost every app. Now we can perform lots of task when app is in background.
iOS 7 supports these background modes :
• Audio (audio)
• Location updates (location)
• Voice over IP (voip)
• Newsstand downloads (newsstand-content)
• External Accessory Communication (external-accessory)
• Bluetooth networking (bluetooth-central)
• Bluetooth data sharing (bluetooth-peripheral)
• Background fetch (fetch)
• Remote notifications (remote-notifications)
Background fetch and Remote notification will be really very useful for developers. Suppose you are developing an app, which is a kind of social network that has a feed screen, which needs regular updates but when app is in background mode then we were not able to refresh our feeds in background. Users have to wait while feeds being update. With background fetch feature in iOS 7 we can schedule app to fetch content in background before user is going to use it. When we schedule app for download in background then iOS automatically trigger an event when it finds that this is best time (with best network condition) to update app. So we can program app for this event to download all content in background. This will be very useful for all iPhone user as they will not require to open the app to update the content of app. Users will find app updated when they will open the app.
Similarly with remote notification support in background we can update content of app when app received a push notification. So iOS will trigger an event to app as it received a push notification and as the app complete its content download process push will be delivered to user. By this way app will get time to update content before the push is being delivered to user. This is really an awesome feature in iOS 7. Apple provided background supports for app when required which will save a lot of battery life, as app is not running in background all the time, it will run only when required. This is really a futuristic approach by Apple because saving battery life is really very important in mobile technology.
Schedule app in background:
To fetch content of app in background we need to schedule our app to run in background and fetch content when iOS triggers an event. For this we need to include “UI Background Modes” key with “fetch” value in info.plist Then we need to set a minimum background fetch interval by which minimum interval iOS triggers an event using this “set Minimum Background Fetch Interval:” method of “UI Application” class.
At last we have to implement “application:perform Fetch With Completion Handler:” in our app delegate to handle trigger event by iOS and fetch content in background.
Here one thing which is very import to remember after completing download process we have to tell iOS that download is complete by using the “completion handler” in above method. So that iOS can switch the app to suspended state.