Implementate notifiche
This commit is contained in:
@@ -1,16 +1,37 @@
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
using Shiny;
|
||||
using Shiny.Notifications;
|
||||
using Shiny.Push;
|
||||
|
||||
namespace salesbook.Maui.Core.System.Notification;
|
||||
|
||||
public class FirebaseNotificationService(IPushManager pushManager, IIntegryNotificationRestClient integryNotificationRestClient) : IFirebaseNotificationService
|
||||
public class FirebaseNotificationService(
|
||||
IPushManager pushManager,
|
||||
IIntegryNotificationRestClient integryNotificationRestClient,
|
||||
INotificationManager notificationManager
|
||||
) : IFirebaseNotificationService
|
||||
{
|
||||
public async Task InitFirebase()
|
||||
{
|
||||
var (accessState, token) = await pushManager.RequestAccess();
|
||||
CreateNotificationChannel();
|
||||
|
||||
var (accessState, token) = await pushManager.RequestAccess();
|
||||
|
||||
if (accessState == AccessState.Denied || token is null) return;
|
||||
await integryNotificationRestClient.Register(token);
|
||||
}
|
||||
|
||||
private void CreateNotificationChannel()
|
||||
{
|
||||
var channel = new Channel
|
||||
{
|
||||
Identifier = "salesbook_push",
|
||||
Description = "Notifiche push di SalesBook",
|
||||
Importance = ChannelImportance.High,
|
||||
Actions = []
|
||||
};
|
||||
|
||||
notificationManager.AddChannel(channel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user