LilyStilson / Macapi.Notifications

Simplified macOS notification bridge for Delphi #DelphiCocoaFlavored

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Macapi.Notifications

Simplified macOS notification bridge for Delphi #DelphiCocoaFlavored

Lily Stilson // 2020


Usage

This unit is meant to be working with RAD Studio 10.4. It won't work in older versions due to bug in Macapi.Foundation. If your app was not signed with Apple Developer Certificate, then starting from macOS 10.15 this unit will work, but won't call any notifications due to limitations in OS.

ScheduleNotification

Simplified notification scheduling. Fires notification after at a sceduled time;

procedure ScheduleNotification(const ATitle, ASubtitile, AInformation: String; 
                               const ADeliveryDate: TDateTime; 
                               const UseTimeZone: boolean = True);
  • ATitle - Notification title (Application name will be used, if empty)
  • ASubtitile - Notification subtitle (Optional)
  • AInformation - Notification body (Optional)
  • ADeliveryDate - Notification delivery date
  • UseTimeZone - Use PC's current time zone to fire notification (default = true)

PresentNotification

Simplified notification presenting. Fires notification immediately.

procedure PresentNotification(const ATitle, ASubtitile, AInformation: String);
  • ATitle - Notification title (Application name will be used, if empty)
  • ASubtitile - Notification subtitle (Optional)
  • AInformation - Notification body (Optional)

Examples

// SceduleNotification // Form contains TButton.
procedure TNSNotificationsTestForm.SceduleNotificationButtonClick (Sender: TObject);
begin
  SceduleNotification('Notification Title', 'Foo Bar', 'Very Informative. Such Notification!', 
                      Now + EncodeTime(0, 0, 5, 0));
end;
// NSSavePanel // Form contains TButton and TEdit
procedure TNSNotificationsTestForm.PresentNotificationButtonClick (Sender: TObject);
begin
  PresentNotification('Notification Title', 'Foo Bar', 'Very Informative. Such Notification!');
end;

Roadmap

  • Notification click handler

About

Simplified macOS notification bridge for Delphi #DelphiCocoaFlavored

License:MIT License


Languages

Language:Pascal 100.0%