edolecki edited this page Feb 26, 2013 · 7 revisions

If you've found that you need one or more iOS applications to communicate with one another you've probably coded up various ways of doing it. A way I've found that's quick and pretty reliable is using Game Kit. However I found myself coding a lot of the same stuff over an over again and decided to make a Class that can do all the lifting for me.

Getting Started

Getting started it quite easy. Make sure to add the GameKit.framework to each project that will require communication with other iOS applications. In Xcode select your project in the Project Navigator on the left side. Select your target and choose Build Phases. Open up Link Binary with Libraries, click the + button and choose GameKit.framework. That bit is done.

Next Step

Add the GameKitRemote .h and .m files to your project. Import the .h file somewhere in a Class file where you'd like to use it (for example in a view controller). You're almost done!

Last Steps

There are a few methods to use, you can check the source and see them there. The current list:

  • GameKitRemote *gkr = [GameKitRemote alloc] initWithSession:@"abc123ZYX" displayName:@"Steel Panther"];
  • [gkr connect]
  • NSLog( @"%@", gkr.displayName );
  • NSLog( @"%@", gkr.sessionID );
  • [gkr sendStringDataToPeers:@"I am a message"];
  • [gkr disconnect];

Your applications can be completely different but to get the communication to work properly between applications make sure that your session string and display name match.

As a test simply build the same test project onto two different devices and press the connect button on both. The simulator will not work as part of testing. You'll need real devices.

When you initiate the connect method an iOS dialog will display while that device searches for matching session IDs - when it finds another it will display the display name for the other device it found. Select that - and on the other device you'll get a confirmation to connect dialog. Once accepted, the devices are connected over Bluetooth and they can send and receive data from one another. This is set up to use string data to push and send, but it could be modified to send images, etc. as well since the mechanism is set up for NSData.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.