Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexcastillo/ng2-notifications
Angular 2 Component for Native Push Notifications [Looking for New Maintainers]
https://github.com/alexcastillo/ng2-notifications
angular javascript notifications push-notifications
Last synced: 13 days ago
JSON representation
Angular 2 Component for Native Push Notifications [Looking for New Maintainers]
- Host: GitHub
- URL: https://github.com/alexcastillo/ng2-notifications
- Owner: alexcastillo
- License: mit
- Created: 2016-05-21T12:48:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-12T18:01:58.000Z (almost 7 years ago)
- Last Synced: 2024-10-12T08:13:05.041Z (28 days ago)
- Topics: angular, javascript, notifications, push-notifications
- Language: JavaScript
- Homepage: http://embed.plnkr.co/cHFcMsvL8lGX9Pnm4UVl/
- Size: 105 KB
- Stars: 185
- Watchers: 9
- Forks: 25
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-angular-components - ng2-notifications - Angular 2 Component for Native Push Notifications. (Uncategorized / Uncategorized)
- awesome-angular - ng2-notifications - Angular 2 Component for Native Push Notifications. (Uncategorized / Uncategorized)
- awesome-angular-components - ng2-notifications - Angular 2 Component for Native Push Notifications. (Uncategorized / Uncategorized)
- awesome-angular-components - alexcastillo/ng2-notifications - Angular 2 Component for Native Push Notifications [Looking for New Maintainers] (UI Components / Notification)
README
# Angular 2 Push Notifications
[![](./src/public/img/demo.gif)]()
> The Notifications API allows web pages to control the display of system notifications to the end user — these are outside the top-level browsing context viewport, so therefore can be displayed even the user has switched tabs or moved to a different app. The API is designed to be compatible with existing notification systems across different platforms.
[Read More about the API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API)
[Read the blog post](http://www.castillo.io/blog/2016/4/14/push-notifications-with-angular-2)
## Demo
[Launch Demo](http://embed.plnkr.co/cHFcMsvL8lGX9Pnm4UVl/)
## Quick Start
```bash
$ npm install ng2-notifications --save
```Then add it to your app:
``` ts
import { PushNotificationComponent } from 'ng2-notifications/ng2-notifications';@Component({
selector: 'my-app',
template: `
`,
directives: [PushNotificationComponent]
})
```## Usage
Example of a basic notification using literals for title, description and icon.
Please note this notification will not close by itself.``` html
```
For data binding use:
``` html
```
### Self-closing
To self-close after a period of time, just add the `[closeDelay]` attribute with a value of milliseconds. The example below will self-close in 5 seconds.
``` html
```
### Controlling when to fire a notification
It is possible to control when a notification is shown.
Simply add a template variable and call the `.show()` method on the variable on any event.``` html
```
In this case, the load event will fire when the component is ready (`ngOnInit`).
### Click Event
To attach a click handler to a notification, add the `(action)` event.
``` html
```
### Show and Close events
It is possible to listen for show/close events to fire and attach a callback.
``` html
```
### Error Event
This event is unlikely, but in order to attach a callback to the notification error event, simply use the `(error)` event.
``` html
```
## Other Options
* data
* tag
* dir: (default: 'auto')
* lang: (default: 'en-US')## Browser Support
[See Browser Support](http://caniuse.com/#feat=notifications)
The folowing options are either in recommendation state or have no browser support currently.
* [Renotify](https://developer.mozilla.org/en-US/docs/Web/API/notification/renotify)
* [Silent](https://developer.mozilla.org/en-US/docs/Web/API/notification/silent)
* [Sound](https://developer.mozilla.org/en-US/docs/Web/API/notification/silent)
* [Vibrate](https://developer.mozilla.org/en-US/docs/Web/API/notification/vibrate)
* [Sticky](https://developer.mozilla.org/en-US/docs/Web/API/notification/sticky)
* [Noscreen](https://developer.mozilla.org/en-US/docs/Web/API/notification/noscreen)It is important to know if you’re browsing in incognito mode in Google Chrome, you won’t get notifications.
## License
The MIT License ([MIT](/LICENSE))
Copyright (c) 2017 Alex Castillo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.