<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ios 7 development Archives - [x]cube LABS</title>
	<atom:link href="https://cms.xcubelabs.com/tag/ios-7-development/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Mobile App Development &#38; Consulting</description>
	<lastBuildDate>Tue, 10 Feb 2026 05:09:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>iOS 7 Background Execution and Multitasking</title>
		<link>https://cms.xcubelabs.com/blog/ios-7-background-execution-and-multitasking/</link>
					<comments>https://cms.xcubelabs.com/blog/ios-7-background-execution-and-multitasking/#respond</comments>
		
		<dc:creator><![CDATA[[x]cube LABS]]></dc:creator>
		<pubDate>Wed, 14 Aug 2013 09:53:04 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Platform]]></category>
		<category><![CDATA[iOS 7 design]]></category>
		<category><![CDATA[ios 7 developers]]></category>
		<category><![CDATA[ios 7 development]]></category>
		<guid isPermaLink="false">http://www.xcubelabs.com/blog/?p=2789</guid>

					<description><![CDATA[<p>Multitasking has always been a smart way to switch between apps. Multitasking allows apps to continue running in the background even after the user switches to another app. Multitasking has been supported in iOS since iOS 4, but it was quite restricted, operating only with music, location and voip. This becomes very frustrating when we [&#8230;]</p>
<p>The post <a href="https://cms.xcubelabs.com/blog/ios-7-background-execution-and-multitasking/">iOS 7 Background Execution and Multitasking</a> appeared first on <a href="https://cms.xcubelabs.com">[x]cube LABS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="text-align: justify;"><span style="color: #000000;">Multitasking has always been a smart way to switch between apps. Multitasking allows apps to continue running in the background even after the user switches to another app. Multitasking has been supported in iOS since iOS 4, but it was quite restricted, operating only with music, location and voip. This becomes very frustrating when we need to download some content for an app in the background, but it isn’t supported. With iOS 7 Apple provided multitasking for almost every app. Now we can perform lots of task when an app is in the background.</span></p>
<p style="text-align: justify;"><a href="http://www.xcubelabs.com/wp-content/uploads/2013/08/ios7.jpeg"><img fetchpriority="high" decoding="async" class="aligncenter size-large wp-image-6486" src="http://www.xcubelabs.com/wp-content/uploads/2013/08/ios7-1024x596.jpeg" alt="ios7" width="474" height="275" srcset="https://d6fiz9tmzg8gn.cloudfront.net/wp-content/uploads/2013/08/ios7-1024x596.jpeg 1024w, https://d6fiz9tmzg8gn.cloudfront.net/wp-content/uploads/2013/08/ios7-300x174.jpeg 300w, https://d6fiz9tmzg8gn.cloudfront.net/wp-content/uploads/2013/08/ios7.jpeg 1600w" sizes="(max-width: 474px) 100vw, 474px" /></a></p>
<p style="text-align: justify;"><span style="color: #000000;">By integrating the new multitasking APIs in iOS 7, the app can keep the content up-to-date. The new service allows your app to update information and download content in the background without draining the battery unnecessarily. The updates can happen at opportunistic times and are intelligently scheduled according to usage, so your app can update content in the background only when your users need it.</span></p>
<p style="text-align: justify;"><span style="color: #000000;"><span id="more-2789"></span></span></p>
<p style="text-align: justify;"><span style="color: #000000;">With iOS 6 and earlier, when an app goes to the background and is still executing a background task—if the device is then locked—the device will not go into sleep mode. It will be awake until the background task is completed. Whereas in iOS 7, the device will go to sleep shortly afterwards. Background tasks will execute at periodical intervals when the device is awake for any other tasks such as fetch mail, etc.</span></p>
<p style="text-align: left;"><span style="color: #000000;">&#8211; New Multitasking API&#8217;s with iOS 7</span><br />
<span style="color: #000000;">&#8211; Background Fetch</span><br />
<span style="color: #000000;">&#8211; Remote Notifications</span><br />
<span style="color: #000000;">&#8211; Background Transfer Service</span></p>
<p style="text-align: left;"><span style="color: #000000;"><strong>Background Fetch:</strong></span><br />
<span style="color: #000000;"> With this new API, an application will be able to fetch the new content and keep the content up-to-date so that users can see the new and interesting content when the app is opened without a waiting time.</span></p>
<p style="text-align: left;"><span style="color: #000000;">Steps to enable this feature on the application:</span></p>
<p style="text-align: left;"><span style="color: #000000;">1. Either in the info.plist or in the new Xcode feature capabilities, you can enable the background fetch by adding this key to UIBackgroundModes.</span><br />
<span style="color: #000000;"> Include “UI Background Modes” key with “fetch” value in info.plist</span></p>
<p style="text-align: left;"><span style="color: #000000;">2. To set a minimum background fetch interval that will allow your app to enable these fetches, just start with:</span></p>
<pre style="text-align: left;"><span style="color: #000000;">[app setMinimumBackgroundFetchInterval: UIApplicationBackgroundFetchIntervalMinimum]</span></pre>
<p style="text-align: left;"><span style="color: #000000;">We can set UIApplicationBackgroundFetchIntervalMinimum / UIApplicationBackgroundFetchIntervalNever or custom interval in seconds as background fetch interval. By Default it holds UIApplicationBackgroundFetchIntervalNever.</span></p>
<p style="text-align: left;"><span style="color: #000000;">When there is no need to download the content in the background, we need to set UIApplicationBackgroundFetchIntervalNever.</span></p>
<p style="text-align: left;"><span style="color: #000000;">3. To handle the new API/delegate method to download the content.&nbsp;</span></p>
<pre style="text-align: left;"><span style="color: #000000;">(void) application : (UIApplication *)application performFetchWithCompletionHandler:
(void(^) (UIBackgroundFetchResult))completionHandler
{
//fetch the latest content [_contentLoader downloadContentWithCompletionHandler:^
(BOOL didReceiveNewContent)
{
if(didReceiveNewContent)
{
completionHandler(UIBackgroundFetchResultNewData);
}
else
{
completionHandler(UIBackgroundFetchResultNoData);
}
}
}</span></pre>
<p style="text-align: left;"><span style="color: #000000;">Here one thing which is very important to remember after completing the download process—we have to tell iOS that the download is complete by using the “completion handler” in the method above, so that iOS can switch the app to a suspended state.</span></p>
<p style="text-align: left;"><span style="color: #000000;"><strong>Remote Notifications:</strong></span></p>
<p style="text-align: left;"><span style="color: #000000;">With this new API, an application will be able to download the content when the app receives the push notification. This will be really very useful for developers—an app can download the push notification related content before the user sees the banner notification.</span></p>
<p style="text-align: left;"><span style="color: #000000;">In addition to this, push notifications can omit the alert key and send it to the app as a silent notification. The app will not show any banner for this, but will be notified with the data availability. The application can load the data content before the next time an app opens to keep the app data up-to-date.</span></p>
<p style="text-align: left;"><span style="color: #000000;">Steps to enable this feature on the application:</span></p>
<p><span style="color: #000000;"> 1. Either in the info.plist or in the new Xcode feature capabilities you can enable the remote notification by adding this key to UIBackgroundModes.</span></p>
<p style="text-align: left;"><span style="color: #000000;">Include “UI Background Modes” key with “remote-notification” value in info.plist .</span></p>
<p><span style="color: #000000;"> 2. Set content available flag in push notifications to inform the app of the content available to download.</span></p>
<p style="text-align: left;"><span style="color: #000000;">3. Handle the new API/delegate method to download the content.</span></p>
<pre style="text-align: left;"><span style="color: #000000;">- (void) application : (UIApplication *)application didReceiveRemoteNotification:
  (NSDictionary *)userInfo performFetchWithCompletionHandler:(void(^)
  (UIBackgroundFetchResult))completionHandler
 {
 //fetch the latest content
 if(![[userInfo objectForKey:@"content-available"] intValue])
 {
 completionHandler(UIBackgroundFetchResultNoData);
 return;
 }
 [_contentLoader downloadContentWithCompletionHandler:^(BOOL didReceiveNewContent){
 if(didReceiveNewContent)
 {
 completionHandler(UIBackgroundFetchResultNewData);
 }else
 {
 completionHandler(UIBackgroundFetchResultNoData);
 }
 }
 }</span></pre>
<p style="text-align: left;"><span style="color: #000000;"><strong>Background Transfer Service:</strong></span></p>
<p style="text-align: left;"><span style="color: #000000;">In iOS 6, apps can transfer files while in the foreground or for a few minutes when the app returns to the background. It also could not effectively auto-download content or upload large assets.</span><br />
<span style="color: #000000;"> iOS 7 provides a service to enqueue downloads and uploads that continue even after an app exits. It is not restricted by time and allows the enqueue of even large data.</span></p>
<p style="text-align: left;"><span style="color: #000000;">Steps to use this feature on the application:</span></p>
<p style="text-align: justify;"><span style="color: #000000;">1. Create a background NSURLSession and figure it with NSURLSession configuration. We need to create a download or upload task using NSURLSessionTask with NSURLRequest and then enqueue it on NSURLSession by adding it to it.</span></p>
<p style="text-align: left;"><span style="color: #000000;">2. Handle the new API/delegate method to handle the downloaded content.</span></p>
<pre style="text-align: left;"><span style="color: #000000;">- (void) application: (UIApplication *)application performFetchWithCompletionHandler:
  (void(^) (UIBackgroundFetchResult))completionHandler
 {
 //fetch the latest content
 //Create a Configuration Object
 NSURLSessionConfiguration* sessionConfig =
 [NSURLSessionConfiguration defaultSessionConfiguration];
 nsConfig.allowsCellularAccess = YES;</span></pre>
<pre style="text-align: left;"><span style="color: #000000;">//Create a Session
 NSURLSession *dataDownloadSession = [NSURLSession sessionWithConfiguration: sessionConfig];
 NSURL* fetchURL = [NSURL URLWithString:@"http://www.google.com"];
 [dataDownloadSession dataTaskWithHTTPGetRequest:fetchURL completionHandler:^
 (NSData* data, NSURLResponse* response, NSError* error)
 {
 NSLog(@"Fetch Completed");
 completionHandler(UIBackgroundFetchResultNewData);</span></pre>
<pre style="text-align: left;"><span style="color: #000000;">}];
 }</span></pre>
<p>The post <a href="https://cms.xcubelabs.com/blog/ios-7-background-execution-and-multitasking/">iOS 7 Background Execution and Multitasking</a> appeared first on <a href="https://cms.xcubelabs.com">[x]cube LABS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cms.xcubelabs.com/blog/ios-7-background-execution-and-multitasking/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
