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
10 stars 21 forks source link

Conflict between webview and pusher beam in app Flutter #37

Closed chuvanhoang888 closed 1 year ago

chuvanhoang888 commented 1 year ago

When I use JavascriptChannel send webviewController.runJavascript(dataJs) of webview the app immediately cannot receive notifications from pusher beam but the app can still receive notifications in background

Please see the image below

image image image

chuvanhoang888 commented 1 year ago

I get an error when I use webview to send a piece of dataJs to the server, there seems to be a channel conflict between Beams and Webview "webviewController.runJavascript(dataJs);"

image image

image image image image

benjamin-tang-pusher commented 1 year ago

I tested this in the Android emulator with Flutter Webview running in the foreground, and its able to successfully receive Beams notifications: D/com.pusher.pusher_beams.PusherBeamsPlugin$onMessageReceivedInTheForeground$1$1@3b0e62e( 6069): Message received: {title=testing, body=test test test, data={pusher={"instanceId":"xxxxxxx","hasDisplayableContent":true,"publishId":"pubid-c79f50ce-8772-432c-bd20-4b05c43f4654"}}} Do you at least get the above log in your logcat? I also didn't test with JavascriptMode.unrestricted. If you do not use JavascriptMode.unrestricted, does it successfully receive foreground messages?

My code looks like this:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final BeamsAuthProvider provider = BeamsAuthProvider()
    ..authUrl = "aaaaa"
    ...
  const instanceID = 'aaaaa';
  await PusherBeams.instance.start(instanceID);
  await PusherBeams.instance.setDeviceInterests(['debug-new', 'hello']);
  PusherBeams.instance.onMessageReceivedInTheForeground(
      (notification) => print("Run notification handling: $notification"));
  runApp(
    const MaterialApp(
      home: WebViewApp(),
    ),
  );
}
class WebViewApp extends StatefulWidget {
  const WebViewApp({super.key});
  @override
  State<WebViewApp> createState() => _WebViewAppState();
}
...
benjamin-tang-pusher commented 1 year ago

I will close this due to no response.

chuvanhoang888 commented 1 year ago

Dear Sir, I am sending this email to give you test code and error video on ios. thankyou.

path_provider: ^2.0.11 pusher_beams: ^1.1.1 flutter_local_notifications: ^9.3.2 webview_flutter_android: ^3.0.0 webview_flutter_wkwebview: ^3.0.0 Screen Recording 2023-03-20 at 17.12.32.mov https://drive.google.com/file/d/16nou0mfsPrB7f5UyATXGx5JdNmgBDsLi/view?usp=drive_web

Vào Th 2, 27 thg 2, 2023 vào lúc 21:24 Benjamin Tang < @.***> đã viết:

Closed #37 https://github.com/pusher/push-notifications-flutter/issues/37 as not planned.

— Reply to this email directly, view it on GitHub https://github.com/pusher/push-notifications-flutter/issues/37#event-8616326982, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2F6PIGMB52SMY77QQTWZS2KJANCNFSM6AAAAAAS46ZJB4 . You are receiving this because you are subscribed to this thread.Message ID: <pusher/push-notifications-flutter/issue/37/issue_event/8616326982@ github.com>