Display notification including a URL

dpertschi
Valued Contributor

Can anyone give advice on how to display a dialog/notification to users which includes a clickable URL?

displayMessage and jamfHelper are not working out for me, unless I'm not using the right syntax or formatting. AppleScript?

thanks,
Darrin

1 ACCEPTED SOLUTION

acidprime
New Contributor III

So I created something like this, and just posted and open source version of it

You can find a compiled example below

external image link

https://github.com/acidprime/ClickDialog/downloads

It could be integrated into scripts like so

#!/bin/bash

declare -x ClickDialog="/Applications/ClickDialog.app/Contents/MacOS/ClickDialog"
if "$ClickDialog" ; then
        echo "User clicked OK"
else
        echo "User clicked cancel"
fi

Xcode Project (very basic 10 mins don't judge) below
https://github.com/acidprime/ClickDialog

Technical Details

Basically I just load a web.html file from the bundle ,matched the colors so it looks like a native element and then added a delegate method to catch the url click and redirect it to the default workspace. I added an "activate" and told it that it was a UI element so it will not show the dock icon, much like a display dialog in AppleScript

You can play with the Xcode project ( with no code changes ) if you want to make the window bigger ( in fact you can probably just edit the raw .xib file in interface builder

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor III

I'm not sure there's a way to do this outside of writing a custom app. I've tried, tried and tried again to get some way for clickable URLs inside dialogs and came up empty.
In my searching, I did find some kludgy methods posted on the interwebs, such as using Applescripts with buttons that when clicked on open a URL, or even showing a list inside an Applescript and allowing the user to choose one, which then opens it.
Neither method is very good, but I'm not sure how else it can be done. But I'd love to know too!

acidprime
New Contributor III

So I created something like this, and just posted and open source version of it

You can find a compiled example below

external image link

https://github.com/acidprime/ClickDialog/downloads

It could be integrated into scripts like so

#!/bin/bash

declare -x ClickDialog="/Applications/ClickDialog.app/Contents/MacOS/ClickDialog"
if "$ClickDialog" ; then
        echo "User clicked OK"
else
        echo "User clicked cancel"
fi

Xcode Project (very basic 10 mins don't judge) below
https://github.com/acidprime/ClickDialog

Technical Details

Basically I just load a web.html file from the bundle ,matched the colors so it looks like a native element and then added a delegate method to catch the url click and redirect it to the default workspace. I added an "activate" and told it that it was a UI element so it will not show the dock icon, much like a display dialog in AppleScript

You can play with the Xcode project ( with no code changes ) if you want to make the window bigger ( in fact you can probably just edit the raw .xib file in interface builder