aciidgh / SwiftMQTT

MQTT Client in pure swift ❤️

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interupted messages

mvorisis opened this issue · comments

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

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.

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