Learning iOS7 Multipeer Connectivity At Mobile Dev Day

To be honest, I haven’t been a big fan of hackathons ever since I started coding. For one, I’m a big fan of building healthy habits both for my body and mind. I like to eat healthy, sleep well, and write really well-designed clean code.

Hackathons discourage all of these habits! They’re long (usually over-night), the food served is pizza and beer and cookies and other junk (if you’re a hackathon organizer, please consider having some healthy brain food!), and you don’t have time to write clean code. In fact, the code you write is really about having it work well enough to show a good presentation, so a lot of the real-life edge-case scenarios are overlooked.

So I haven’t really gone to hackathons much, until now…

The New Hackathon Mindset

When I went to the Launch Hackathon last weekend and to the Parse and Facebook’s Mobile Dev Day yesterday, I went with the mission of learning something new. For the Launch Hackathon, I wanted to learn iBeacons, and for Mobile Dev Day I wanted to learn about Multipeer Connectivity.

When you’re first learning something, the code is going to get messy. You’re just experimenting around and don’t even know what’s going to work or not or how to best structure it well yet. It’s a perfect hack for a hackathon! And, even if you don’t win anything (we didn’t win anything yesterday), you walk away with amazing new knowledge!

This way, time you spent hacking at the hackathon is definitely justified no matter what happens (oh, and you might win)! Anyways, this “learn something new” mind-set has worked really well for me in the past week, and I plan to bring it to other hackathons I attend in the future!

Pairing to Learn

The best way to learn, as I first learned in my Dev Bootcamp days and from my job at Manilla, is through pairing. I came to the Mobile Dev Day without knowing anyone, and I was lucky to have run into Rob Aikins, who joined me in doing something neither of us have done before!

I watched the WWDC 2013 Nearby Networking with Multipeer Connectivity video in the morning before the Mobile Dev Day, and played around with some basic understanding of how it worked, but inevitably, in the short 4 hours that we had to code, we spent about 30 minutes debugging the invite flow to a peer. If it was just me, I would have spend the rest of the time having no idea what was wrong with my code. It was Rob who came up with a brilliant fix!

Hackathons are a great place to meet people with complimentary skills to yours, and just by pairing, you can learn more together much faster than you can ever learn on your own at home!

The Idea

Usually, for me at least, it’s pretty hard to come up with a hackathon idea. However, since I had the goal of using the Multipeer Connectivity framework and we had to use the Parse and Facebook APIs for our hack, these constraints made it a lot simpler.

We decided to build Rumor:

  • Log in with Facebook
  • See which of your friends are nearby (this is using the Wifi or Bluetooth connectivity on your phone, so the nearby radius is variable but probably around 50 feet).
  • Click Chat to invite your nearby Facebook friends to chat
  • Chat away!
  • Once everyone leaves the chat (no more friends nearby), the chat is destroyed!

Since the chat does not require internet connectivity (it works with just bluetooth), this could be a great app in emergency situations where the networks are down and you can’t call / text to check on friends nearby, or at concerts where it’s loud and you can’t hear anyone, or, of course, it could be used by teens to chat with each other on a bus on the way to school!

Unlike Groupme or similar services, there is no email / text-message invite-flow for chatting. As long as you’re Facebook friends and have the app installed, you can instantly see and chat with each other!

Also, unlike Groupme, the chat uses the multipeer connectivity to send and receive data, so the text message or image or file sharing happens without ever hitting the web server! It’s a truly incredible technology and I can’t wait to see how others use it!


… And we succeeded. Within a very short 4 hours, we got most of the functionality of Rumor to work! Here is a screenshot of my phone recognizing that Rob, my new Facebook friend, is nearby!

Rumor App

Next up, I’ll write a more technical post on how Multipeer Connectivity and iBeacons actually work so you can play with these cool technologies in your own app!

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.