I am trying to emit a socket event in applicationWillTerminate in AppDelegate
. I have used socket.io
.
I believe I am able to successfully emit the event. Following are the logs I get in the console :
2018-10-08 20:29:45.663856+0530 SOCKET_POC[4718:303986] LOG SocketIOClient{/}: Emitting: 23["device-disconnect","{\"QrcodeID\":\"2a758b00-314f-d69d-a10b-24fca56693ed\",\"UniqueID\":\"E15C087D-626F-4F10-B0B3-7567DA76EF51\"}"], Ack: false 2018-10-08 20:29:49.561608+0530 SOCKET_POC[4718:304214] LOG SocketEngine: Writing ws: 23["device-disconnect","{\"QrcodeID\":\"123\",\"UniqueID\":\"123\"}"] has data: false 2018-10-08 20:29:49.561675+0530 SOCKET_POC[4718:304214] LOG SocketEngineWebSocket: Sending ws: 23["device-disconnect","{\"QrcodeID\":\"123\",\"UniqueID\":\"123\"}"] as type: 4
Please find the code below :
func applicationWillTerminate(_ application: UIApplication) {
print(SocketHandler.instance?.socket.status)
if let uniqueId = UserDefaults.standard.value(forKey: Constants.USER_DEFAULT_KEYS.UINQUE_ID) as? String {
CommonFunctions().emitResultOnDeviceDisconnect(qrcode: "\(Variables.QRCodeID)", uniqueId: uniqueId)
print(SocketHandler.sharedInstance().socket.status)
}
I have even printed the status of my socket which always prints connected.
But when I see the logs at the server(backend), they don't receive my emitted socket event at all.