Flutter: await Backendless.messaging.subscribe("xxx"); broke app

Hi,i am coding flutter app ,but when run to “await Backendless.messaging.subscribe(“myChannel”);”,the app will be broken,and we cant catch exception,any idea,thanks!

void initListener() async{
try{
Channel channel = await Backendless.messaging.subscribe(“myChannel”);
channel.addMessageListener(onMessageRececive);
}catch(e){
var msg = e.toString();
_textMessageSubmitted(msg);
}

Hello Frank

Seems the issue is related to Flutter but not to Backendless
Take a look at this topic https://github.com/flutter/flutter/issues/32587

Regards, Vlad

Hi,Vlad
app is broken when run " await Backendless.messaging.subscribe(“myChannel”);",sowe get error like" lost connection to device ",then other errors happened.
if i use old version of backendless,then everything is ok,i only get error when i use backendless_sdk: ^1.0.1,seems version conflict

Hi @Frank_He

You need to add the io.socket dependency to support real-time messaging for Android clients. Open your build.gradle file that is located under android/app/ and add the following lines of code:

dependencies {
   implementation ('io.socket:socket.io-client:1.0.0') { 
     // excluding org.json which is provided by Android 
     exclude group: 'org.json', module: 'json' 
   }
}

Also this article may be helpful for you:
How to Create a Chat App with Backendless SDK for Flutter

Best Regards,
Maksym

Hi @Maksym_Khobotin,

It will be interesting add this dependency to Client-side Setup documentation or Real-Time Database Overview documentation

Thanks,
Dani