Search code examples
cocoawebkitnsusernotification

How to handle HTML5 Web Notifications with a Cocoa WebView?


I use a Cocoa WebView to display a website which sends HTML5 Web Notifications. When browsing this page using Safari, I receive User Notifications directly in the Notification Center of Mac OS X Mountain Lion.

How I can achieve the same behavior by implementing my own WebView ? I didn't see any delegate methods related to this feature.

Edit: If this can help someone:

https://github.com/jnordberg/irccloudapp/blob/master/NotificationProvider.m

Thanks to Johan Nordberg for sharing this.


Solution

  • There is no public API for web notifications in WebKit on OS X at this time. You should file an enhancement request with Apple requesting that the functionality be exposed. However, since WebKit is open source you can easily find the private interface on WebView that relates to displaying web notifications. As with all private interfaces, it's subject to change without notice and may not be used within an application in the App Store.