Nsnotify has been unreliable; many notifications never appear

I have found that the nsnoitfy statement has been unreliable, possibly more than 50% of the notifications do not appear. I have stopped using them for anything that is essential, and use an alertsheet. I wonder if others have had a similar problem and have any solutions.

Can’t confirm that. nsnotify is working well for me — according to the “Do Not Disturb” Settings of my Mac.

I have just found that if the nsnotify is followed by an alertsheet statement then the notification will never appear. It also fails if followed by a rundialog. Other alerts do not interfere with it, such as Alert or get text.

I cannot duplicate that. I tried this code:

nsnotify "Hello"
alertsheet "What's up?"

Both the notification and the alert sheet showed up as expected.

In a stand-alone database with one blank record, with this code in a Text Display object:

if info(“records”)<2
console “go”
nsnotify “Nothing to display!”
alertsheet “yo”
rtn
endif

Clicking it ten times, both the console and alertsheet appeared 10 times; the notification appears 0 times.

I repeated this with the Alertsheet statement removed; then the console statement appeared 10 times; the notification appeared twice.

I have tried this on two different computers with similar results.

After reading Kurt’s message, I went to check the Settings, to see if that is affecting this behavior. I have Notifications for PanX set to Banners, which are supposed to appear and then go away after a few seconds. Even though the Banners are not appearing on the upper right portion of the screen, I checked the Notification Center and found all of the notifications there.

I switched the Notification setting from Banners to Alerts. The difference is that Alerts remain on the screen until they are acknowledged. With this setting, 100% of the notification appeared!

I don’t see anything in the Notification Settings that would explain this difference, but this now looks like a MacOS issue.

The two reasons for using the Notifications were (1) the user did not need to acknowledge the alert and (2) the use of the notification does not implicate the run loop; so you can use a nsnotify statement in atomic code, (is that right, Jim?)

Interesting. However, I am using the Banners setting and the banners do appear in my tests, even when the nsnotify is immediately followed by an alertsheet. I don’t know the reason why I am getting different results than you do.

the use of the notification does not implicate the run loop; so you can use a nsnotify statement in atomic code, (is that right, Jim?)

Yes, that is right.

The bad behavior is still true. In a new standalone database, this code never shows the notification, only the alert.

nsnotify "Hello World"
alertsheet "hello world"

But this code always shows the notification and the alert:

nsnotify "Hello World"
wait 1  //using a wait 0 here also results in no notification 
alertsheet "hello world"

New database, procedure
.Initialize prodedure:
nsnotify “Hello world.”
alertsheet “Hello world alert”

Produces both, with the alertsheet slightly ahead of the nsnotify …

Hi Craig, I have heard others say also that both work. But they reliably fail on my computer. That’s why I concluded that nsnotify was unreliable; even if it worked 90% of the time, I wouldn’t rely on it for something important. For now, I am just going to accept this quirk.

Here’s another interesting wrinkle. If I reverse the statements, thus:

alertsheet “hello world alert”

nsnotify “Hello World”

after I ok out of the alert sheet, the nsnotify appears.

That’s the way it is supposed to happen. When an alert appears, it pauses the procedure until you respond to it. The procedure doesn’t even reach the nsnotify command until after you have responded.