Skip to content

[firebase_messaging] data message arrives on the native side, but is not delivered to the Dart side #1357

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

Closed
sd-timaru opened this issue Nov 3, 2019 · 5 comments
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: messaging type: bug Something isn't working

Comments

@sd-timaru
Copy link

Using firebase_messaging: ^5.1.6 plugin in my application, I noticed that when the app is in the background, sometimes the messages do not reach "the destination", so i decided to do some "tracking".

In the file FlutterFirebaseMessagingService.java, at the method executeDartCallbackInBackgroundIsolate i added
"Log.i(TAG, "before handleBackgroundMessage")":

    ...
    Log.i(TAG, "before handleBackgroundMessage");
    args.put("message", messageData);
    backgroundChannel.invokeMethod("handleBackgroundMessage", args, result);
    ...

In the file firebase_messaging.dart , at the method setMethodCallHandler i added
"print('Received in Dart!');":

  backgroundChannel.setMethodCallHandler((MethodCall call) async {
    print('Received in Dart!');
    if (call.method == 'handleBackgroundMessage') {
    ...

To do some testing, i send 4 data messages, while the app was in background. 2 of them arrived successfully in the app, but the last 2 didn't, even they arrived to the java side:

mess

If i "bring" the app in the foreground and send to it others data messages, the arrive successfully.

What could be the problem? Why the messages are not delivered always to the Dart side, when the app is in the background?

@sd-timaru sd-timaru added the type: bug Something isn't working label Nov 3, 2019
@iapicca
Copy link

iapicca commented Nov 4, 2019

Hi @sd-timaru
Could you please provide your flutter doctor -v
and your your flutter run --verbose?
Thank you

@iapicca iapicca added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Nov 4, 2019
@sd-timaru
Copy link
Author

Yes, but i just updated the flutter and dart plugin....

doc.txt

output.txt

@iapicca iapicca removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Nov 5, 2019
@iapicca
Copy link

iapicca commented Nov 5, 2019

Thank you @sd-timaru

@goody-h
Copy link

goody-h commented Nov 14, 2019

I also experience this on my app.

A simple flutter logs on the connected device would show the creation of an observatory listener when a data message is received
I/flutter (24260): Observatory listening on http://127.0.0.1:46040/aO_xk0_pDeQ=/

But then the Dart background Message handler does not always execute

@Salakar
Copy link
Member

Salakar commented Nov 5, 2020

Hey all 👋

As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues.

If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.

Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.

Thanks everyone.

@Salakar Salakar closed this as completed Nov 5, 2020
@firebase firebase locked and limited conversation to collaborators Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: customer A bug with low impact (e.g. affecting only a few customers or has a workaround). (P3) plugin: messaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants