Search code examples
delphifiremonkeydelphi-10.4-sydney

Delphi 10.4.2 FMX How to make a head up notification?


When creating notification using TNotificationCenter and TNotification, it only appear in the notification drawer, it won't have pop up mini floating box like WhatsApp msg notification for examples. Is there any properties that will enable that?


Solution

  • You need to create a channel with an importance of High, and have the notifications sent using the id for that channel (via the ChannelId property of the notification). Example code for setting up the channel:

    procedure TForm1.SetupNotificationChannel;
    var
      LChannel: TChannel;
    begin
      LChannel := NotificationCenter.CreateChannel;
      try
        LChannel.Id := 'MyChannel';
        LChannel.Title := LChannel.Id;
        LChannel.Importance := TImportance.High;
        NotificationCenter.CreateOrUpdateChannel(LChannel);
      finally
        LChannel.Free;
      end;
    end;
    

    NotificationCenter is a TNotificationCenter component