简体   繁体   English

在带有delphi-XE6的Mac OSX上显示通知

[英]Showing Notifiction on Mac OSX with delphi-XE6

When i create a Notification for mac OSX. 当我为Mac OSX创建通知时。 I can set the (unique)name of the notication, but the Title doesn't change. 我可以设置通知的(唯一)名称,但标题不变。 It just shows the name of the application. 它仅显示应用程序的名称。

procedure TPWTrayIcon.MacNotification(pTitle, pMessage: string);
var
 Note       : TNOtification;
 NoteCenter : TNotificationCenter;
begin
  NoteCenter:=TNotificationCenter.Create(nil);
  try
    note := NoteCenter.CreateNotification(pTitle,pMessage,Now+EncodeTime(0,0,1,0));
    try
    note.AlertAction := 'Alert';
//    note.name := pTitle;
//    note.AlertBody := pMessage;
//    note.FireDate  := Now + EncodeTime(0, 0, 1, 0);
    NoteCenter.ScheduleNotification(note);
    finally
      note.DisposeOf;
    end
  finally
    NoteCenter.Free;
  end;

通知事项

As you noticed the name of the notification is the application name and there is no way to change it through the current API. 如您所见,通知的名称是应用程序名称,无法通过当前API对其进行更改。 Anyway since it gets the application name you could try as a Workaround(a sort of hack) to change the application name at runtime as needed. 无论如何,由于它获得了应用程序名称,因此您可以尝试作为一种变通办法(一种hack)在运行时根据需要更改应用程序名称。

If changing the application name in FMX is not possible it I'm afraid that there is no way at the moment to change the Title of the notification. 如果无法在FMX中更改应用程序名称,那么恐怕目前无法更改通知的标题。

However the notification Title in Mac OS X is ever the application name that have pushed it,so I think is in this way defined in the Mac OS X spec. 但是,Mac OS X中的通知标题曾经是推送它的应用程序名称,因此我认为Mac OS X规范中定义了这种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM