pusher / push-notifications-flutter

Official Pusher Beams Flutter client plugin (iOS, Android and Web), receive notifications easily on your Flutter application with Pusher Beams.
https://pub.dev/packages/pusher_beams
MIT License
11 stars 30 forks source link

Switching instanceId's not possible #49

Closed Arthurius closed 2 months ago

Arthurius commented 9 months ago

For our application, we are using a different instanceId per environment (dev, test, accept and prod). For our debug application we have an environment switch. Whenever we switch between environments, we want to stop Pusher, and start with a new instanceId. But when we do, this throws an exception:

E/flutter (17079): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(IllegalStateException, java.lang.IllegalStateException: PushNotifications.start has been called before with a different instanceId! (before: XXXXXXXX, now: XXXXXXXX).
E/flutter (17079): If you want to use multiple instanceIds use the `PushNotificationsInstance` class directly e.g. `val pushNotifications1 = PushNotificationsInstance(context, instanceId)`
E/flutter (17079): `pushNotifications1.start()`, null, null)

Is it possible, like the exception states, to use multiple PushNotificationsInstances in Flutter? I could not find a way to do this. Or can we really stop and clear the instanceId before we start a new instance?

Arthurius commented 8 months ago

Anyone had a chance to look at this issue? It's quite inconvenient to have to restart the application each time we switch environment.

Arthurius commented 2 months ago

Still no update on this?

hans06806 commented 2 months ago

Hi @Arthurius I have responded to the support ticket 355685. Please update the ticket if you have any further questions. Thanks.

Arthurius commented 2 months ago

Thank you @hans06806 , the problem is that this does not work on Flutter. I tried everything to dispose and stop the instance, but it simply does not work. As a workaround I built our own wrapper around the iOS and Android SDK's. There it does work.