3

Is it possible to display an icon in a notification message? I use this code to show the notification, but it doesn't seem to have any property for an image:

MyNotification := NC.CreateNotification;
try
  MyNotification.Name := '';
  MyNotification.Title := 'Raspberry Pi';
  MyNotification.AlertBody := Msg;
  NC.PresentNotification(MyNotification);
finally
  MyNotification.Free;
end;

Edit: My question is not dupplicate. I need a answer for Windows, not Android, like in the sugested question.

Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55
  • There presently is no support for including images in a notification "out of the box" for Delphi. I have an example of how to achieve it for Android, [here](https://github.com/DelphiWorlds/Playground/tree/main/Demos/CustomNotification). (It uses direct API calls, rather than `TNotificationCenter`). iOS is much harder (requiring an extension, which needs to be an Xcode project), which I am yet to make it work. – Dave Nottage Mar 26 '23 at 18:28
  • @Remy the suggested "already has answers" is *not* the same thing – Dave Nottage Mar 26 '23 at 18:30
  • 1
    I don't need for Android, I need for Windows ! Please reopen my question ! – Marus Gradinaru Mar 26 '23 at 18:31
  • 1
    @MarusGradinaru you didn't say in your question which platform(s) you are targeting. Every platform has different requirements, and the duplicate I linked to explained how to accomplish it for Android, for instance. Like Dave said, TNotification does not support images, so you will have to resort to native APIs on each platform as needed. – Remy Lebeau Mar 26 '23 at 18:33
  • My comment of "presently is no support for including images in a notification "out of the box" for Delphi" still applies. On Windows, Delphi supports only 2 text-only ["template" types](https://learn.microsoft.com/en-us/uwp/api/windows.ui.notifications.toasttemplatetype?view=winrt-22621), namely ToastText01 and ToastText02. The `System.Win.Notification` unit would need to be modified to use an image-based template, but there is still the question of how to assign the image – Dave Nottage Mar 26 '23 at 18:54

0 Answers0