BBPortal 0.1.2

BBPortal 0.1.2

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2018年11月
SPM支持 SPM

Dejan Agostini 维护。



BBPortal 0.1.2

BBPortal

Version License Platform

简介

BBPortal 是一个库,允许你在不同目标和应用程序之间(不包括手表目标)传递数据。它使用 App Groups 在后台将数据保存在共享容器中,并使用另一个库 - DAFileMonitor - 来监听文件上的更改。你可以创建任意数量的门户。你可以为你的门户分配不同的 ID,或者你可以让它们都具有相同的 ID。当你通过你的门户推送数据时,所有其他相同 ID 的门户都将收到数据。

在下面的示例中,你可以看到两个应用程序通过实时传递数据相互控制

BBPortal_usage_med2

你可以在我的博客上了解更多关于这个库的信息:http://agostini.tech/2017/08/13/sharing-data-between-applications-and-extensions-using-app-groups/

用法

var portal: BBPortalProtocol = BBPortal(withGroupIdentifier: "your.group.identifier.goes.here", andPortalID: "id.for.this.portal")

// Send data
portal.send(data: ["key": "What ever data you want"]) { 
    (error) in

    if let anError = error {
        print("Send failed with error: ", anError)
    }
}

// Receive data
portal.onDataAvailable = {
    (data) in

    guard let dict = data as? [String: Any?] else {
        return
    }

    print("I received some data through the portal: ", dict)
}

安装

BBPortal可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中:

pod 'BBPortal'

作者

Dejan Agostini,[email protected]

许可证

BBPortal遵循MIT许可证。有关更多信息,请参阅LICENSE文件。