【问题标题】:Delphi Seattle cannot reference default FMX classDelphi Seattle 无法引用默认 FMX 类
【发布时间】:2015-10-14 14:48:55
【问题描述】:
在我的项目中尝试实现 Notifications 时,Delphi Seattle 无法正确引用 FMX.Notification。
这是我得到的:
[DCC 致命错误] UnitMain.pas(27): F2613 Unit 'FMX.Notification' not found.
然后它会自动引用System.Notification,但是当我尝试使用此类中的对象时它会导致我的 Android 应用程序崩溃。
如何在 Delphi Seattle 上正确实施通知?
注意:它必须同时在 iOS 和 Android 上运行。
【问题讨论】:
标签:
android
ios
delphi
delphi-10-seattle
【解决方案1】:
根据Embarcadero's official Seattle changes:
FMX.Notification 单元已替换为System.Notification。
TNotificationCenter 组件现在支持 Windows 8 和更高版本的 Windows。这个组件也发生了一些小的变化:
- 它提供了一个 Loaded 属性来检查通知中心是否可以使用。
-
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;