MacGapProject / MacGap1

Desktop WebKit wrapper for HTML/CSS/JS applications.
Other
3.55k stars 209 forks source link

Hide macgap.notice interface when OS X doesn't support it. #60

Closed mutru closed 11 years ago

mutru commented 11 years ago

This allows the app to use Notification Center when it's available, but fall back to Growl messages. The app could also choose to always use the Growl interface.

To test, create an index.html with something like:

<script type="text/javascript">
    if (macgap.notice) {
        macgap.notice.notify({title: 'MacGap', content: 'Using native OS X notifications'});
    } else {
        macgap.growl.notify({title: 'MacGap', content: 'Using Growl notifications'});
    }
</script>

It should behave differently on OS X Mountain Lion and older versions.

Please note that this essentially breaks API compatibility, although I believe the macgap.notice API was never part of an official release.