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!