https://github.com/inndy/notice.js
A simple interface to webkitNotification
https://github.com/inndy/notice.js
Last synced: 11 months ago
JSON representation
A simple interface to webkitNotification
- Host: GitHub
- URL: https://github.com/inndy/notice.js
- Owner: Inndy
- Created: 2014-01-16T02:36:16.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-21T07:40:45.000Z (almost 12 years ago)
- Last Synced: 2025-02-23T10:46:16.974Z (11 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
notice.js
=========
A simple interface to `webkitNotification`
***It only works with Safari and Chromium-based browser***
* Specifications from Chromium
--- [http://dev.chromium.org/developers/design-documents/desktop-notifications/api-specification][1]
* Specifications from W3
--- [https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html][2]
```javascript
var ready_to_use = notice.ready();
// returns true if everything is ready
// var result = notice.check();
// check permission
// -1: not support
// 0: allow
// 1: need to request
// 2: denied
//
// constants below was defined in Chrome
// PERMISSION_ALLOWED = 0
// PERMISSION_NOT_ALLOWED = 1
// PERMISSION_DENIED = 2
if (result == -1) alert("Your browser doesn't support desktop notification.");
else if (result == 1) notice.request();
else if (result == 2) alert("You have denied permission of desktop notification.");
var obj = new notice("img.png", "title text", "content text");
obj.show(); // show notification without timedout
obj.show(time); // show notification with timedout
[1]: http://dev.chromium.org/developers/design-documents/desktop-notifications/api-specification
[2]: https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html