Laravel echo null and sockets in Flutter

84 Views Asked by At

So I was trying to use Laravel echo null package and it's connecting and it sends the data I give I can see it in the web version of the app which is built using vue js but here when I'm listening to the channel it doesn't print anything how can I listen to it correctly? and also this package has an issue with IOS it give me this error :

[!] No podspec found for `pusher_client_fixed` in `.symlinks/plugins/pusher_client_fixed/ios`

so do you know any other package to do the same? I tried using web sockets channel but it just says the connection was established Here's my code:

Echo<PusherClient, PusherChannel> echo =
      Echo<PUSHER.PusherClient, PusherChannel>(PusherConnector(
    'akm',
    authEndPoint:
        'https://api.akm-r.com/broadcasting/auth', // String?: auth host
    authHeaders: {
      // authenticate headers
      'Authorization': 'Bearer ${Helpers.readUserData()?.token}',
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
    // cluster: 'mt1', // String?: pusher cluster
    host: 'api.akm-r.com',
    wsPort: 443,
    wssPort: 443,
    encrypted: true,
    activityTimeout: 120000,
    pongTimeout: 30000,
    maxReconnectionAttempts: 6,
    maxReconnectGapInSeconds: 30,
    enableLogging: true,
    autoConnect: true, // bool: client connection automatically
    // nameSpace: 'nameSpace',
  ));

  _connect() {
    print('soket id ${echo.socketId}');
    echo.connect();
    echo.private('session.11111').subscribe();
    echo.private('session.11111').onSubscribedSuccess(() {
      print('subscribe');
    });
    echo.private('session.11111').listen('drivers.11111', (d) {
      print('listen $d');
    }).listenForWhisper('drivers.11111', (d) {
      print('here');
      print('whisper $d');
    }).error((e) {
      print('error $e');
    });
  }

  _send() {
    UserData? user = Helpers.readUserData();
    Map<String, dynamic> message = {"driver_mobile": user?.user?.mobile};
    echo.private('session.11111').whisper('drivers.11111', message).error((e) {
      print('error here');
      print('error $e');
    });
  }
2

There are 2 best solutions below

1
Jaimin Raval On

For IOS issue here is the solution:

1- Delete Podfile and Podfile.lock from ios folder

2- Flutter clean either from terminal or from Android studio -> Tools -> Flutter -> Flutter Clean

3- Pod install

4- Run the app

The solution is here: https://github.com/MisterJimson/flutter_keyboard_visibility/issues/52

0
Aleksey On

Try it

  1. Rename file

ios/.symlinks/plugins/pusher_client_fixed/ios/pusher_client.podspec

to->

ios/.symlinks/plugins/pusher_client_fixed/ios/pusher_client_fixed.podspec

  1. Replace the line in the file "pusher_client_fixed.podspec"

s.name = 'pusher_client'

to ->

s.name = 'pusher_client_fixed'