Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
react-web-notification
Advanced tools
React component with HTML5 Web Notification API.
This component show nothing in dom element, but trigger HTML5 Web Notification API with render
method in the life cycle of React.js.
npm install --save react-web-notification
Notification
React component which wrap web-notification.
Notification.propTypes = {
ignore: bool,
disableActiveWindow: bool,
askAgain: bool,
notSupported: func,
onPermissionGranted: func,
onPermissionDenied: func,
onShow: func,
onClick: func,
onClose: func,
onError: func,
timeout: number,
title: string.isRequired,
options: object,
swRegistration: object,
};
ignore
: if true, nothing will be happen
disableActiveWindow
: if true, nothing will be happen when window is active
askAgain
: if true, window.Notification.requestPermission
will be called on componentDidMount
, even if it was denied before,
notSupported()
: Called when HTML5 Web Notification API is not supported.
onPermissionGranted()
: Called when permission granted.
onPermissionDenied()
: Called when permission denied. Notification
will do nothing until permission granted again.
onShow(e, tag)
: Called when Desktop notification is shown.
onClick(e, tag)
: Called when Desktop notification is clicked.
onClose(e, tag)
: Called when Desktop notification is closed.
onError(e, tag)
: Called when Desktop notification happen error.
timeout
: milli sec to close notification automatically. Ignored if 0
or less. (Default 5000
)
title
: Notification title.
options
: Notification options. set body
, tag
, icon
here.
See also (https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification)
swRegistration
: ServiceWorkerRegistration. Use this prop to delegate the notification creation to a service worker.
See also (https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification)
⚠️ onShow
, onClick
, onClose
and onError
handlers won't work when notification is created by the service worker.
See example
yarn
yarn run start:example
yarn test
Notification.sound
is not supported in any browser.
You can emulate it with onShow
callback. see example.Ver 0.8.0
FAQs
React component with HTML5 Web Notification API
The npm package react-web-notification receives a total of 2,388 weekly downloads. As such, react-web-notification popularity was classified as popular.
We found that react-web-notification demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.