From 35ba93ae3df74ffb035263312f05d0b1aef77d56 Mon Sep 17 00:00:00 2001 From: Allan Ritchie Date: Mon, 22 Apr 2024 21:13:47 -0400 Subject: [PATCH] Porting fix from 3.x - also return restricted vs denied for schedule permission --- .../Platforms/Android/NotificationManager.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Shiny.Notifications/Platforms/Android/NotificationManager.cs b/src/Shiny.Notifications/Platforms/Android/NotificationManager.cs index 6700b733a..837ffec7a 100644 --- a/src/Shiny.Notifications/Platforms/Android/NotificationManager.cs +++ b/src/Shiny.Notifications/Platforms/Android/NotificationManager.cs @@ -139,7 +139,7 @@ public Task GetCurrentAccess() var status = new NotificationAccessState( notificationStatus, this.geofenceManager.CurrentStatus, - alarm!.CanScheduleExactAlarms() ? AccessState.Available : AccessState.Denied + alarm!.CanScheduleExactAlarms() ? AccessState.Available : AccessState.Restricted ); return Task.FromResult(status); } @@ -221,8 +221,8 @@ public async Task Send(Notification notification) var android = notification.TryToNative(); // TODO: should I cancel an existing id if the user is setting it? - if (notification.Id == 0) - notification.Id = this.settings.IncrementValue("NotificationId"); + if (android.Id == 0) + android.Id = this.settings.IncrementValue("NotificationId"); var channelId = notification.Channel ?? Channel.Default.Identifier; var channel = this.channelManager.Get(channelId); @@ -234,18 +234,18 @@ public async Task Send(Notification notification) if (notification.Geofence != null) { await this.geofenceManager.StartMonitoring(new GeofenceRegion( - AndroidNotificationProcessor.GetGeofenceId(notification), - notification.Geofence!.Center!, - notification.Geofence!.Radius! + AndroidNotificationProcessor.GetGeofenceId(android), + android.Geofence!.Center!, + android.Geofence!.Radius! )); } else if (notification.RepeatInterval != null) { // calc first date if repeating interval - notification.ScheduleDate = notification.RepeatInterval!.CalculateNextAlarm(); + android.ScheduleDate = android.RepeatInterval!.CalculateNextAlarm(); } - if (notification.ScheduleDate == null && notification.Geofence == null) + if (android.ScheduleDate == null && notification.Geofence == null) { var native = builder.Build(); this.manager.NativeManager.Notify(notification.Id, native); @@ -253,11 +253,11 @@ await this.geofenceManager.StartMonitoring(new GeofenceRegion( else { // ensure a channel is set - notification.Channel = channel!.Identifier; - this.repository.Set(notification); + android.Channel = android!.Identifier; + this.repository.Set(android); if (notification.ScheduleDate != null) - this.manager.SetAlarm(notification); + this.manager.SetAlarm(android); } }