Issues with Pubnub + Wink Hub and sensors

爱⌒轻易说出口 提交于 2019-12-13 14:04:31

问题


I'm trying to get my Wink Hub working with Pubnub subscriptions in my iOS app, but all I ever get is a PNUnexpectedDisconnectCategory status in the didReceiveStatus callback.

Here is the code:

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.
    }
}

The subscribe and channel keys are taken straight from the device subscription data returned by the Wink API, so I am not sure what I am doing wrong. Any help would be appreciated!

来源:https://stackoverflow.com/questions/38798161/issues-with-pubnub-wink-hub-and-sensors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!