测试测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2015年5月 |
SPM支持SPM | ✗ |
依赖项 | |
MMWormhole | ~> 1.1 |
PeerKit | ~> 1.1 |
从您的Mac到您的查看器之间的通信频道。
在MMWormhole和PeerKit周围提供方便的包装工具,Stargate利用多对多连接和App Group在OS X应用程序和iPhone之间的ᴡᴀᴛᴄʜ上通信,通信是双向的,并允许您发送符合NSCoding
的任何对象。
简单通过CocoaPods安装它
use_frameworks!
pod 'Stargate'
注意:请确保您使用的是0.37或更高版本。Stargate是用Swift 1.2编写的,因此还需要Xcode 6.3或更高版本。
通过多对多连接发送和接收消息
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")
在Multipeer和Darwin通知之间连接消息
let stargate = Abydos(applicationGroupIdentifier: "group.com.contentful.Stargate")
stargate.tunnel()
stargate.tunnelReplies(identifier: "stargate2")
通过Darwin通知发送和接收消息
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")
查看示例项目以获取如何在所有三个平台上设置单个项目的指导。在创建目标时,请确保您没有意外地将OS X目标作为WatchKit扩展的主机。
版权(c)2015 Contentful GmbH。有关详细信息,请参阅LICENSE。