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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [firebase_messaging] Why ios badge data is managed in alert ? #9533

Closed
bebe0612 opened this issue Sep 14, 2022 · 10 comments 路 Fixed by #10470
Closed

馃悰 [firebase_messaging] Why ios badge data is managed in alert ? #9533

bebe0612 opened this issue Sep 14, 2022 · 10 comments 路 Fixed by #10470
Assignees
Labels
platform: ios Issues / PRs which are specifically for iOS. plugin: messaging resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working type: question A question where further information is requested

Comments

@bebe0612
Copy link

Bug report

Describe the bug
When my spring server send FCM push message by using firebase admin client to my flutter app, firebase_messaging package handles ios payload uncorrectly. below is fcm ios payload

    aps =     {
        alert =         {
            body = "!@#!@#";
            title = Test;
        };
        badge = 3;
        "content-available" = 1;
    };

I found that this package extract badge data from apsAlertDict not from apsDict. is it right?
obviously in flutter project, badge data in remoteMessage is null because apsAlertDict have not badge.
I don't understand and i can't find any who ask this problem.

@bebe0612 bebe0612 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 14, 2022
@darshankawar darshankawar added the triage Issue is currently being triaged. label Sep 14, 2022
@darshankawar
Copy link

@bebe0612
What's the expected result are you looking for when you send that payload ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 14, 2022
@bebe0612
Copy link
Author

bebe0612 commented Sep 14, 2022

@darshankawar
you know, badge is notification count exposed on app home icon in ios. also, RemoteMessage class it represents firebase push message have badge property.

When I send fcm message with badge, We should be able to get badge count in message.notification.apple.badge in flutter side.

but this package get badge data in aps.alert.badge not aps.badge so this is problem what i claim.

is it my fault ?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 14, 2022
@darshankawar
Copy link

Check this comment and see if it helps.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 15, 2022
@bebe0612
Copy link
Author

@darshankawar
thank you for answer. but still i can't understand why the pacakge parse ios payload uncorrectly. the badge data is in aps dict not apsAlert dict. is there a reason?
I send fcm message by using java spring firebase admin.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 15, 2022
@darshankawar
Copy link

Thanks for the feedback.

I see that the badge is being extracted from apsAlertDict as:

notificationIOS[@"badge"] = apsAlertDict[@"badge"];

Looking at apsAlert documentation: https://firebase.google.com/docs/reference/admin/dotnet/class/firebase-admin/messaging/aps-alert, it doesn't seem to have badge property, unlike aps which has it:

https://firebase.google.com/docs/reference/admin/dotnet/class/firebase-admin/messaging/aps#badge

I am not exactly sure if this is expected behavior, so keeping this issue open for further insights from the team.

/cc @russellwheatley

@darshankawar darshankawar added type: question A question where further information is requested plugin: messaging platform: ios Issues / PRs which are specifically for iOS. and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Sep 15, 2022
@allen-impact
Copy link

@darshankawar @russellwheatley Is there any update on this? Seeing the same issue.

@bebe0612
Copy link
Author

bebe0612 commented Feb 7, 2023

@allen-impact

In flutter, I think, managing badge data in fcm is not a good way because it only handles each native side.

Instead, It is a good way to handle on the flutter side by using flutter_app_badger package.

If you do this, you can handle not only fcm badge data but custom badge data also.

In my case, I have to handle badge count in background, but thanks to fcm background handler function and shared_preference, I can handle that when application is terminated or background.

Maybe many developer are knowing this trick that no one raise this issue.

@allen-impact
Copy link

@bebe0612 Thanks for your reply!

Yeah, I am using that package now to update the badge count, but it's still unfortunate that fcm is not able to correctly parse the Apple payload for badge count. Seems like a bug in the framework given it always returns null when it should not.

@russellwheatley
Copy link
Member

Thanks for the report. Confirmed and PR is here.

@maharramg
Copy link

@allen-impact

In flutter, I think, managing badge data in fcm is not a good way because it only handles each native side.

Instead, It is a good way to handle on the flutter side by using flutter_app_badger package.

If you do this, you can handle not only fcm badge data but custom badge data also.

In my case, I have to handle badge count in background, but thanks to fcm background handler function and shared_preference, I can handle that when application is terminated or background.

Maybe many developer are knowing this trick that no one raise this issue.

My firebase background handler does not get triggered on IOS when app is terminated or in background, so, I can't update the badge count. Any solutions?

@darshankawar darshankawar added the resolution: fixed A fix has been merged or is pending merge from a PR. label Feb 22, 2023
@firebase firebase locked and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: ios Issues / PRs which are specifically for iOS. plugin: messaging resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working type: question A question where further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants