Home > Software engineering >  Flutter Listen Mqtt Server in Background
Flutter Listen Mqtt Server in Background

Time:06-21

I am working on controlling IOT devices from Flutter. IOT devices run with MQTT server and in Flutter I need to listen Mqtt server in background and according to coming messages, I want to push notification. I already tried WorkManager it connects MQTT in background but not listen. I think it works only one. I saw another solution writing native solution but it is so complicated and I dont understand. Is there any way to get handle it? I dont want to use extra server for that. Ex: Firebase messaging or OneSignal.

CodePudding user response:

If your MQTT server supports Websockets you can use websocket for your implementation, see https://docs.flutter.dev/cookbook/networking/web-sockets

CodePudding user response:

You can use flutter_background_service and flutter_local_notifications packages. You will listen api and when a message coming , you will show a notification , and when user click the notification , you can show page what you want and when app running at resume lifecycle, function will still working and you can listen with StreamBuilder widget (with on function)4

package adress = 'https://pub.dev/packages/flutter_background_service'

You can ask your question to me, I will answer

  • Related