Tuesday, 25 July 2017

Windows 10 Notification

Here is a quick and simple example of a notification procedure. On a form I added a 'TNotificationCenter' component from the 'System' tool palette.

procedure TForm.DoNotification(aName, aTitle, aBody: string);
    appNotification: TNotification;
    appNotification := NotificationCenter1.CreateNotification;
        appNotification.Name := aName;
        appNotification.Title := aTitle;
        appNotification.AlertBody := aBody;

procedure TForm.ShowTestNotification;
    DoNotification('Test Name', 'Test Title', 'This is an example');

There is an event in the NotificationCenter component called 'OnReceiveLocalNotification', which is useful if you want to display a notification and when a user clicks on the notification the software performs an operation. 

I did this example in Delphi 10.1 Berlin, it is a very limited example due to Delphi being very limited with what can be done with Windows Notifications. Looking at the documentation you can do more with iOS, I am not sure why they have made it so limited. I have briefly looked at some C# examples and you can do more with notifications like custom sounds, icons, images and actions. 

One thing I have noticed is that when I run this example the notification is shown and then when it goes away it is automatically removed from the action centre. One thing I would require is that if the user does not acknowledge the notification, it should stay in the Action Centre list. For me it would be really useful to have the following:
  • Custom image.
  • Custom sound.
  • FireDate to work in Windows 10.
  • Option for the notification to stay in the Action Centre.

I would like to see Embarcadero expand on what these notifications can do, obviously they are limited to what the OS can do. If they could persist in the Action Centre until clicked then I can think of multiple uses for notifications.  

No comments:

Post a Comment