Hi,
I am not sure what i am looking for. Could someone point me towards the documentation on how to code notifications to show in the notification menu on the right hand side of the latest OSX (e.g. Mountain lion / Mavericks).
Cheers
Hi,
I am not sure what i am looking for. Could someone point me towards the documentation on how to code notifications to show in the notification menu on the right hand side of the latest OSX (e.g. Mountain lion / Mavericks).
Cheers
you can read blog entry here:
http://www.mbsplugins.de/archive/2012-07-28/Mac_OS_X_108_User_Notification
and check our plugins docs here:
https://www.monkeybreadsoftware.net/class-nsusernotificationmbs.shtml
We have it all ready including push notifications and example projects as part of MBS Plugins.
It’s also one of the things I demonstrated in my “Using MacOSLib” webinar.
In Mavericks you can use
dim myshell as new shell
myshell.Execute ("osascript -e 'display notification ""Message"" with title ""This is a Title"" subtitle ""This is a Subtitle"" sound name ""Frog""'")
[quote=126656:@Axel Schneider]In Mavericks you can use
dim myshell as new shell
myshell.Execute ("osascript -e 'display notification ""Message"" with title ""This is a Title"" subtitle ""This is a Subtitle"" sound name ""Frog""'")
[/quote]
What is the appstore-ability on this? I hear there’s lots of trouble with app store and shell scripts.
You can grab my Cocoa module from GitHub… It does very little compared to macoslib (these guys are awesome), but it is a single self-contained module with no external classes and you just do simple calls to it (mostly) using built-in Xojo classes… For example, to deliver a notification, create a dictionary and then pass the dictionary to the method…
[code] 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
Cocoa.DeliverNotification notification[/code]
Hi All,
Thanks for the responses to this. I will give it ago tonight
Shell scripts in the MAS are fine. The same rules apply than for the sandboxed app itself. You cannot access a folder if the user has not given his permission, and calling some processes like ps is not permitted. But most commands work. As far as I know, using shell per se is no reason for rejection. I have been using shell in almost all my applications and never had any issues with Apple.
As far as osascript/AppleScript call goes, telling System events is off limit from AppleScript in the MAS. If you script another application, you have to get approval from the reviewer. Apart from that, all commands intrinsic to AppleScript are just as fine as a regular shell.
Shao Sean solutions seems somewhat better, though, for displaying notifications.
Mine is just a simple solution for my own needs, either MBS or macoslib would better for more complex needs…
I was comparing to the AppleScript method …
MBS is powerful and easy, but one has to buy. I did and would recommend, but there is sort of a religious war going on. MacOSLib is powerful, but finding out how to do something simple can be daunting.
Sometimes using a caterpillar machine is a bit much to plant one flower
Often, simplicity is the best form of art.
Well, if you buy MBS, you have me to ask and get help.
[quote=126886:@Michel Bujardet]I was comparing to the AppleScript method …
MBS is powerful and easy, but one has to buy. I did and would recommend, but there is sort of a religious war going on. MacOSLib is powerful, but finding out how to do something simple can be daunting. [/quote]
I can see why it might be daunting to those starting out, but it comes with extensive examples. The likelihood is that there’s an example of what you’re trying to do and it’s a simple job of copying or pulling the code apart. Kem’s webinar, mentioned above, is a useful intro for anyone wanting to get started.
I know I will stir things, but neither MacOSLib not MBS are very convenient for simple tasks.
Case in point : I look in the MacOSLib Examples folder. I locate a file called “NSUserNotificationExample.rbfrm”. Looks like it is what I want. I drag that file over Xojo. Nothing in the IDE but an icon, and when run, nothing happens.
I am sure this is all perfectly simple and I should be intelligent enough to go into the hollow tree grab the token to give the witch so she tells me how to proceed. But for the moment, I do not feel like spending yet another half an hour dealing with a half baked documentation, or watching an hour of webinar.
MacOSLib is no doubt a great achievement, but the absence of documentation is dismal.
Now, let us say I want to do the same with MBS. I go to the Examples folder, and things are organized by plugins, not by what they do. No way to find a function if I do not know in which plugin it is. So because I already bugged Christian about finding what is in the examples, I go to https://www.monkeybreadsoftware.net/examples.shtml . Incidentally, Christian, it would be a terrific idea to add a shortcut to that page in your Example folders.
Now, on the wonderful page in question, I want to find NSUserNotification, so I have to click “by name”, then use the browser search. Beep. No luck. Never mind, to brave heart nothing impossible. Search for “notification” leads to 23 results. Finally, No 19 ‘UserNotification example’ looks very much like what I need. Or so it may be. I will have to spend half an hour trying out to see if it is what I looked for.
To be honest, if I do not find that way, Christian will help me by email as fast as he can. But I wanted to show how difficult it is to locate an example in MBS plugins. To his merit, Christian’s examples work right away, unlike MacOSLib strange files.
Now this is all to comfort my previous post : why go into this paraphernalia when the solution is just an AppleScript away, or just here ready to use thanks to Shao Sean ? I think he should add that to Xippets, by the way.
No need to be a zen master to appreciate the beauty of sobriety.
[quote=126950:@Michel Bujardet]I know I will stir things, but neither MacOSLib not MBS are very convenient for simple tasks.
Case in point : I look in the MacOSLib Examples folder. I locate a file called “NSUserNotificationExample.rbfrm”. Looks like it is what I want. I drag that file over Xojo. Nothing in the IDE but an icon, and when run, nothing happens.[/quote]
Simply open the macoslib-master folder, then open macoslib.rbvcp. Run the project and you can view some introductory documentation. Next, click the Examples menu and see what it can do for you. Hope that helps.
Here are some screenshots:
[quote=126955:@Gavin Smith]Simply open the macoslib-master folder, then open macoslib.rbvcp. Run the project and you can view some introductory documentation. Next, click the Examples menu and see what it can do for you. Hope that helps.
[/quote]
I appreciate your answer. Still, the examples appear by sections, which is about the same, if less complex, than MBS examples by plugin.
And if all I want is to display a bitty notification, I will have to dump into my project 500 MB of MacOSLib folder which contain even the proverbial kitchen sink, together with every method under the sun.
It is not exactly simple.
[quote=126826:@shao sean]
[code] 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
Cocoa.DeliverNotification notification[/code][/quote]
it does not work for me,
I wrote a fault description on github
[quote=126974:@Axel Schneider]it does not work for me,
I wrote a fault description on github[/quote]
Sorry about that, I made some changes but looks like I forgot to sync the changes (this GitHub stuff is all new to me, so please bear with me as I learn)…
k… Just synced the changes, downloaded the files from GitHub and gave it a whirl and everything seems to be okay now… Sorry about that…
Hey Jay
I posted an example of how to do it with Applescript some time ago on the forums.
But I can’t remeber where, so I’ve put a link to the Xojo project and Applescripts used below.
Regards Mark