All Projects → contentful → Stargate

contentful / Stargate

Licence: MIT license
A communication channel from your Mac to your watch.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
Makefile
30231 projects

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].