I use Delphi 10.2 in Windows 10. The following code is the sample code provided by Embarcadero.
After running this code the notification disappears and deosn't stay in Action Center. How can I let it pended there?
procedure TNotify.btnShowClick(Sender: TObject);
var
MyNotification: TNotification;
begin
MyNotification := NotificationCenter1.CreateNotification;
try
MyNotification.Name := 'Windows10Notification';
MyNotification.Title := 'Windows 10 Notification #1';
MyNotification.AlertBody := 'RAD Studio 10 Seattle';
NotificationCenter1.PresentNotification(MyNotification);
finally
MyNotification.Free;
end;
end;
ADDED: After turning on the toggle of Windows Setting > System > Notifications & actions I can see HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Embarcadero.DesktopToasts.0579D43A\ShowInActionCenter is 1. But each user who would use this application can't do this all the time manually and I cannot predict the name of the key either.
-Settings > system > notifications > turn on notifications and in the list below, select the apps you want to receive notifications. Now click on Focus Assist > check Disabled.
Go to Settings > System > Notifications & actions , under Get notifications from these senders select the app, and then under Priority of notifications in action center select Top.
You will find the answer here: powershell script creates Windows 10 notification and it disappears after popup
You must register your application for "Show notifications in action center" "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$prodName" -Name "ShowInActionCenter" -Type Dword -Value "1"
To get the $prodName use:
function TNotificationsForm.getRegisterToastMessageKey : String;
const
AppId = 'Embarcadero.DesktopToasts.';
begin
result := AppId + THashBobJenkins.GetHashString(ParamStr(0));
end;
Embarcadero hasn't done a good Job here but so you get the Key, or make a copy from unit System.Win.Notification and change it to your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With