Advertisement
Guest User

Untitled

a guest
Dec 26th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. 2016-12-26 15:06:17.793051 App[] didReceive in BG!!!
  2. 2016-12-26 15:06:17.932569 App[] Connected!
  3. 2016-12-26 15:06:17.936581 App[] Subscribed!
  4. 2016-12-26 15:06:17.938355 App[] received:Hello World , in:/topic/state
  5.  
  6. 2016-12-26 15:06:22.674577 App[] applicationWillResignActive
  7. 2016-12-26 15:06:23.228441 App[] applicationDidEnterBackground
  8.  
  9. 2016-12-26 15:06:30.642825 App[] didReceive in BG!!! //first push code
  10. 2016-12-26 15:06:31.842432 App[] Connected! //first push code
  11. 2016-12-26 15:06:31.843643 App[] Subscribed! //first push code
  12.  
  13. 2016-12-26 15:06:41.713718 App[] received:Hello World , in:/topic/state //first push result
  14. 2016-12-26 15:06:41.740015 App[] didReceive in BG!!! //second push
  15. 2016-12-26 15:06:42.911593 App[] Connected! //second push
  16. 2016-12-26 15:06:42.913403 App[] Subscribed! //second push
  17.  
  18. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
  19. NSLog("didReceive in BG!!!" )
  20. application.delegate = self
  21. mqttSession = MQTTSession(host: "192.168.159.110", port: 1883, clientID: "swift", cleanSession: true, keepAlive: 5, useSSL: false)
  22. mqttSession.username = "bucky"
  23. mqttSession.password = "bucky"
  24. mqttSession.delegate = self
  25.  
  26. mqttSession.connect { (succeeded, error) -> Void in
  27. if succeeded {
  28. NSLog("Connected!")
  29.  
  30. }
  31. }
  32. completionHandler(.newData)
  33. }
  34.  
  35. func mqttDidReceive(message data: Data, in topic: String, from session: MQTTSession) {
  36. let stringData = String(data: data, encoding: .utf8)
  37. NSLog("received:%@ , in:%@", stringData ?? "12345", topic)
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement