Home > Mobile >  Delphi 10.4.2 FMX How to make a head up notification?
Delphi 10.4.2 FMX How to make a head up notification?

Time:12-30

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?

CodePudding user response:

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

  • Related