generated from Integry/Template_NetMauiBlazorHybrid
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using CommunityToolkit.Mvvm.Messaging;
|
|
using salesbook.Shared.Core.Dto.Notification;
|
|
using salesbook.Shared.Core.Interface.IntegryApi;
|
|
using salesbook.Shared.Core.Messages.Notification;
|
|
using Shiny.Push;
|
|
|
|
namespace salesbook.Maui.Core.System.Notification.Push;
|
|
|
|
public class PushNotificationDelegate(
|
|
IIntegryNotificationRestClient integryNotificationRestClient,
|
|
IMessenger messenger
|
|
) : IPushDelegate
|
|
{
|
|
public Task OnEntry(PushNotification notification)
|
|
{
|
|
// fires when the user taps on a push notification
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task OnReceived(PushNotification notification)
|
|
{
|
|
if (notification.Notification is null) return Task.CompletedTask;
|
|
var pushNotification = new PushNotificationDTO
|
|
{
|
|
Title = notification.Notification.Title,
|
|
Message = notification.Notification.Message
|
|
};
|
|
|
|
messenger.Send(new NewPushNotificationMessage(pushNotification));
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task OnNewToken(string token)
|
|
{
|
|
integryNotificationRestClient.Register(token);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task OnUnRegistered(string token)
|
|
{
|
|
// fires when a push notification change is set by the operating system or provider
|
|
return Task.CompletedTask;
|
|
}
|
|
} |