微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Quickblox-Flutter JNI与本机C ++分离

如何解决Quickblox-Flutter JNI与本机C ++分离

我在Flutter应用中使用Quickblox进行聊​​天。建立连接后,聊天即可正常进行。当应用程序发送到后台时,我按照Quickblox文档的建议将连接设置为关闭。但是,当我重新打开我的应用程序时,在事件(QBChatEvents.RECEIVED_NEW_MESSAGE)中它不再收到消息。尽管已在日志中发送和接收消息,但是此事件不再起作用。日志显示此异常,

Tried to send a platform message to Flutter,but FlutterJNI was detached from native C++. Could not send. Channel:

这是我订阅的活动,

QB.chat.subscribeChatEvent(QBChatEvents.RECEIVED_NEW_MESSAGE,(data) {
         // my implementaion here
      });

我已经从他们的文档中添加了此实现。

class _SomeScreenState extends State<SomeScreen> with WidgetsBindingObserver {
  
@override
initState() {
  super.initState();
  WidgetsBinding.instance.addobserver(this);
}

@override
void dispose() {
  WidgetsBinding.instance.removeObserver(this);
  super.dispose();
}
  
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
  switch (state) {
    case AppLifecycleState.resumed:
      try {
        await QB.chat.connect(userId,userPassword);
        } on PlatformException catch (e) {
        // Some error occured,look at the exception message for more details
        }
      break;
    case AppLifecycleState.paused:
      print("app in paused");
      try {
        await QB.chat.disconnect();
      } on PlatformException catch (e) {
        // Some error occured,look at the exception message for more details
        }
      break;
}

我在做什么错了?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。