Hi everyone - in my app I have put the n(what I think) is the latest macoslib folder.
In “Module1” I have the class named “MyNotificationCenter”.
I have a Method named “NSNotifications”, which contains the following code:
// ---------------------------------------- DEFINE VARIABLES
Dim TitleText as string = inTitle
Dim SubTitleText as string
Dim InformativeText as string = inMSG
Dim SoundNameText as string = "Morse"
// ---------------------------------------- DISPLAY NSUserNotification
dim n as New NSUserNotification
if TitleText <> "" then n.Title = TitleText
if SubTitleText <> "" then n.Subtitle = SubTitleText
if InformativeText <> "" then n.InformativeText = InformativeText
if SoundNameText <> "" then n.SoundName = SoundNameText
return n
I also have a Property named “m” (type=MyNotificationCenter)- which as far as I know should all be correct.
In a button’s action event, I have the following code:
// DISPLAY THE USER NOTIFICATION
m = New Module1.MyNotificationCenter
m.DeliverNotification(Module1.NSNotifications("Snippets:","Successfully backed up the database files."))
However - no notification shows up, even though it is enabled in the System Preferences > notifications area.
Im pretty sure this worked in Catalina - can anyone shed some light, or test this?
… and if you should figure out how to present a notification set to banner in the user’s notification preferences when the apps in foreground, let me know. There is a willPresentNotification event where you can override the type of notification but I have only been successful in making the sound play or show the notification if the style is set to persistent.
Apple deprecated NotificationStyleAlert as a possible reply value so it looks like you cannot override the visibility of a notification for a foreground app anymore in Big sur.
I hate to break it to you, but Apple’s updated HIG now states:
Handle notifications gracefully if your app is in the foreground. Your app’s notifications don’t appear onscreen when your app is in the front, but your app still receives the information. Present it to the user in a way that’s informative but not distracting or invasive. For example, you might display or increment a badge or subtly insert new data into the current view.
Thanks, Greg. Makes one wonder what the Banner flag is good for if it does not change anything, and explains why my best result, not matter what I returned, was to make the notification sound play.