Android Delphi TNotificationCenter多个重复通知具有意外行为

Android Delphi TNotificationCenter多个重复通知具有意外行为,android,delphi,notifications,firemonkey,Android,Delphi,Notifications,Firemonkey,假设您希望创建一个具有重复间隔的通知,以使其重复出现 var MyNotification : TNotification; begin MyNotification := NotificationCenter1.CreateNotification; try MyNotification.Name := 'FirstNotification'; MyNotification.AlertBody := 'First Notification

假设您希望创建一个具有重复间隔的通知,以使其重复出现

var
    MyNotification : TNotification;
begin
    MyNotification := NotificationCenter1.CreateNotification;
    try
        MyNotification.Name := 'FirstNotification';
        MyNotification.AlertBody := 'First Notification!';
        MyNotification.FireDate := IncSecond(Now,15);// Note this fires 15 secs from NOW
        MyNotification.RepeatInterval := TRepeatInterval.Minute;
        Notificationcenter1.ScheduleNotification(MyNotification);
    finally
        MyNotification.DisposeOf;
    end;
在我的例子中,反复提醒用户响应通知,然后一旦用户在tNotificationCenter
OnReceiveLocalNotification
上响应通知,我就取消通知

NotificationCenter1.CancelNotification(ANotification.Name);
这会取消通知,并且可以正常工作(有点)

现在,上面的示例将创建一个通知,如果没有响应,每分钟将再次触发一次,直到响应为止

但现在的问题是,我是否要创建另一个我也想重复的通知:

var
    MyNotification2 : TNotification;
begin
    MyNotification2 := NotificationCenter1.CreateNotification;
    try
        MyNotification2.Name := 'SecondNotification';
        MyNotification2.AlertBody := 'Second Notification!';
        MyNotification2.FireDate := IncSecond(Now,30);// Note this fires 30 secs from NOW
        MyNotification2.RepeatInterval := TRepeatInterval.Minute;
        Notificationcenter1.ScheduleNotification(MyNotification2);
    finally
        MyNotification2.DisposeOf;
    end;
如果第二个通知的FireDate设置为晚于第一个通知,那么一切都会正常工作,正如预期的那样,但是如果我要创建第二个通知,使用类似于
IncSecond(现在,10)
的FireDate,这意味着它将在第一个预定通知发生错误之前触发

var
    MyNotification2 : TNotification;
begin
    MyNotification2 := NotificationCenter1.CreateNotification;
    try
        MyNotification2.Name := 'SecondNotification';
        MyNotification2.AlertBody := 'Second Notification!';
        MyNotification2.FireDate := IncSecond(Now,10);// Note this fires 10 secs from NOW
        MyNotification2.RepeatInterval := TRepeatInterval.Minute;
        Notificationcenter1.ScheduleNotification(MyNotification2);
    finally
        MyNotification2.DisposeOf;
    end;
第一个通知永远不会到达,第二个通知不再被
通知中心1.CancelNotification(ANotification.Name)删除
CancelNotification
现在对第二个通知无效

NotificationCenter1.CancelNotification(ANotification.Name);
更新1

我可以确认,该代码在iOS中完全正常工作(没有意外行为),因此这是一个与Android相关的问题


我曾在运行5.0.2的Xperia Z2和运行4.4.2的三星Note 2上试用过,其性能完全相同

尝试此解决方案-不确定是否相同