1
Fork 0

Use a ENV file

This commit is contained in:
KorbsStudio 2023-02-12 12:35:24 -05:00
parent bd283bfa2e
commit 0bfacbff80
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

1
.env Normal file
View file

@ -0,0 +1 @@
PushyAppId="YourAppIdHere"

View file

@ -6,6 +6,9 @@ const isDev = require('electron-is-dev')
const path = require('path')
let mainWindow
require('dotenv').config()
console.log(process.env.PushyAppId);
// Use the correct icon depending on the operating system
if /* If macOS */ (process.platform == 'darwin') {global.AppIcon = 'public/images/icons/app/macOS.icns' }
else if /* If Windows */ (process.platform == 'win32') {global.AppIcon = 'public/images/icons/app/Windows.png' }
@ -42,12 +45,12 @@ function createWindow () {
// Pushy - Pushy Notification System (PNS)
mainWindow.webContents.on('did-finish-load', () => {Pushy.listen()})
Pushy.register({ appId: 'YourAppIdHere' }).then((deviceToken) => {}).catch((error) => {console.log('Pushy registration error: ' + error.message)})
Pushy.register({ appId: process.env.PushyAppId }).then((deviceToken) => {}).catch((error) => {console.log('Pushy registration error: ' + error.message)})
setTimeout(() => {
Pushy.setNotificationListener((data) => {
mainWindow.webContents.executeJavaScript(`
document.querySelector("body > div > div.sidebar > div.sidebar-bottom").insertAdjacentHTML("afterBegin",'<li class="notification"><img class="notification-image" src="${data.image}"><i class="${data.icon}"></i><p class="notification-title">${data.title}</p><p class="notification-message">${data.message}</p><div class="notification-actions"><button id="primary" class="notification-action">${data.action}</button><button id="secondary" class="notification-action">Dismiss</button></div></li>')
document.querySelector("body > div > div.sidebar > div.sidebar-bottom").insertAdjacentHTML("afterBegin",'<li class="notification"><img class="notification-image" src="${data.image}"><i class="${data.icon}"></i><p class="notification-title">${data.title}</p><p class="notification-message">${data.message}</p><div class="notification-actions"><button id="primary" class="notification-action" onclick="shell.openExternal(${data.action})">Open</button><button id="secondary" class="notification-action">Dismiss</button></div></li>')
`)
})
}, 10000);