NotificationActionTapped Only Returns ReturningData From Last-Added Notification

Open
#365 7 comments 0 reactions 1 assignee View on GitHub

@thudugala is already working on this.

Since May 19, 2023.

Assessment

This issue has not been assessed yet.

Description

Android

I'm using V. 10.1.3 in a .Net Maui application.I add two notifications all at once with each having a different kind of ReturningData,but no matter which notification I tap in the Notification center,just the ReturningData of the last-added notification is returned.I think it's a bug,which needs to be fixed.
The same issue as in: #312 ,but the problem still persists even though it's been closed!
Also take a look at the following Discussion:

I will try to be clear as possible.

I am testing the plugin and everything is really clear and simple to this point. But I have a problem with the NotificationActionTapped event.

In my testing app I created two NotificationRequest with different NotificationId, Title, description, etc. I show the two notifications. The two notifications are send and I can tapped them. Their is notification 1 who is show first and notification 2 who is show second.

When I tapped notification 1 or 2, its always the data of the last show notification that its received. I cannot acces the data of the first show notification.

Code exemple to help understand what I am trying to explain

I create the two notification

            var notification1 = new NotificationRequest
            {
                BadgeNumber = 1,
                Title = "Title 1",
                Description = "Description 1",
                ReturningData = "Data 1",
                NotificationId = 1,
                Schedule =
                {
                    NotifyTime = DateTime.Now.AddSeconds(5)
                },
            };

            var notification2 = new NotificationRequest
            {
                Android =
                {
                    Priority = AndroidPriority.High,
                },

                BadgeNumber = 1,
                Title = "Title 2",
                Description = "Description 2",
                ReturningData = "Data 2",
                NotificationId = 2,
                Schedule =
                {
                    NotifyTime = DateTime.Now.AddSeconds(5)
                },
            };

            LocalNotificationCenter.Current.Show(notification1);
            LocalNotificationCenter.Current.Show(notification2);

A little Display to show the received data after the tapped notification

        LocalNotificationCenter.Current.NotificationActionTapped += Current_NotificationActionTapped;

        private void Current_NotificationActionTapped(Plugin.LocalNotification.EventArgs.NotificationActionEventArgs e)
        {
            LocalNotificationCenter.Current.GetDeliveredNotificationList();

            App.Current.MainPage.DisplayAlert(e.Request.Title, e.Request.Description, "ok");
        }

The display is alway the data from the second notification

image

Is it by design or there is something I'm doing wrong?

Thank you!

Originally posted by @AlexForget in https://github.com/thudugala/Plugin.LocalNotification/discussions/359

Dominant language
C#
Stars
474
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thudugala/Plugin.LocalNotification

All issues in thudugala/Plugin.LocalNotification

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.