This course is available as part of the raywenderlich.com Professional subscription. To learn more click here
Pro

Multipeer Connectivity in iOS

Jan 12 2021 · Video Course (22 mins) · Advanced

In this course, you'll learn how to use Multipeer Connectivity: Apple's framework for transferring data between devices with no external network.

Version

  • Swift 5, iOS 14, Xcode 12

Set up Info.plist

2:08 Free

The first step to adding Multipeer Connectivity to any app is to ask for permission and tell users why it will use a local network. You'll use Info.plist for this.

1

In order to advertise your device to others, you'll need to use a reference to a Multipeer Connectivity Session object.

2

Once your device is advertising that it’s available, you'll need to employ MCNearbyServiceAdvertiserDelegate to handle requests to connect to other devices.

3

Discovery

3:19

When you have devices advertised through Multipeer Connectivity, the next step is to discover them. For that, you can use an MCNearbyServiceBrowser object.

4

Send Data

4:11

With an MCSession on one device, you can send data. And on another, an MCSessionDelegate will receive it.

5

Multipeer Connectivity provides a standard UI that abstracts what can be achieved with MCNearbyServiceBrowser: MCBrowserViewController.

6

Who is this for?

If you need a way to communicate wirelessly with Apple devices in close proximity to each other, in a blazing fast way, and you're quite comfortable with Swift, this course is likely a good match for you. SwiftUI and Combine knowledge will be helpful: they're both used in this course, but are not essential for employing Multipeer Connectivity.

Covered concepts

  • Local Networking
  • MCSession
  • MCNearbyServiceAdvertiser
  • MCBrowserViewController
  • Combine

Contributors

Comments