| 98 | |
| 99 | // NODE-NOTIFIER |
| 100 | var showNativeNotification = function (icon, title, message, sound, image) { |
| 101 | var notifier; |
| 102 | try { |
| 103 | notifier = require('node-notifier'); |
| 104 | } catch (error) { |
| 105 | console.error(error); |
| 106 | if (error.message == "Cannot find module 'node-notifier'") { |
| 107 | window.alert("Can not load module 'node-notifier'.\nPlease run 'npm install'"); |
| 108 | } |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | var path = require('path'); |
| 113 | |
| 114 | icon = icon ? path.join(process.cwd(), icon) : undefined; |
| 115 | image = image ? path.join(process.cwd(), image) : undefined; |
| 116 | |
| 117 | notifier.notify({ |
| 118 | title: title, |
| 119 | message: message, |
| 120 | icon: icon, |
| 121 | appIcon: icon, |
| 122 | contentImage: image, |
| 123 | sound: sound, |
| 124 | wait: false, |
| 125 | sender: 'org.nwjs.sample.notifications' |
| 126 | }, function (err, response) { |
| 127 | if (response == "Activate\n") { |
| 128 | writeLog("node-notifier: notification clicked"); |
| 129 | NW.Window.get().focus(); |
| 130 | } |
| 131 | }); |
| 132 | |
| 133 | writeLog("-----<br>node-notifier: " + title); |
| 134 | }; |
| 135 | |
| 136 | // NW-NOTIFY |
| 137 | var showHtmlNotification = function (icon, title, body, callback) { |