Would like to change default image icon
Closed this issue · 6 comments
sarfarazansari commented
I am trying to replace default icon. but some how am getting result like below image.
My icon is going right side straight forward while am expecting it to left side.
does am doing something wrong?
here is the snippet am using.
if (process.platform === 'darwin') {
let opts = {
body: data.message.content,
canReply: true,
icon: 'IMAGE_URL_WITH_ABSOLUTE_PATH'
};
const notification = new Notification(data.title, opts);
notification.addEventListener('reply', ({ response }) => {
console.log(`User entered: ${response}`);
});
}
let me know thanks
j-f1 commented
To change the icon on the left, I think you have to change the icon of the Electron .app
.
sarfarazansari commented
@j-f1 yup you are right. my bad it works when I made a build
Aarbel commented
@sarfarazansari
Facing same problem
where did you changed the Electron .app
icon ?
Extract of my package.json (i'm using electron and electron-builder)
…
"build": {
"appId": my.aypp.id",
"dmg": {
"contents": [
{
"x": 110,
"y": 270
},
{
"x": 370,
"y": 270,
"type": "link",
"path": "/Applications"
}
]
},
"mac": {
"category": "productivity",
"extendInfo": {
"CFBundleURLName": "myapp",
"CFBundleURLSchemes": [
"myapp"
],
"NSUserNotificationAlertStyle": "alert"
}
},
},
Thanks a lot for your help !
sarfarazansari commented
@Aarbel
here you go
// package.json
"build": {
"nodeGypRebuild": false,
"generateUpdatesFilesForAllChannels": true,
"appId": "YOUR_APP_ID",
"productName": "KISS",
"directories": {
"buildResources": "src/assets/electron",
"output": "packages",
"app": "dist"
},
"mac": {
"category": "public.app-category.productivity",
"target": [
"dmg",
"zip"
],
"identity": "YOUR_IDENTITY",
"type": "distribution",
"entitlements": "default.entitlements.mac.plist",
"provisioningProfile": "embedded.provisionprofile"
}
}
// notification.ts
import { ipcMain, BrowserWindow } from 'electron';
import * as notifier from 'node-notifier';
import * as path from 'path';
function handleRes(e: any, data: any, err: any, response: string, metadata: any) {
if (err) {
elog.info('error from notification', err);
return;
}
// success do something
}
let opts: any = {
title: data.title,
message: data.message.content,
icon: path.join(__dirname, '/assets/icon/icon.png'),
sound: true,
timeout: 5
};
if (process.platform === 'darwin') {
const NotificationCenter = require('node-notifier').NotificationCenter;
const mac = new NotificationCenter({withFallback: true});
opts.appIcon = 'https://kiss-uploads.sokt.io/H1TeBMgrX_icon.png';
opts.icon = 'https://kiss-uploads.sokt.io/H1TeBMgrX_icon.png';
opts.sound = 'Tink';
mac.notify(opts, (err: any, response: string, metadata: any) => {
handleRes(e, data, err, response, metadata);
});
} else {
notifier.notify(opts, (err: any, response: string, metadata: any) => {
handleRes(e, data, err, response, metadata);
});
}
Aarbel commented
@sarfarazansari you use node-notifier
, not node-mac-notifier ;)
alihasen commented
Does anyone find a solution?? I am still facing this issue.