web-manager 3.2.70 → 3.2.71
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +21 -6
- 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:
|
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
|
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
|
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
|
-
|
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
|
-
|
1202
|
-
|
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