Machado
Machado

Reputation: 14489

Delphi Seattle cannot reference default FMX class

While trying to implement Notifications at my project, Delphi Seattle can't reference FMX.Notification properly.

This is what I get:

[DCC Fatal Error] UnitMain.pas(27): F2613 Unit 'FMX.Notification' not found.

And then it makes an automatically reference to System.Notification, however it crashes my Android app when trying to use a object from this class.

How can I correctly implement Notifications on Delphi Seattle?

Note: It must run on both iOS and Android.

Upvotes: 1

Views: 1102

Answers (1)

Machado
Machado

Reputation: 14489

According to Embarcadero's official Seattle changes:

The FMX.Notification unit has been replaced by System.Notification.

The TNotificationCenter component now supports Windows 8 and later Windows versions. This component has also undergone some minor changes:

  • It provides a Loaded property to check whether the notification center is ready to use or not.
  • The type of ApplicationIconBadgeNumber has changed from Word to Integer.
  • Its Supported method is no longer necessary and has been removed.

The TBaseNotificationCenter class has replaced the IFMXNotificationCenter interface. Classes that used to implement the IFMXNotificationCenter interface must become subclasses of TBaseNotificationCenter and implement the virtual abstract methods of their parent class.


Hereby how I figured out to display notifications now:

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;

Upvotes: 3

Related Questions