A simple javascript push notification library for a websites. It uses a javascript Notification API and supported on all browsers for desktop and mobile.
to use a push notification feature you need to add a push notification to your website add
- Add/link javascript file from dist folder to your website
- make a function call to on notification object using using NotifyMe object.
to get show a push notification for a user need to grant a notification access on the browser. so to do that we need to use the following method to request a notification permission.
NotifyMe.requestPermission();
To check the status of status of website notification permission you can use the following method. It have a return values default, granted or denied
NotifyMe.permission();
to make a push notification make a call to member function notify it will have an object argument option which have 3 important properties title, tag, message other more optional properties.
NotifyMe.notify({
title: "Title",
tag: "tag",
message: "Notification body/message",
});
Method | Description |
---|---|
requestPermission() | make a request for notification access permission |
permission() | return notification permission status |
notify(option) | show notification |
A properties that can be used on Option for notify method
Properties | Description | Value | Default | Note |
---|---|---|---|---|
title | add titlte to notification | string | null | Important |
tag | linking morethan one notification together | string | null | Important |
message | notification body | string | null | Important |
icon | url address to icon/logo | url | null | |
image | url address to image | url | null | Not supported by all browsers |
silent | intended to fire a silent notification | boolean | false | Not supported by all browsers |
renotify | intended to fire a silent notification | boolean | true | Not supported by all browsers |