Delphi Seattle Android TNotificationCenter CancelAll not working after one notification has fired

  

I’m using Delphi DX Seattle and testing on an android Device
when a user clicks a button i’m creating multiple scheduled notifications
and when a user clicks another button im clearing the remaining notifications

I cant seem to get the TNotificationCenter.CancelAll to actually cancel notifications after one notification has fired Similar Question Here

Using the Delphi sample SendCancelNotification as the base code
I’m Changing the “Send Notification Immediately” button to “Send Multiple Notifications” and the code looks like this

procedure TNotificationsForm.btnSendMultipleNotificationsClick(
Sender: TObject);

procedure MyNotificationCreate(aNotificationName : String; aSecondDelay : Word);
var
Notification: TNotification;
begin
if (aSecondDelay < 0) or (aSecondDelay > 60) then
raise Exception.Create(‘Seconds must be between 0 and 60’);
{ verify if the service is actually supported }
Notification := NotificationC.CreateNotification;
try
Notification.Name := aNotificationName;
Notification.AlertBody := aNotificationName + ‘ ran after ‘ + inttostr(aSecondDelay) + ‘ seconds’;

{ Fired in 10 second }
Notification.FireDate := Now + EncodeTime(0,0,aSecondDelay,0);

{ Send notification in Notification Center }
NotificationC.ScheduleNotification(Notification);
finally
Notification.DisposeOf;
end;
end;
begin
MyNotificationCreate(‘First’ , 5);
MyNotificationCreate(‘Second’, 10);
MyNotificationCreate(‘Third’ , 15);
end;

This sends three notifications after the button has been clicked.
if i click the “Send Multiple Notifications” button and then before 5 seconds click the “cancel all notifications” button the notifications are canceled successfully.

procedure TNotificationsForm.SpeedButton2Click(Sender: TObject);
begin
NotificationC.CancelAll;
end;

But if i click the multi notification button and wait until the first notification has fired then click the “cancel all notifications” button, it doesn’t cancel the remaining notifications. e.g. notifications Second and Third still run.

Has anyone come across this? or have any ideas on why the CancelAll event doesn’t work after one of the notifications have been sent

Comments are closed.