在我的Flutter应用中使用Laravel回声聊天 [英] chat using Laravel echo in my flutter app

查看:50
本文介绍了在我的Flutter应用中使用Laravel回声聊天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 laravel_echo 0.2.2 和pusher进行聊天.在调试模式下可以正常工作,但在发布模式下则无法工作.

I'm working on a chat using laravel_echo 0.2.2 and pusher. it's work just fine in debug mode but in the release mode it's doesn't work.

我的回声配置是:

echo = new Echo({
  'broadcaster': 'pusher',
  'client': pusherClient,
  "wsHost": 'api.salatkksa.com',
  "httpHost": 'api.salatkksa.com',
  "wsPort": 6001,
  'auth': {
    "headers": {'Authorization': 'Bearer $token'}
  },
  'authEndpoint': 'http://api.salatkksa.com/api/broadcasting/auth',
  "disableStats": true,
  "forceTLS": false,
  "enabledTransports": ['ws', 'wss']
});

和我的推送器配置:

PusherOptions options = PusherOptions(
    host: 'api.salatkksa.com',
    port: 6001,
    encrypted: false,
    auth: PusherAuth('http://api.salatkksa.com/api/broadcasting/auth',
        headers: {'Authorization': 'Bearer $token'}));
pusherClient = FlutterPusher(
  "468adb0d5808c1",
  options,
  enableLogging: true,
);

我只是试图将此添加到 application 标记内的 androidmanafist.xml 中:

I just tried to add this to my androidmanafist.xml inside the application tag:

android:usesCleartextTraffic="true" 

因此,如果我添加SSL证书并使用加密的消息传递,它将起作用吗?

so if I add an SSL certificate and use encrypted messaging it will work or not?

推荐答案

我通过使用R8或proguard启用代码混淆来解决此问题,并添加以下规则:

I solve it by enabling code obfuscation with R8 or proguard, and add the following rule:

android/app/build.gradle中:

buildTypes {
  release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

,如果没有 proguard-rules.pro ,则在此路径中创建一个 android/app/proguard-rules.pro 并添加以下内容:

and if you don't have proguard-rules.pro create one in this path android/app/proguard-rules.pro and add the following:

-keep class com.github.heywhy.flutter_pusher.** { *; }

这篇关于在我的Flutter应用中使用Laravel回声聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆