This solution is better than the osascript one since the notification will have the app icon and will be listed under the app name in the notification center.
With osascript the sender application will be Applescript (so will have AppleScript Icon and will be listed under AppleScript)
[quote=127390:@Antonio Rinaldi]This solution is better than the osascript one since the notification will have the app icon and will be listed under the app name in the notification center.
With osascript the sender application will be Applescript (so will have AppleScript Icon and will be listed under AppleScript)[/quote]
I mentioned the osascript one liner as sort of a reference to the caterpillar machine of my previous post.
You are right, the method way is better. And it can be enriched the same way with the Apple reference.
I’m testing usernotification. I’m on MacOsx 10.9.5 and Xojo 2015R2. Both shao sean cocoa declares and MBS plugin
doesn’t work. I Have no errors but no notification pops up.
Any idea ?
Thanks
My declares are probably a result of hacking other people’s declares, so best to work with MBS plugins or macoslib… If neither of those projects are working for you, then I would suspect there is something with your system (do you allow your app to show notifications? are you “do not disturb” mode?)
Stupid question: Have you checked the notifications setting for your app in system preferences? Could be it is set to “none”.
And is your app in foreground? If so, you have to return “true” on the shouldPresentNotification Event of the UserNotificationCenterDelegate. If you don’t, notifications do only show up when the app is in background.
Using the apple script call by shell I have no issues.
Other application are show regularly notification.
Asking to what Christian pointing, where do I have to check ‘prefs’ ?
Maybe shao sean could you post a complete sample on how to use your module for OS notification ?
Do I have necessarily use the event delegate ?
Thanks in advance.
C
Makte sure the notification settings are set to banner and then program a delayed notification, in case your implementation doesn’t allow you to via a timer. Then send the app to the background and wait for the timer to trigger. I guess the notification will show up now. Like said, without using the delegate notifications only work for background apps. If it’s in the foreground, Apple thinks you have better means to signalize the situation.
Maybe this old project helps you to I haven’t checked if it still runs and I will not continue the single module OS X additions; after all, many classes need a lot of other OS X classes so I think a full library is a better way: https://dl.dropboxusercontent.com/u/21200221/Xojo/MacOSUserNotification%20Demo.xojo_xml_project.zip
Look for the “present always” button at the bottom. When it’s set, the delegate returns true.
Carlo, have you checked if the notification is in the notification list? If your app is front most without a delegate the notification will be delivered (and you can see in the notification list) but you will not see the notification.
Thanks to all for suggestion. I have found where I was wrong. To test I used only local variables, instanciated into a button action event. I see that I have to use global properties like:
m = new NSUserNotificationCenterMBS
d = new MyNSUserNotificationCenterDelegateMBS
This appens for MBS implementation
Instead, about shao sean cocoa module, I have not working code:
// don’t work
DIM notification As NEW Dictionary
notification.Value(“title”) = “Hello”
notification.Value(“subtile”) = “World”
notification.Value(“informativeText”) = “mmm… notifications” //notification.Value(“icon”) = aXojoPicture // don’t use this in apps for MAS though
[quote=191518:@Axel Schneider]I just had the idea for a ‘FakeNotification’
should also work in Windows[/quote]
I use a similar technique in my latest Windows app. Nice job.
Windows notifications appear at the bottom of the screen, right along the top of the taskbar, so notif.top should be Screen(0).availableHeight-notif.Height. The size of Notif is just fine. The text label should be multiline and left justified. Also, Timer should be faster. The animation for notification show is too slow. I guess a period of 3-5 should be fine.
The only drawback of using fake notifications under Windows is that in Windows 10, there is now a bar (think slide in pane) which can be displayed where the Charm bar was, where all notifications are logged. Of course the Xojo made notifications will not appear there. But it is probably not big deal.