[英]Open application when click on notification in electron.js app
I created one Electron application using webRTC where I implemented the notification for incoming call.我使用 webRTC 创建了一个 Electron 应用程序,我在其中实现了来电通知。 When I click on notification I need that my application should be open if it is minimize.
当我点击通知时,我需要我的应用程序在最小化时打开。
Could anyone suggest me the way?任何人都可以建议我的方式吗?
function showNotification (body_content) {
let myNotification = new Notification({ title: NOTIFICATION_TITLE,
body: `Incoming Call from ${body_content}` }).show()
console.log(myNotification,'notification')
}
You can define the browser window variable as global and display it with the show() function when you click the notification.您可以将浏览器 window 变量定义为全局变量,并在单击通知时使用 show() function 显示它。
var browserWindow = null;
function createWindow () {
browserWindow = new BrowserWindow({
width: 800,
height: 600
})
browserWindow.loadFile('index.html')
}
app.whenReady().then(createWindow);
function showNotification (body_content) {
let myNotification = new Notification({ title: NOTIFICATION_TITLE,
body: `Incoming Call from ${body_content}` })
console.log(myNotification,'notification')
myNotification.show()
myNotification.on('click', (event, arg)=>{
console.log("notification clicked")
browserWindow.show()
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.