CocoaMQTT
CocoaMQTT copied to clipboard
When the APP is launched from the background, the message fails to be sent, but can be received.
This problem will appear when the app is in the background for a while.
Below is my configuration file and code:
pod 'CocoaMQTT', :git => 'https://github.com/emqtt/CocoaMQTT.git' version: 1.2.1
let clientID = "CocoaMQTT-" + String(ProcessInfo().processIdentifier) mqtt = CocoaMQTT(clientID: clientID, host: host, port: port) mqtt.username = username mqtt.password = password mqtt.willMessage = CocoaMQTTWill(topic: "/will", message: "dieout") mqtt.keepAlive = keepAlive mqtt.cleanSession = false mqtt.autoReconnect = true mqtt.autoReconnectTimeInterval = 1
subscribe(topic, qos: . qos2)
@cocoay I have the same issue with the newest version 2.1.5. Were you able to solve this somehow, please?
@cocoay I have the same issue with the newest version 2.1.5. Were you able to solve this somehow, please?
Sorry, I'm not tracking this. I had to go with the 'MQTTClient' framework.
Try applying for some permissions in XCODE and see if that helps. Here are some reference documents Using background tasks to update your app
@leeway1208 The issue is that I'm not able to receive any new message when I return to the app from the background after the keepAlive
time of the client (60s by default). So I lock the device, wait for 60s and open the app - no new messages are received now when the app is in the foreground. It's not related to permissions and background capabilities. The client reconnects successfully but it doesn't receive any messages.