Skip to content
This repository has been archived by the owner on Jan 30, 2018. It is now read-only.

Latest commit

 

History

History
84 lines (55 loc) · 2.74 KB

README.md

File metadata and controls

84 lines (55 loc) · 2.74 KB

Stargate

Version License Platform Build Status

A communication channel from your Mac to your watch.

Providing a convenient wrapper around MMWormhole and PeerKit, Stargate leverages Multipeer Connectivity and App Groups to communicate between an OS X application and ᴡᴀᴛᴄʜ via your iPhone. The communication is bi-directional and lets you send any object that complies with NSCoding.

Usage

Simply install it via CocoaPods:

use_frameworks!

pod 'Stargate'

Note: make sure you use version 0.37 or newer. Stargate is written in Swift 1.2, so it requires Xcode 6.3 or newer as well.

On the Mac

Send and receive messages via Multipeer Connectivity:

let stargate = Earth(applicationGroupIdentifier: "group.com.contentful.Stargate")

stargate.listenForMessage(identifier: "stargate2") { (object) -> Void in
	println("Received message on Mac: \(object)")
}

stargate.passMessage("YOLO", identifier: "stargate")

On the phone

Bridge messages between Multipeer and Darwin notifications:

let stargate = Abydos(applicationGroupIdentifier: "group.com.contentful.Stargate")
    
stargate.tunnel()
stargate.tunnelReplies(identifier: "stargate2")

On the watch

Send and receive messages via Darwin notifications:

let stargate = Atlantis(applicationGroupIdentifier: "group.com.contentful.Stargate")

stargate.passMessage("YOLO", identifier:"stargate2")

stargate.listenForMessage(identifier:"stargate") { (object) -> Void in
	println("Received message on watch: \(object)")
}

stargate.stopListeningForMessage(identifier:"stargate")

Look at the example project for guidance on how to set up one project for all three platforms. When creating the targets, make sure you don't accidentially select the OS X target as host for the WatchKit extension.

License

Copyright (c) 2015 Contentful GmbH. See LICENSE for further details.