Plugin.LocalNotification icon indicating copy to clipboard operation
Plugin.LocalNotification copied to clipboard

How to sort notifications by id ?

Open andrei-cb opened this issue 3 years ago • 3 comments

Can't find any option to do this but looks like it is possible in Android.

https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder#setSortKey(java.lang.String)

andrei-cb avatar Feb 24 '23 10:02 andrei-cb

I did try to add builder.SetSortKey(request.NotificationId.ToString()); in NotificationServiceImpl.cs but it's still not sorting them by notification id.

andrei-cb avatar Feb 24 '23 13:02 andrei-cb

Set a sort key that orders this notification among other notifications from the same package. This can be useful if an external sort was already applied and an app would like to preserve this. Notifications will be sorted lexicographically using this value, although providing different priorities in addition to providing sort key may cause this value to be ignored.

thudugala avatar Mar 04 '23 09:03 thudugala

Hi, I am setting the same priority for all notifications, but they still don't get sorted.

Channel:

android.AddChannel(new NotificationChannelRequest
{
	Id = $"my_channel_01",
	Name = "Channel 1",
	Description = "blablabla",
	Importance = AndroidImportance.Low

});

Summary:

var notification = new NotificationRequest
{
        NotificationId = 1,
        Title = "appName",
        ReturningData = "none",
        Group = "appName",
        Android =
        {
	        IsGroupSummary = true,
	        ChannelId = "my_channel_01",
	        Ongoing = false,
	        AutoCancel = false,
	        Priority =  AndroidPriority.Low
        }
};

Notifications:

var notification = new NotificationRequest
{
        NotificationId = getNotificationId(defaultPriority),
        Title = "appName",
        Subtitle = priorityNames[defaultPriority],
        Description = notiText,
        Group = "appName",
        Android =
        {
                IconSmallName =
                {
	                ResourceName = priorityIcons[defaultPriority]
                },
                IconLargeName =
                {
	                ResourceName = priorityIcons[defaultPriority]
                },
                IsGroupSummary = false,
                Ongoing = persistentNotification,
                ChannelId = "my_channel_01",
                AutoCancel = false,
                Priority =  AndroidPriority.Low
        }
};

image

getNotificationId returns a number based on priority (high = 10000, medium = 20000, low = 30000)

andrei-cb avatar Mar 05 '23 17:03 andrei-cb