Gestito notificationData nelle notifiche push

This commit is contained in:
2025-09-12 17:37:36 +02:00
parent 223e74c490
commit 0f3047a2b6
10 changed files with 59 additions and 23 deletions

View File

@@ -1,8 +1,11 @@
using CommunityToolkit.Mvvm.Messaging;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface.IntegryApi;
using salesbook.Shared.Core.Messages.Notification.NewPush;
using Shiny.Push;
using System.Text.Json;
namespace salesbook.Maui.Core.System.Notification.Push;
@@ -20,10 +23,25 @@ public class PushNotificationDelegate(
public Task OnReceived(PushNotification notification)
{
if (notification.Notification is null) return Task.CompletedTask;
var data = notification.Data;
NotificationDataDTO? notificationDataDto = null;
if (!data.IsNullOrEmpty())
{
var json = JsonSerializer.Serialize(data);
notificationDataDto = JsonSerializer.Deserialize<NotificationDataDTO>(json);
}
if (notificationDataDto?.NotificationId == null) return Task.CompletedTask;
var notificationId = long.Parse(notificationDataDto.NotificationId);
var pushNotification = new WtbNotification
{
Id = notificationId,
Title = notification.Notification.Title,
Body = notification.Notification.Message
Body = notification.Notification.Message,
NotificationData = notificationDataDto
};
messenger.Send(new NewPushNotificationMessage(pushNotification));