Pubnub + Wink Hub和传感器的问题

时间:2016-08-05 21:44:36

标签: ios swift pubnub home-automation wink

我正在尝试让我的Wink Hub在我的iOS应用程序中使用Pubnub订阅,但我得到的是didReceiveStatus回调中的PNUnexpectedDisconnectCategory状态。

以下是代码:

class AppDelegate: UIResponder, UIApplicationDelegate, PNObjectEventListener {

    var window: UIWindow?
    var client: PubNub

    override init() {
        let configuration = PNConfiguration(publishKey: "", subscribeKey: "fake-key")
        client = PubNub.clientWithConfiguration(configuration)
        super.init()
        client.addListener(self)
    }

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        client.subscribeToChannelGroups(
            ["sensor-channel0",
            "sensor-channel1"],
                                        withPresence: false)

        return true
    }

    func client(client: PubNub, didReceiveMessage message: PNMessageResult) {        
        print("receivedMessage")
    }


    func client(client: PubNub, didReceiveStatus status: PNStatus) {        
    if status.category == .PNUnexpectedDisconnectCategory {
        print("disconnected")
        // This event happens when radio / connectivity is lost.
    }
}

订阅和频道密钥直接来自Wink API返回的设备订阅数据,所以我不确定我做错了什么。任何帮助将不胜感激!

0 个答案:

没有答案