fluttercommunity / flutter_webview_plugin

Community WebView Plugin - Allows Flutter to communicate with a native WebView.
https://pub.dev/packages/flutter_webview_plugin
Other
1.48k stars 933 forks source link

when FirebaseMessaging.onBackgroundMessage initialize in main, javaScriptChannel doesn't listen on Android #939

Open bartukaan opened 3 years ago

bartukaan commented 3 years ago

When I initialize FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler) in main function, webview javaScriptChannel doesnt listen any event on Android, but ios working well. Anyone encountering this error? Is there any idea for that situtation?

bartukaan commented 3 years ago

[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.19043.1348], locale en-US) • Flutter version 2.5.3 at C:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 18116933e7 (6 weeks ago), 2021-10-15 10:46:35 -0700 • Engine revision d3ea636dc5 • Dart version 2.14.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\Bartu\AppData\Local\Android\sdk • Platform android-31, build-tools 30.0.2 • Java binary at: E:\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Users\Bartu\AppData\Local\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3) • Android Studio at E:\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] Connected device (3 available)

flutter_webview_plugin: ^0.4.0 ( but I use edited version in my repo )

flutter_webview_plugin: git: url: https://github.com/bartukaan/flutter_webview_plugin.git ref: master

firebase_messaging: ^11.1.0

Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); .... }

WebviewScaffold( allowFileURLs: true, resizeToAvoidBottomInset: true, key: key, appBar: appBar(args), ignoreSSLErrors: true, url: args.fetchUrl!, withLocalStorage: true, withJavascript: true, debuggingEnabled: true, javascriptChannels: Set.from([ JavascriptChannel( name: 'TEST', onMessageReceived: _onJSMsgRecv, ), ]), initialChild: Container( color: Colors.white, child: Center( child: CupertinoActivityIndicator(radius: 30), ), ), ), _onJSMsgRecv doesnt listen any event on Android. When I initialize FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler) in main function,

bartukaan commented 3 years ago

any idea?