Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsenpeder authored Aug 28, 2018
1 parent aa316c1 commit 6edae72
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function setup(webContents) {
let credentials = config.get('credentials');
// Retrieve saved senderId
const savedSenderId = config.get('senderId');
if (started) {
webContents.send(NOTIFICATION_SERVICE_STARTED, (credentials.fcm || {}).token);
if (started && listener) {
webContents.send(NOTIFICATION_SERVICE_STARTED, (credentials.fcm || {}).token, listener);
return;
}
started = true;
Expand All @@ -54,7 +54,7 @@ function setup(webContents) {
// Listen for GCM/FCM notifications
listener = await listen(Object.assign({}, credentials, { persistentIds }), onNotification(webContents));
// Notify the renderer process that we are listening for notifications
webContents.send(NOTIFICATION_SERVICE_STARTED, credentials.fcm.token);
webContents.send(NOTIFICATION_SERVICE_STARTED, credentials.fcm.token, listener);
} catch (e) {
console.error('PUSH_RECEIVER:::Error while starting the service', e);
// Forward error to the renderer process
Expand All @@ -63,15 +63,6 @@ function setup(webContents) {
});
}

function destroy() {
if (started && listener) {
started = false;
listener.destroy();
}

return;
}

// Will be called on new notification
function onNotification(webContents) {
return ({ notification, persistentId }) => {
Expand Down

0 comments on commit 6edae72

Please sign in to comment.