Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Firebase messaging? #212

Closed
koteezy opened this issue Dec 7, 2019 · 4 comments
Closed

Not working with Firebase messaging? #212

koteezy opened this issue Dec 7, 2019 · 4 comments

Comments

@koteezy
Copy link

koteezy commented Dec 7, 2019

Environment

Flutter version: 1.9.1+hotfix.6 • channel stable
Plugin version: ^2.0.0
firebase_messaging version: ^6.0.2
Android version: 6

Description

inAppBrowser events, like onLoadStop, onLoadStart not working when we use firebase_messaging

Example

MyInAppBrowser.dart
class MyInAppBrowser extends InAppBrowser {
Service service;
Function callback;

MyInAppBrowser(this.service, this.callback) {
  final options =
      InAppBrowserClassOptions(inAppBrowserOptions: InAppBrowserOptions());

  this.open(
    url: this.service.url,
    options: options,
  );
}

@override
Future onBrowserCreated() async {
  print("\n\nBrowser Created!\n\n");
}

@override
Future onLoadStart(String url) async {
  print("\n\nStarted $url\n\n");
}

@override
Future onLoadStop(String url) async {
  print("\n\nStopped!! $url\n\n");
  this
      .webViewController
      .injectJavascriptFileFromAsset(assetFilePath: service.parserPath());

  this.webViewController.addJavaScriptHandler(
      handlerName: "tracks",
      callback: (args) {
        this.callback(args[0]);

        this.close();
      });
}

@override
void onLoadError(String url, int code, String message) {
  print("Can't load $url.. Error: $message");
}
}

Working example

Future bgMsgHdl(Map<String, dynamic> message) async {
  print("onbgMessage: $message");
}

main() {
  Service service = Service(
        name: "Google", 
        alias: 'google', 
        url: "https://google.com"
  );
 
  // messaging.configure(
  //   onMessage: (Map<String, dynamic> message) async {
  //     print("onMessage: $message");
  //   },
  //   onBackgroundMessage: bgMsgHdl,
  //   onLaunch: (Map<String, dynamic> message) async {
  //     print("onLaunch: $message");
  //   },
  //   onResume: (Map<String, dynamic> message) async {
  //     print("onResume: $message");
  //   },
  // );

  MyInAppBrowser(service, (res) {
    print("All ok!");
  });

  runApp(MyApp());
}
Working example log
D/IABFlutterPlugin( 7155): use Chrome Custom Tabs = false
D/IABFlutterPlugin( 7155): loading in InAppBrowser
D/Options ( 7155): No field toolbarTopBackgroundColor in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
D/Options ( 7155): No field toolbarTop in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
D/Options ( 7155): No field hideUrlBar in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
D/Options ( 7155): No field hidden in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
I/flutter ( 7155): null
I/flutter ( 7155): null
I/flutter ( 7155):
I/flutter ( 7155):
I/flutter ( 7155): Browser Created!
I/flutter ( 7155):
I/Choreographer( 7155): Skipped 156 frames!  The application may be doing too much work on its main thread.
I/flutter ( 7155):
I/flutter ( 7155):
I/flutter ( 7155): Stopped!! https://www.google.com/
I/flutter ( 7155):
I/flutter ( 7155):
I/flutter ( 7155):
I/flutter ( 7155): Stopped!! https://www.google.com/
I/flutter ( 7155):
I/flutter ( 7155): Js return response!
I/flutter ( 7155): {"data":[{"res":"ok"}]}
I/flutter ( 7155): Js return response!
I/flutter ( 7155): {"data":[{"res":"ok"}]}
E/InputAwareWebView( 7155): Can't create a proxy view because there's no container view. Text input may not work.

Not Working example

Future bgMsgHdl(Map<String, dynamic> message) async {
  print("onbgMessage: $message");
}

main() {
  Service service = Service(
        name: "Google", 
        alias: 'google', 
        url: "https://google.com"
  );
 
  messaging.configure(
     onMessage: (Map<String, dynamic> message) async {
       print("onMessage: $message");
     },
     onBackgroundMessage: bgMsgHdl,
     onLaunch: (Map<String, dynamic> message) async {
       print("onLaunch: $message");
     },
     onResume: (Map<String, dynamic> message) async {
       print("onResume: $message");
     },
  );

  MyInAppBrowser(service, (res) {
    print("All ok!");
  });

  runApp(MyApp());
}
Not Working example log
D/IABFlutterPlugin( 7155): use Chrome Custom Tabs = false
D/IABFlutterPlugin( 7155): loading in InAppBrowser
D/Options ( 7155): No field toolbarTopBackgroundColor in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
D/Options ( 7155): No field toolbarTop in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
D/Options ( 7155): No field hideUrlBar in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
D/Options ( 7155): No field hidden in class Lcom/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions; (declaration of 'com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions' appears in /data/app/com.example-2/base.apk)
I/flutter ( 7155): null
I/flutter ( 7155): null
I/Choreographer( 7155): Skipped 141 frames!  The application may be doing too much work on its main thread.

Also, when using firebase_messaging, call stacks appear, which I have not seen before. I understand that this does not apply to your library, but maybe it is important.

Call stack

Also, when updating through dart devtools, they start duplicate and I get messages like:
Duplicates

Error 105 received from application: Isolate must be runnable
Hot reload received invalid response: {code: 105, message: Isolate must be runnable, data: {request: {method: _reloadSources, params: {pause: true, rootLibUri: file:///data/user/0/com.example/code_cache/exampleYUENGH/example/lib/main.dart.incremental.dill, packagesUri: file:///data/user/0/com.example/code_cache/exampleYUENGH/example/.packages, isolateId: isolates/3743833729212491}}, details: Isolate must be runnable before this request is made.}}
Flutter doctor
  • Flutter version 1.9.1+hotfix.6 at /Users/uebanchik/development/flutter
  • Framework revision 68587a0916 (3 months ago), 2019-09-13 19:46:58 -0700
  • Engine revision b863200c37
  • Dart version 2.5.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
  • Android SDK at /Users/uebanchik/Library/Android/sdk
  • Android NDK location not configured (optional; useful for native profiling support)
  • Platform android-29, build-tools 29.0.2
  • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
  • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
  ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
  • Xcode at /Applications/Xcode.app/Contents/Developer
  • Xcode 11.2.1, Build version 11B500
  • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
  • Android Studio at /Applications/Android Studio.app/Contents
  • Flutter plugin version 41.1.2
  • Dart plugin version 191.8593
  • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.40.2)
  • VS Code at /Applications/Visual Studio Code.app/Contents
  • Flutter extension version 3.7.0

[✓] Connected device (1 available)
  • Nexus 5 • 0567efb40047d301 • android-arm • Android 6.0.1 (API 23)

! Doctor found issues in 1 category.
@koteezy
Copy link
Author

koteezy commented Dec 7, 2019

Alright, i remove BG handler for now, because i don't understand for which purposes he need.

@koteezy koteezy closed this as completed Dec 7, 2019
@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Dec 7, 2019

@koteezy so, is it working?

@koteezy
Copy link
Author

koteezy commented Dec 7, 2019

@koteezy so, is it working?

Yea, now everything okay, without onBackgroundMessage handler.

This was referenced Jul 6, 2020
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants