aciidgh / SwiftMQTT

MQTT Client in pure swift ❤️
MIT License
270 stars 71 forks source link

A little bit issue in background #17

Closed bucky0970 closed 6 years ago

bucky0970 commented 7 years ago

When my app is running, I send a silent push to request app do a subscribe. It's no problem.console:

2016-12-26 10:33:27.666401 Myapp[4515:1489204] didReceive in BG!!! 2016-12-26 10:33:27.791351 Myapp[4515:1489204] Connected! 2016-12-26 10:33:27.792438 Myapp[4515:1489204] Subscribed! 2016-12-26 10:33:27.798099 Myapp[4515:1489204] received:Hello World , in:/topic/state

But if my app is in background, I send a silent push to request app do a subscribe. It's has a problem.console:

2016-12-26 10:37:02.084332 Myapp[4515:1489204] didReceive in BG!!!

It stuck in first line of my code, when I push second time, console:

2016-12-26 10:37:02.084332 Myapp[4515:1489204] didReceive in BG!!! 2016-12-26 10:37:52.354677 Myapp[4515:1489204] Connected! 2016-12-26 10:37:52.357002 Myapp[4515:1489204] Subscribed! 2016-12-26 10:37:52.358031 Myapp[4515:1489204] received:Hello World , in:/topic/state 2016-12-26 10:37:52.358843 Myapp[4515:1489204] received:Hello World , in:/topic/state 2016-12-26 10:37:52.364654 Myapp[4515:1489204] didReceive in BG!!! 2016-12-26 10:37:52.546004 Myapp[4515:1489204] Connected! 2016-12-26 10:37:52.546695 Myapp[4515:1489204] Subscribed! 2016-12-26 10:37:52.547312 Myapp[4515:1489204] received:Hello World , in:/topic/state

It seems to show twice result? the first push result shows when second push arrive, when I push third time, It stuck on "Subscribed!", not show the messages. What the difference between app active and background cause this problem, please help me~