web-manager 3.2.68 → 3.2.69
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.
- package/index.js +25 -31
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1018,20 +1018,27 @@ Manager.prototype.notifications = function(options) {
|
|
1018
1018
|
|
1019
1019
|
return {
|
1020
1020
|
isSubscribed: function () {
|
1021
|
-
// self.log('isSubscribed()');
|
1022
1021
|
return new Promise(function(resolve, reject) {
|
1023
|
-
|
1024
|
-
|
1022
|
+
// Log
|
1023
|
+
// self.log('isSubscribed()');
|
1024
|
+
|
1025
|
+
// Check if subscribed
|
1026
|
+
return resolve(supported && Notification.permission === 'granted');
|
1025
1027
|
})
|
1026
1028
|
},
|
1027
1029
|
subscribe: function () {
|
1028
|
-
// self.log('subscribe()');
|
1029
1030
|
return new Promise(function(resolve, reject) {
|
1030
|
-
//
|
1031
|
+
// Log
|
1032
|
+
// self.log('subscribe()');
|
1033
|
+
|
1034
|
+
// Check if supported
|
1031
1035
|
if (!supported) {
|
1032
1036
|
return resolve(false)
|
1033
1037
|
}
|
1034
|
-
|
1038
|
+
|
1039
|
+
// Ask for permission
|
1040
|
+
firebase.messaging()
|
1041
|
+
.getToken({
|
1035
1042
|
serviceWorkerRegistration: self.properties.references.serviceWorker,
|
1036
1043
|
})
|
1037
1044
|
.then(function (token) {
|
@@ -1051,7 +1058,7 @@ Manager.prototype.notifications = function(options) {
|
|
1051
1058
|
if (localHash !== userHash || dateDifference > 1) {
|
1052
1059
|
var timestamp = currentDate.toISOString();
|
1053
1060
|
var timestampUNIX = Math.floor((+new Date(timestamp)) / 1000);
|
1054
|
-
var subscriptionRef = firebase.firestore().doc('notifications/
|
1061
|
+
var subscriptionRef = firebase.firestore().doc('notifications/' + token);
|
1055
1062
|
|
1056
1063
|
function saveLocal() {
|
1057
1064
|
// console.log('---------saveLocal');
|
@@ -1060,38 +1067,25 @@ Manager.prototype.notifications = function(options) {
|
|
1060
1067
|
}
|
1061
1068
|
|
1062
1069
|
function saveServer(doc) {
|
1063
|
-
// console.log('-------saveServer', !doc.exists, !self.utilities().get(doc.data(), 'link.user.data.uid', ''), user.uid);
|
1064
1070
|
// Run if it (DOES NOT EXIST on server) OR (it does AND the uid field is null AND the current user is not null)
|
1065
|
-
if (!doc.exists || (doc.exists && !self.utilities().get(doc.data(), '
|
1071
|
+
if (!doc.exists || (doc.exists && !self.utilities().get(doc.data(), 'owner.uid', '') && user.uid)) {
|
1066
1072
|
subscriptionRef
|
1067
1073
|
.set(
|
1068
1074
|
{
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
timestampUNIX: timestampUNIX
|
1073
|
-
},
|
1074
|
-
url: window.location.href,
|
1075
|
+
created: {
|
1076
|
+
timestamp: timestamp,
|
1077
|
+
timestampUNIX: timestampUNIX,
|
1075
1078
|
},
|
1076
|
-
|
1077
|
-
|
1078
|
-
user: {
|
1079
|
-
lastLinked: {
|
1080
|
-
timestamp: timestamp,
|
1081
|
-
timestampUNIX: timestampUNIX
|
1082
|
-
},
|
1083
|
-
pk: user.uid,
|
1084
|
-
data: {
|
1085
|
-
uid: user.uid,
|
1086
|
-
email: user.email
|
1087
|
-
}
|
1088
|
-
}
|
1079
|
+
owner: {
|
1080
|
+
uid: user.uid,
|
1089
1081
|
},
|
1090
|
-
|
1082
|
+
token: token,
|
1083
|
+
url: window.location.href,
|
1084
|
+
tags: ['general'],
|
1091
1085
|
},
|
1092
1086
|
{
|
1093
|
-
merge: true
|
1094
|
-
}
|
1087
|
+
merge: true,
|
1088
|
+
},
|
1095
1089
|
)
|
1096
1090
|
.then(function(data) {
|
1097
1091
|
// self.log('Updated token: ', token);
|
package/package.json
CHANGED