Skip to content

Commit 16cde3a

Browse files
committed
Updated README
1 parent 9bad48d commit 16cde3a

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
Push is the fastest way to get up and running with Javascript desktop notifications. A fairly new addition to the official specification, the Notification API allows modern browsers such as Chrome, Safari, and IE 9+ to push notifications to a user's desktop. Push acts as a cross-browser solution to this API, falling back to use older implementations if the user's browser does not support the new API.
66

7+
#### Creating Notifications ####
78
So just how easy is it to create a notification using Push? We can do it in just one line, actually:
89

910
```javascript
@@ -18,6 +19,35 @@ define(['pushjs'], function (Push) {
1819
});
1920
```
2021

22+
#### Closing Notifications ####
23+
When it comes to closing notifications, you have a few options. You can either set a timeout (see "Options"), call Push's close() method, or pass around the notification object and call close() directly. Push's close() method will only work with newer browsers, taking in a notification's unique tag name and closing the first notification it finds with that tag:
24+
25+
```javascript
26+
Push.create('Hello World!', {
27+
tag: 'foo'
28+
});
29+
30+
// Somewhere later in your code...
31+
32+
Push.close('foo');
33+
```
34+
35+
Alternatively, you can assign the Notification wrapper returned by Push to a variable and close it directly:
36+
37+
```javascript
38+
var notification = Push.create('Hello World!');
39+
40+
// Somewhere later in your code...
41+
42+
notification.close();
43+
```
44+
45+
When it comes to clearing all open notifications, that's just as easy as well:
46+
47+
```javascript
48+
Push.clear();
49+
```
50+
2151
### Options ###
2252

2353
The only required argument in a Push call is a title. However, that doesn't mean you can't add a little something extra. You can pass in options to Push as well, like so:

0 commit comments

Comments
 (0)