OSX Dock Badges (Object Pascal)
From Appmethod Code Examples
Description
This example shows you how to implement notification badges for your OS X applications.
Code
unit UnMain; interface uses //These frameworks define types that map to the Mac OS X Objective-C based 'Cocoa' API. Macapi.AppKit, //You need it to create an '''NSApplication''' instance. Macapi.Helpers, //You need it to use the function StrToNSStr(). System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls; type TFrmBadgeLabel = class(TForm) BadgeLabel: TButton; procedure BadgeLabelClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var FrmBadgeLabel: TFrmBadgeLabel; implementation {$R *.fmx} procedure TFrmBadgeLabel.BadgeLabelClick(Sender: TObject); var // Create an instance of NSApplication NSApp: NSApplication; begin NSApp := TNSApplication.Wrap(TNSApplication.OCClass.sharedApplication); NSApp.dockTile.setBadgeLabel(StrToNSStr('23')); end; end.
You will see the badge on the icon's app after clicking the button.