Skip to content

Commit

Permalink
Porting fix from 3.x - also return restricted vs denied for schedule …
Browse files Browse the repository at this point in the history
…permission
  • Loading branch information
aritchie committed Apr 23, 2024
1 parent 1b5c7ee commit 35ba93a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Shiny.Notifications/Platforms/Android/NotificationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Task<NotificationAccessState> 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);
}
Expand Down Expand Up @@ -221,8 +221,8 @@ public async Task Send(Notification notification)
var android = notification.TryToNative<AndroidNotification>();

// 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);
Expand All @@ -234,30 +234,30 @@ 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);
}
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);
}
}

Expand Down

0 comments on commit 35ba93a

Please sign in to comment.