Socket
Socket
Sign inDemoInstall

react-desktop-notification

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-desktop-notification - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.npmignore

69

index.js

@@ -7,42 +7,45 @@ /**

var Notifier = React.createClass({
statics: {
start:function (title,context,url,icon) {
if (!Notification) {
alert("你的浏览器不支持桌面通知,请使用chrome浏览器。");
return;
}
statics: {
start: function(title, context, url, icon) {
if (!Notification) {
console.log("Your browser is not support desktop notifications, please try Chrome or Firefox.");
return false;
}
if (!(icon.match(/\.(jpeg|jpg|gif|png)$/) != null)) {
return false;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification(title, {
icon: icon||"http://ob9oayzh3.bkt.clouddn.com/images.png",
body: context,
});
notification.onclick = function () {
window.open(url);
};
}
if (Notification.permission !== "granted") {
Notification.requestPermission();
} else {
var notification = new Notification(title, {
icon: icon || "http://ob9oayzh3.bkt.clouddn.com/images.png",
body: context,
});
notification.onclick = function() {
window.open(url);
};
}
},
}
},
shouldComponentUpdate: function () {
return false;
},
shouldComponentUpdate: function() {
return false;
},
getScript: function () {
var script = 'document.addEventListener("DOMContentLoaded", function () { if (Notification.permission !== "granted") Notification.requestPermission(); });';
return script;
},
getScript: function() {
var script = 'document.addEventListener("DOMContentLoaded", function () { if (Notification.permission !== "granted") Notification.requestPermission(); });';
return script;
},
render: function () {
return React.createElement("script", {
type: "text/javascript",
dangerouslySetInnerHTML: {
__html: this.getScript()
}
});
}
render: function() {
return React.createElement("script", {
type: "text/javascript",
dangerouslySetInnerHTML: {
__html: this.getScript()
}
});
}
});
module.exports = Notifier;
{
"name": "react-desktop-notification",
"version": "1.0.1",
"version": "1.0.2",
"description": "Use browser's desktop notification in React. It depends on notifications API of chrome or else browser's other way.",

@@ -5,0 +5,0 @@ "main": "index.js",

## react-desktop-notification
## install
```
```
npm install --save react-desktop-notification
```
```
## usage
```
import Notifier from "react-desktop-notification"
gotNewNotification(){
...
Notifier.start("Title","Here is context","www.google.com");
...
}
```
```
import Notifier from "react-desktop-notification"
gotNewNotification(){
...
//Here will pop a notifier.
Notifier.start("Title","Here is context","www.google.com","validated image url");
...
}
```
## git
https://github.com/leejaen/React-Desktop-Notification.git
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc