mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-20 12:19:31 +02:00
Cocoa: add system default Sound to notification
This commit is contained in:
parent
14d9977fc8
commit
caad04b08d
@ -63,12 +63,17 @@ const
|
||||
UNAuthorizationOptionCarPlay = 1 shl 3;
|
||||
|
||||
type
|
||||
UNNotificationSound = objcclass external (NSObject)
|
||||
class function defaultSound: UNNotificationSound; message 'defaultSound';
|
||||
end;
|
||||
|
||||
UNNotificationContent = objcclass external (NSObject)
|
||||
public
|
||||
function title: NSString; message 'title';
|
||||
function subtitle: NSString; message 'subtitle';
|
||||
function body: NSString; message 'body';
|
||||
function badge: NSNumber; message 'badge';
|
||||
function sound: UNNotificationSound; message 'sound';
|
||||
end;
|
||||
|
||||
UNMutableNotificationContent = objcclass external (UNNotificationContent)
|
||||
@ -76,7 +81,8 @@ type
|
||||
procedure setTitle( newValue: NSString ); message 'setTitle:';
|
||||
procedure setSubtitle( newValue: NSString ); message 'setSubtitle:';
|
||||
procedure setBody( newValue: NSString ); message 'setBody:';
|
||||
procedure setBadge( newValue: NSNumber); message 'setBadge:';
|
||||
procedure setBadge( newValue: NSNumber ); message 'setBadge:';
|
||||
procedure setSound( newValue: UNNotificationSound ); message 'setSound:';
|
||||
end;
|
||||
|
||||
UNNotificationTrigger = objcclass external (NSObject)
|
||||
|
@ -179,6 +179,7 @@ begin
|
||||
message:= UNMutableNotificationContent.new;
|
||||
message.setTitle( StrToNSString(ATrayIcon.BalloonTitle) );
|
||||
message.setBody( StrToNSString(ATrayIcon.BalloonHint) );
|
||||
message.setSound( UNNotificationSound.defaultSound );
|
||||
|
||||
request:= UNNotificationRequest.requestWithIdentifier_content_trigger(
|
||||
NSString.string_, message, trigger );
|
||||
@ -197,6 +198,8 @@ begin
|
||||
message:= NSUserNotification.new;
|
||||
message.setTitle( StrToNSString(ATrayIcon.BalloonTitle) );
|
||||
message.setInformativeText( StrToNSString(ATrayIcon.BalloonHint) );
|
||||
if NOT NSApplication(NSApp).isActive then
|
||||
message.setSoundName( NSUserNotificationDefaultSoundName );
|
||||
|
||||
nc:= NSUserNotificationCenter.defaultUserNotificationCenter;
|
||||
if CocoaConfig.CocoaAlwaysPresentNotification then begin
|
||||
|
Loading…
Reference in New Issue
Block a user