iOS 7 Round Table: AirDrop, Peer-to-Peer, Multitasking, and NSURLSession
Azoft Blog iOS 7 Round Table: AirDrop, Peer-to-Peer, Multitasking, and NSURLSession

iOS 7 Round Table: AirDrop, Peer-to-Peer, Multitasking, and NSURLSession

By Anna Orlova on March 25, 2014

iOS 7 Round Table: AirDrop, Peer-to-Peer, Multitasking, and NSURLSession Apple's iOS 7 has presented one of the most striking set of changes for mobile developers. The recent round-table session at Azoft hosted by Victor Kotov is a follow-up to Getting Ready for iOS 7 Release round table. This time Victor has covered four new features that have proved to be the most useful so far.

Key learning

  • AirDrop
  • Peer-to-Peer Connectivity
  • Multitasking
  • Networking with NSURLSession

Primary speaker

Victor Kotov, iOS developer

Let's take a close look at the issues in focus.


Introduced in Mac OS X Lion, AirDrop has been added to iOS 7 allowing users to share various kinds of data – documents, photos, URLs, etc. – with supported iOS devices (iPhone 5 and iPad 4th Gen) and Mac computers via Wi-Fi and Bluetooth. 

Developers could easily use AirDrop in their apps because AirDrop support is built into the existing UIActivityViewController class. You can reduce the list of suggested options by setting an array for excludedActivityTypes.

AirDrop settings allow to choose if sharing would be available on sending and receiving devices to Everyone or Contacts Only; in the latter case a user should be logged in his or her iCloud account to get AirDrop requests solely from users with known AppleIDs.

Table 1. Types of data and corresponding appsTypes of data and corresponding apps

The best part – you can share any type of data if you turn it in a file. A UTI (Uniform Type Identifier) is a unique ID for any type of data. Some UTIs are predefined by Apple but you can also make a custom one. A custom UTI (also known as URL Scheme) should be registered with an app. When receiving data of a registered type, the application:openURL:sourceApplication:annotation method would be called. The method would be called for each file sent. All files are stored in the Documents\Inbox folder; the folder should be manually checked after launching an app or returning from a sleeping mode.

Peer-to-Peer Connectivity

The new Multipeer Connectivity framework allows to share data and files between iOS devices without the Internet. An optimal connection method is chosen automatically, it might be Wi-Fi, peer-to-peer Wi-Fi or Bluetooth.

Peer-to-Peer Connectivity might be used when:

  • your app doesn't require the Internet connection
  • your app limits data sharing to nearby devices;
  • your app implies data sharing without any server component.

The basic terms of the framework:

  • Advertiser – a device offering some data or function to other devices;
  • Browser – a device locating nearby Advertisers, ready to use the offered data or service.

While the framework offers ready-made view controllers, you can also write custom ones.

A name of a service offered must:

  • be unique;
  • contain only ASCII letters in the lower case, figures and dashes;
  • be no longer than 14 symbols.

During initialization, a dictionary can be transmitted as a parameter; the requirements are:

  • all keys and values must be NSString in UTF-8 less than 255 bytes;
  • the whole dictionary shouldn't be less than 65535 bytes; the recommended value is 1300 bytes so it fits an Ethernet package.

The shared data could be a complex object, but it must correspond to NSCoding (NSKeyedArchiver / NSKeyedUnarchive). Besides NSData two more data types could be sent:

  • URL Content – NSURL
  • Streaming Content – NSOutputStream

Two modes of data sharing:

  • MCSessionSendDataUnreliable – when the speed is the top priority;
  • MCSessionSendDataReliable – when the security is the top priority.

Customisation: Even if you add your own non-standard view controllers for searching and establishing connection between peers, all other functionality will be the same as if you were using native iOS controllers. So you could start with a native UI and customize it later; the rest of your code should work fine.

Testing: Within one Wi-Fi network a simulator can be used.


iOS 7 introduces new multitasking opportunities:

  • Background Fetch – downloads regularly updated data (news feed, etc.) in an auto mode.
  • Background Transference – based on using NSURLSession, the feature manages downloads of large files easily; moreover it makes possible to receive notifications and launch apps when a download is complete.
  • Silent Push-Notifications – push-notifications that can initiate launching some task in the background.

To make background fetches work, an app should be in the system list of all launched apps. The use of it could be canceled by user: Settings > General > Background App Refresh.

The following method is called by the system right before downloading in the background: application:performFetchWithCompletionHandler:

There is no official information on how iOS sets priority for background downloading, but there is an opinion that the returned value for UIBackgroundFetchResult matters.


For detailed information, please refer to

VN:F [1.9.22_1171]
Rating: 5.0/5 (3 votes cast)
VN:F [1.9.22_1171]
Rating: +3 (from 3 votes)
iOS 7 Round Table: AirDrop, Peer-to-Peer, Multitasking, and NSURLSession, 5.0 out of 5 based on 3 ratings

Request a Free Quote

Please enter the result and submit the form

Content created by Anna Orlova