web-manager 3.2.70 → 3.2.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +21 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1088,13 +1088,13 @@ Manager.prototype.notifications = function(options) {
1088
1088
  },
1089
1089
  )
1090
1090
  .then(function(data) {
1091
- // self.log('Updated token: ', token);
1091
+ // self.log('Updated token:', token);
1092
1092
  saveLocal();
1093
1093
  resolve(true);
1094
1094
  })
1095
1095
  } else {
1096
1096
  saveLocal();
1097
- // self.log('Skip sync, server data exists.');
1097
+ // self.log('Skip sync because server data exists');
1098
1098
  resolve(false);
1099
1099
  }
1100
1100
  }
@@ -1109,7 +1109,7 @@ Manager.prototype.notifications = function(options) {
1109
1109
  saveServer({exists: false})
1110
1110
  })
1111
1111
  } else {
1112
- // self.log('Skip sync, recently done.');
1112
+ // self.log('Skip sync because recently done');
1113
1113
  resolve(false);
1114
1114
  }
1115
1115
 
@@ -1196,10 +1196,25 @@ function subscriptionManager(self, options_user) {
1196
1196
  // Normally, notifications are not displayed when user is ON PAGE but we will display it here anyway
1197
1197
  try {
1198
1198
  firebase.messaging().onMessage(function (payload) {
1199
- new Notification(payload.notification.title, payload.notification)
1199
+ // Get the notification data
1200
+ var notification = payload.notification;
1201
+
1202
+ // Log
1203
+ console.log('Message received', payload);
1204
+
1205
+ // Display notification
1206
+ new Notification(notification.title, notification)
1200
1207
  .onclick = function(event) {
1201
- event.preventDefault(); // prevent the browser from focusing the Notification's tab
1202
- window.open(payload.notification.click_action, '_blank');
1208
+ // Quit if there is no click action
1209
+ if (!notification.click_action) {
1210
+ return;
1211
+ }
1212
+
1213
+ // prevent the browser from focusing the Notification's tab
1214
+ event.preventDefault();
1215
+
1216
+ // Open the click action
1217
+ window.open(notification.click_action, '_blank');
1203
1218
  }
1204
1219
  })
1205
1220
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.70",
3
+ "version": "3.2.71",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {