pushjs-notification
pushjs-notification is the fastest way to get up and running with Javascript desktop and mobile notifications. The Notification API allows modern browsers such as Chrome, Safari, Firefox, and IE 9+ to push notifications to a user's desktop.
Installation
Install the plugin using the NPM.
npm install pushjs-notification --save
Basic Implementation
Import the package in your component
;@ ... { let jsPush = ; jsPushNotificationTitle = 'pushjs-notification'; jsPushClickEnable = true; jsPushNavigateUrl = 'https://www.npmjs.com/package/pushjs.notification'; jsPushOptionsbody = 'The plugin supports modern browsers such as Chrome, Safari, Firefox, and IE 9+ to push notifications to a users desktop'; jsPushOptionsicon = 'favicon.ico'; jsPushOptionsimage = 'bannerImage.ico'; jsPush; } ...
Options
Inputs
- NotificationTitle
string
: Defines a title for the notification, which will be shown at the top of the notification window when it is fired. - ClickEnable
boolean
: Specifies whether click event is enabled or not (Default value isfalse
) - NavigateUrl
string
: If the ClickEnable istrue
, then when the notification is clicked, it will redirect to specified url. - Options
object
: An options object containing any custom settings that you want to apply to the notification.(These are optional settings) The possible options are:- dir
string
: The direction in which to display the notification. It defaults toauto
, which just adopts the browser's language setting behavior, but you can override that behaviour by setting values ofltr
andrtl
(although most browsers seem to ignore these settings.) - body
string
: ADOMString
representing the body text of the notification, which will be displayed below the title. - tag
string
: ADOMString
representing an identifying tag for the notification. - icon
string
: AUSVString
containing the URL of an icon to be displayed in the notification. - image
string
: AUSVString
containing the URL of an image to be displayed in the notification. - data
string
: Arbitrary data that you want associated with the notification. This can be of any data type. - vibrate
string
: AVibration Pattern
for the device's vibration hardware to emit when the notification fires. - renotify
boolean
: A Boolean specifying whether the user should be notified after a new notification replaces an old one. The default isfalse
, which means they won't be notified. - requireInteraction
boolean
: Indicates that a notification should remain active until the user clicks or dismisses it, rather than closing automatically. The default value isfalse
.
- dir
API Reference
showNotification() function
: Used to generate the notification.
Note: Before calling
sendNotification()
you need to initialize above specified Input properties for the customization.
Todos
- Write MORE Tests
- Add additional features
- Web Workers compatibility
License
MIT
Free Software, Hell Yeah!