aciidgh / SwiftMQTT

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

Interupted messages #22

Closed mvorisis closed 7 years ago

mvorisis commented 7 years ago

Hi

I put a print under mqttDidReceive to have logs in xcode, then I tried on simulator and put the app in the background and sent a message that appeared in the log.

And now here comes the problem I tried the same thing on my iphone but when the app was in the background nothing came, and when I reopened it all messages came right a way.

Any thought of why is this happening?

I also asked in stackoverflow

adolfo commented 7 years ago

MQTT won't work in the background, at least not for an extended period of time. When the app enters the background you should disconnect from the MQTT server and when reentering the forground you reconnect and resubscribe. During this time you should rely on other methods to communicate with your app, i.e. push.

mvorisis commented 7 years ago

Thanks for the quick answer,

I just was so curious that it would work on simulator and not on Iphone,

Anyways I will disconnect it and reconnect properly

Thanks again