在我的项目中尝试实现Notifications时,Delphi Seattle无法正确引用FMX.Notification
。
这就是我得到的:
[DCC致命错误] UnitMain.pas(27):未找到F2613单位'FMX.Notification'。
然后它会自动引用System.Notification
,但在尝试使用此类中的对象时会崩溃我的Android应用。
如何在Delphi Seattle上正确实现通知?
注意:它必须同时在iOS
和Android
上运行。
答案 0 :(得分:3)
根据Embarcadero's official Seattle changes:
FMX.Notification单位已被System.Notification
替换。
TNotificationCenter
组件现在支持Windows 8及更高版本的Windows版本。该组件也经历了一些小的改动:
ApplicationIconBadgeNumber
的类型已从Word更改为Integer。Supported
方法,并且已将其移除。 TBaseNotificationCenter
类已替换IFMXNotificationCenter
接口。用于实现IFMXNotificationCenter
接口的类必须成为TBaseNotificationCenter
的子类,并实现其父类的虚拟抽象方法。
因此我现在想出如何显示通知:
procedure TForm_Master.showNotification(Sender: TObject);
var
MyNotification: TNotification;
begin
MyNotification := NotificationCenter1.CreateNotification;
try
MyNotification.Name := 'NotificationName';
MyNotification.AlertBody :=
'Here goes your message';
MyNotification.FireDate := Now;
// Send notification to the notification center
NotificationCenter1.ScheduleNotification(MyNotification);
finally
MyNotification.Free;
end;
end;