0

I have a flutter application that uses Pusher beams to receive messages it's all working as expected in Android, in IOS when I run the app in debug mode it works fine as usual receives events even when the app is in Foreground but when I run it in release mode in xcode it stops receiving events in the background and it receives all of the events that were sent while the app was in the background once I restore it to the foreground this is my code putting it in the bloc of the home screen:

PusherOptions options = PusherOptions(
      auth: PusherAuth(
        url + 'broadcasting/auth',
        headers: {
          'Authorization': 'Bearer $token',
        },
      ),
      cluster: configurationModel.pusherAppCluster,
    );

    PusherClient pusher = PusherClient(
        configurationModel.pusherAppKey,
        options,
        autoConnect: false
    );

    pusher.connect();

    // Subscribe to a private channel
    Channel channel = pusher.subscribe(pusherChannel);

    // Bind to listen for events called "order-status-updated" sent to "private-orders" channel
    channel.bind(pusherEvent, (PusherEvent event) {
      _showNotificationCustomSound();
    });

1 Answers1

1

Well, I've been there. I used that exact package and it does not seem to be maintained anymore. I made a fork here. It has updated versions of base libraries like the iOS one, null safety and other goodies, at github I listed all the changes made. Please use that version and tell me if it solves your issue.

You can add it your your project as follows:

  pusher_client:
    git:
      url: https://github.com/fabiancrx/pusher_client
      ref: 7da7dddb

croxx5f
  • 5,163
  • 2
  • 15
  • 36
  • 1
    Thank you for the reply I tried your fork but unfortunately, it produced the same results, it appears to be as @Paulw11 said it has something to do with IOS shutting down network connection when the device enters the background, I had a friend of mine who is an IOS developer try the native PusherSwift in the project and it also didn't work – Nickola Jarjous Dec 17 '21 at 08:30