@kolektor/nucleus-notifications 0.0.8-pre.5672 → 0.0.9-pre.5707
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/{esm2015/kolektor-nucleus-notifications.js → esm2020/kolektor-nucleus-notifications.mjs} +0 -0
- package/{esm2015/lib/models.js → esm2020/lib/models.mjs} +0 -0
- package/{esm2015/lib/nucleus-notifications.module.js → esm2020/lib/nucleus-notifications.module.mjs} +4 -4
- package/esm2020/lib/nucleus-notifications.service.mjs +356 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/fesm2015/{kolektor-nucleus-notifications.js → kolektor-nucleus-notifications.mjs} +10 -11
- package/fesm2015/kolektor-nucleus-notifications.mjs.map +1 -0
- package/fesm2020/kolektor-nucleus-notifications.mjs +406 -0
- package/fesm2020/kolektor-nucleus-notifications.mjs.map +1 -0
- package/package.json +23 -10
- package/bundles/kolektor-nucleus-notifications.umd.js +0 -894
- package/bundles/kolektor-nucleus-notifications.umd.js.map +0 -1
- package/esm2015/lib/nucleus-notifications.service.js +0 -361
- package/fesm2015/kolektor-nucleus-notifications.js.map +0 -1
|
@@ -1,894 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@capacitor/push-notifications'), require('rxjs'), require('@angular/common/http'), require('@angular/service-worker'), require('@kolektor/nucleus-common')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@kolektor/nucleus-notifications', ['exports', '@angular/core', '@capacitor/push-notifications', 'rxjs', '@angular/common/http', '@angular/service-worker', '@kolektor/nucleus-common'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.kolektor = global.kolektor || {}, global.kolektor['nucleus-notifications'] = {}), global.ng.core, global.pushNotifications, global.rxjs, global.ng.common.http, global.ng.serviceWorker, global.i3));
|
|
5
|
-
}(this, (function (exports, i0, pushNotifications, rxjs, i1, i2, i3) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return e[k];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n['default'] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
|
-
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
-
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
30
|
-
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
|
|
31
|
-
|
|
32
|
-
/*! *****************************************************************************
|
|
33
|
-
Copyright (c) Microsoft Corporation.
|
|
34
|
-
|
|
35
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
36
|
-
purpose with or without fee is hereby granted.
|
|
37
|
-
|
|
38
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
39
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
40
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
41
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
42
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
43
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
44
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
45
|
-
***************************************************************************** */
|
|
46
|
-
/* global Reflect, Promise */
|
|
47
|
-
var extendStatics = function (d, b) {
|
|
48
|
-
extendStatics = Object.setPrototypeOf ||
|
|
49
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
50
|
-
function (d, b) { for (var p in b)
|
|
51
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
52
|
-
d[p] = b[p]; };
|
|
53
|
-
return extendStatics(d, b);
|
|
54
|
-
};
|
|
55
|
-
function __extends(d, b) {
|
|
56
|
-
if (typeof b !== "function" && b !== null)
|
|
57
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
58
|
-
extendStatics(d, b);
|
|
59
|
-
function __() { this.constructor = d; }
|
|
60
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
61
|
-
}
|
|
62
|
-
var __assign = function () {
|
|
63
|
-
__assign = Object.assign || function __assign(t) {
|
|
64
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
65
|
-
s = arguments[i];
|
|
66
|
-
for (var p in s)
|
|
67
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
68
|
-
t[p] = s[p];
|
|
69
|
-
}
|
|
70
|
-
return t;
|
|
71
|
-
};
|
|
72
|
-
return __assign.apply(this, arguments);
|
|
73
|
-
};
|
|
74
|
-
function __rest(s, e) {
|
|
75
|
-
var t = {};
|
|
76
|
-
for (var p in s)
|
|
77
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
78
|
-
t[p] = s[p];
|
|
79
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
80
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
81
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
82
|
-
t[p[i]] = s[p[i]];
|
|
83
|
-
}
|
|
84
|
-
return t;
|
|
85
|
-
}
|
|
86
|
-
function __decorate(decorators, target, key, desc) {
|
|
87
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
88
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
89
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
90
|
-
else
|
|
91
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
92
|
-
if (d = decorators[i])
|
|
93
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
94
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
95
|
-
}
|
|
96
|
-
function __param(paramIndex, decorator) {
|
|
97
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
98
|
-
}
|
|
99
|
-
function __metadata(metadataKey, metadataValue) {
|
|
100
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
101
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
102
|
-
}
|
|
103
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
104
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
105
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
106
|
-
function fulfilled(value) { try {
|
|
107
|
-
step(generator.next(value));
|
|
108
|
-
}
|
|
109
|
-
catch (e) {
|
|
110
|
-
reject(e);
|
|
111
|
-
} }
|
|
112
|
-
function rejected(value) { try {
|
|
113
|
-
step(generator["throw"](value));
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
reject(e);
|
|
117
|
-
} }
|
|
118
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
119
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
function __generator(thisArg, body) {
|
|
123
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
124
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
125
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
126
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
127
|
-
function step(op) {
|
|
128
|
-
if (f)
|
|
129
|
-
throw new TypeError("Generator is already executing.");
|
|
130
|
-
while (_)
|
|
131
|
-
try {
|
|
132
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
133
|
-
return t;
|
|
134
|
-
if (y = 0, t)
|
|
135
|
-
op = [op[0] & 2, t.value];
|
|
136
|
-
switch (op[0]) {
|
|
137
|
-
case 0:
|
|
138
|
-
case 1:
|
|
139
|
-
t = op;
|
|
140
|
-
break;
|
|
141
|
-
case 4:
|
|
142
|
-
_.label++;
|
|
143
|
-
return { value: op[1], done: false };
|
|
144
|
-
case 5:
|
|
145
|
-
_.label++;
|
|
146
|
-
y = op[1];
|
|
147
|
-
op = [0];
|
|
148
|
-
continue;
|
|
149
|
-
case 7:
|
|
150
|
-
op = _.ops.pop();
|
|
151
|
-
_.trys.pop();
|
|
152
|
-
continue;
|
|
153
|
-
default:
|
|
154
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
155
|
-
_ = 0;
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
159
|
-
_.label = op[1];
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
163
|
-
_.label = t[1];
|
|
164
|
-
t = op;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
if (t && _.label < t[2]) {
|
|
168
|
-
_.label = t[2];
|
|
169
|
-
_.ops.push(op);
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
if (t[2])
|
|
173
|
-
_.ops.pop();
|
|
174
|
-
_.trys.pop();
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
op = body.call(thisArg, _);
|
|
178
|
-
}
|
|
179
|
-
catch (e) {
|
|
180
|
-
op = [6, e];
|
|
181
|
-
y = 0;
|
|
182
|
-
}
|
|
183
|
-
finally {
|
|
184
|
-
f = t = 0;
|
|
185
|
-
}
|
|
186
|
-
if (op[0] & 5)
|
|
187
|
-
throw op[1];
|
|
188
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
192
|
-
if (k2 === undefined)
|
|
193
|
-
k2 = k;
|
|
194
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
195
|
-
}) : (function (o, m, k, k2) {
|
|
196
|
-
if (k2 === undefined)
|
|
197
|
-
k2 = k;
|
|
198
|
-
o[k2] = m[k];
|
|
199
|
-
});
|
|
200
|
-
function __exportStar(m, o) {
|
|
201
|
-
for (var p in m)
|
|
202
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
203
|
-
__createBinding(o, m, p);
|
|
204
|
-
}
|
|
205
|
-
function __values(o) {
|
|
206
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
207
|
-
if (m)
|
|
208
|
-
return m.call(o);
|
|
209
|
-
if (o && typeof o.length === "number")
|
|
210
|
-
return {
|
|
211
|
-
next: function () {
|
|
212
|
-
if (o && i >= o.length)
|
|
213
|
-
o = void 0;
|
|
214
|
-
return { value: o && o[i++], done: !o };
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
218
|
-
}
|
|
219
|
-
function __read(o, n) {
|
|
220
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
221
|
-
if (!m)
|
|
222
|
-
return o;
|
|
223
|
-
var i = m.call(o), r, ar = [], e;
|
|
224
|
-
try {
|
|
225
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
226
|
-
ar.push(r.value);
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
e = { error: error };
|
|
230
|
-
}
|
|
231
|
-
finally {
|
|
232
|
-
try {
|
|
233
|
-
if (r && !r.done && (m = i["return"]))
|
|
234
|
-
m.call(i);
|
|
235
|
-
}
|
|
236
|
-
finally {
|
|
237
|
-
if (e)
|
|
238
|
-
throw e.error;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return ar;
|
|
242
|
-
}
|
|
243
|
-
/** @deprecated */
|
|
244
|
-
function __spread() {
|
|
245
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
246
|
-
ar = ar.concat(__read(arguments[i]));
|
|
247
|
-
return ar;
|
|
248
|
-
}
|
|
249
|
-
/** @deprecated */
|
|
250
|
-
function __spreadArrays() {
|
|
251
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
252
|
-
s += arguments[i].length;
|
|
253
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
254
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
255
|
-
r[k] = a[j];
|
|
256
|
-
return r;
|
|
257
|
-
}
|
|
258
|
-
function __spreadArray(to, from, pack) {
|
|
259
|
-
if (pack || arguments.length === 2)
|
|
260
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
261
|
-
if (ar || !(i in from)) {
|
|
262
|
-
if (!ar)
|
|
263
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
264
|
-
ar[i] = from[i];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
268
|
-
}
|
|
269
|
-
function __await(v) {
|
|
270
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
271
|
-
}
|
|
272
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
273
|
-
if (!Symbol.asyncIterator)
|
|
274
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
275
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
276
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
277
|
-
function verb(n) { if (g[n])
|
|
278
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
279
|
-
function resume(n, v) { try {
|
|
280
|
-
step(g[n](v));
|
|
281
|
-
}
|
|
282
|
-
catch (e) {
|
|
283
|
-
settle(q[0][3], e);
|
|
284
|
-
} }
|
|
285
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
286
|
-
function fulfill(value) { resume("next", value); }
|
|
287
|
-
function reject(value) { resume("throw", value); }
|
|
288
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
289
|
-
resume(q[0][0], q[0][1]); }
|
|
290
|
-
}
|
|
291
|
-
function __asyncDelegator(o) {
|
|
292
|
-
var i, p;
|
|
293
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
294
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
295
|
-
}
|
|
296
|
-
function __asyncValues(o) {
|
|
297
|
-
if (!Symbol.asyncIterator)
|
|
298
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
299
|
-
var m = o[Symbol.asyncIterator], i;
|
|
300
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
301
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
302
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
303
|
-
}
|
|
304
|
-
function __makeTemplateObject(cooked, raw) {
|
|
305
|
-
if (Object.defineProperty) {
|
|
306
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
cooked.raw = raw;
|
|
310
|
-
}
|
|
311
|
-
return cooked;
|
|
312
|
-
}
|
|
313
|
-
;
|
|
314
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
315
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
316
|
-
}) : function (o, v) {
|
|
317
|
-
o["default"] = v;
|
|
318
|
-
};
|
|
319
|
-
function __importStar(mod) {
|
|
320
|
-
if (mod && mod.__esModule)
|
|
321
|
-
return mod;
|
|
322
|
-
var result = {};
|
|
323
|
-
if (mod != null)
|
|
324
|
-
for (var k in mod)
|
|
325
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
326
|
-
__createBinding(result, mod, k);
|
|
327
|
-
__setModuleDefault(result, mod);
|
|
328
|
-
return result;
|
|
329
|
-
}
|
|
330
|
-
function __importDefault(mod) {
|
|
331
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
332
|
-
}
|
|
333
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
334
|
-
if (kind === "a" && !f)
|
|
335
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
336
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
337
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
338
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
339
|
-
}
|
|
340
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
341
|
-
if (kind === "m")
|
|
342
|
-
throw new TypeError("Private method is not writable");
|
|
343
|
-
if (kind === "a" && !f)
|
|
344
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
345
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
346
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
347
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
var Notification = /** @class */ (function () {
|
|
351
|
-
function Notification() {
|
|
352
|
-
}
|
|
353
|
-
return Notification;
|
|
354
|
-
}());
|
|
355
|
-
var Identity = /** @class */ (function () {
|
|
356
|
-
function Identity() {
|
|
357
|
-
}
|
|
358
|
-
return Identity;
|
|
359
|
-
}());
|
|
360
|
-
var Recipient = /** @class */ (function () {
|
|
361
|
-
function Recipient() {
|
|
362
|
-
}
|
|
363
|
-
return Recipient;
|
|
364
|
-
}());
|
|
365
|
-
var NotificationData = /** @class */ (function () {
|
|
366
|
-
function NotificationData() {
|
|
367
|
-
}
|
|
368
|
-
return NotificationData;
|
|
369
|
-
}());
|
|
370
|
-
var WebKey = /** @class */ (function () {
|
|
371
|
-
function WebKey() {
|
|
372
|
-
}
|
|
373
|
-
return WebKey;
|
|
374
|
-
}());
|
|
375
|
-
var Registration = /** @class */ (function () {
|
|
376
|
-
function Registration() {
|
|
377
|
-
}
|
|
378
|
-
return Registration;
|
|
379
|
-
}());
|
|
380
|
-
var RegistrationResult = /** @class */ (function () {
|
|
381
|
-
function RegistrationResult() {
|
|
382
|
-
}
|
|
383
|
-
return RegistrationResult;
|
|
384
|
-
}());
|
|
385
|
-
var PayloadData = /** @class */ (function () {
|
|
386
|
-
function PayloadData() {
|
|
387
|
-
}
|
|
388
|
-
return PayloadData;
|
|
389
|
-
}());
|
|
390
|
-
var NucleusNotificationsConfig = /** @class */ (function () {
|
|
391
|
-
function NucleusNotificationsConfig() {
|
|
392
|
-
}
|
|
393
|
-
return NucleusNotificationsConfig;
|
|
394
|
-
}());
|
|
395
|
-
var NotificationClick = /** @class */ (function () {
|
|
396
|
-
function NotificationClick() {
|
|
397
|
-
}
|
|
398
|
-
return NotificationClick;
|
|
399
|
-
}());
|
|
400
|
-
var UserChannelConfig = /** @class */ (function () {
|
|
401
|
-
function UserChannelConfig() {
|
|
402
|
-
}
|
|
403
|
-
return UserChannelConfig;
|
|
404
|
-
}());
|
|
405
|
-
|
|
406
|
-
var NucleusNotificationsService = /** @class */ (function () {
|
|
407
|
-
function NucleusNotificationsService(http, swPush, appService, config) {
|
|
408
|
-
this.http = http;
|
|
409
|
-
this.swPush = swPush;
|
|
410
|
-
this.appService = appService;
|
|
411
|
-
this.apiUrl = null;
|
|
412
|
-
this.registrationStorageKey = 'NucleusNotificationsRegistrationId';
|
|
413
|
-
this.notificationsStorageKey = 'NucleusNotificationsLocalCache';
|
|
414
|
-
this._isInitialized = false;
|
|
415
|
-
this._newNotifications = new rxjs.Subject();
|
|
416
|
-
this._clicksSubject = new rxjs.Subject();
|
|
417
|
-
this._stateChangesSubject = new rxjs.Subject();
|
|
418
|
-
this.notifications = [];
|
|
419
|
-
var url = config.serverApiUrl;
|
|
420
|
-
if (!url.endsWith('/')) {
|
|
421
|
-
url += '/';
|
|
422
|
-
}
|
|
423
|
-
this.apiUrl = url;
|
|
424
|
-
}
|
|
425
|
-
Object.defineProperty(NucleusNotificationsService.prototype, "unreadCount", {
|
|
426
|
-
get: function () {
|
|
427
|
-
return this.notifications.filter(function (x) { return !x.isRead; }).length;
|
|
428
|
-
},
|
|
429
|
-
enumerable: false,
|
|
430
|
-
configurable: true
|
|
431
|
-
});
|
|
432
|
-
Object.defineProperty(NucleusNotificationsService.prototype, "newNotifications", {
|
|
433
|
-
get: function () {
|
|
434
|
-
return this._newNotifications.asObservable();
|
|
435
|
-
},
|
|
436
|
-
enumerable: false,
|
|
437
|
-
configurable: true
|
|
438
|
-
});
|
|
439
|
-
Object.defineProperty(NucleusNotificationsService.prototype, "clicks", {
|
|
440
|
-
get: function () {
|
|
441
|
-
return this._clicksSubject.asObservable();
|
|
442
|
-
},
|
|
443
|
-
enumerable: false,
|
|
444
|
-
configurable: true
|
|
445
|
-
});
|
|
446
|
-
Object.defineProperty(NucleusNotificationsService.prototype, "stateChanges", {
|
|
447
|
-
get: function () {
|
|
448
|
-
return this._stateChangesSubject.asObservable();
|
|
449
|
-
},
|
|
450
|
-
enumerable: false,
|
|
451
|
-
configurable: true
|
|
452
|
-
});
|
|
453
|
-
Object.defineProperty(NucleusNotificationsService.prototype, "isInitialized", {
|
|
454
|
-
get: function () {
|
|
455
|
-
return this._isInitialized;
|
|
456
|
-
},
|
|
457
|
-
enumerable: false,
|
|
458
|
-
configurable: true
|
|
459
|
-
});
|
|
460
|
-
NucleusNotificationsService.prototype.initialize = function () {
|
|
461
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
462
|
-
var _this = this;
|
|
463
|
-
return __generator(this, function (_b) {
|
|
464
|
-
switch (_b.label) {
|
|
465
|
-
case 0:
|
|
466
|
-
// make sure app service has finished initializing
|
|
467
|
-
return [4 /*yield*/, this.appService.init()];
|
|
468
|
-
case 1:
|
|
469
|
-
// make sure app service has finished initializing
|
|
470
|
-
_b.sent();
|
|
471
|
-
this.loadFromStorage();
|
|
472
|
-
if (!this.appService.isNative) return [3 /*break*/, 3];
|
|
473
|
-
this._platform = this.appService.deviceInfo.platform;
|
|
474
|
-
return [4 /*yield*/, this.registerCapacitorEvents()];
|
|
475
|
-
case 2:
|
|
476
|
-
_b.sent();
|
|
477
|
-
return [3 /*break*/, 4];
|
|
478
|
-
case 3:
|
|
479
|
-
if (this.swPush.isEnabled) {
|
|
480
|
-
this._platform = 'web';
|
|
481
|
-
this.registerWebPushEvents();
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
console.warn('Nucleus.Notifications: There is no push capability, timer will be used to update notifications');
|
|
485
|
-
setInterval(function () {
|
|
486
|
-
console.log('Updating notifications...');
|
|
487
|
-
_this.refresh(true);
|
|
488
|
-
}, 5 * 60 * 1000);
|
|
489
|
-
}
|
|
490
|
-
_b.label = 4;
|
|
491
|
-
case 4:
|
|
492
|
-
this._isInitialized = true;
|
|
493
|
-
this.refresh();
|
|
494
|
-
return [2 /*return*/];
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
NucleusNotificationsService.prototype.register = function () {
|
|
500
|
-
var _this = this;
|
|
501
|
-
return new Promise(function (_resolve, _reject) {
|
|
502
|
-
_this.getRegistrationInfo().then(function (info) {
|
|
503
|
-
_this.http.post(_this.apiUrl + 'registration', info).subscribe(function (regResult) {
|
|
504
|
-
window.localStorage.setItem(_this.registrationStorageKey, regResult.id);
|
|
505
|
-
_resolve(null);
|
|
506
|
-
}, function (error) {
|
|
507
|
-
console.log('Nucleus.Notifications: Failed to send notification registration to server.', error);
|
|
508
|
-
_reject(error);
|
|
509
|
-
});
|
|
510
|
-
}).catch(function (error) { return _reject(error); });
|
|
511
|
-
});
|
|
512
|
-
};
|
|
513
|
-
NucleusNotificationsService.prototype.unregister = function () {
|
|
514
|
-
var _this = this;
|
|
515
|
-
return new Promise(function (_resolve, _reject) {
|
|
516
|
-
_this.getRegistrationInfo().then(function (info) {
|
|
517
|
-
_this.http.request('DELETE', _this.apiUrl + 'registration', { body: info }).subscribe(function () {
|
|
518
|
-
window.localStorage.removeItem(_this.registrationStorageKey);
|
|
519
|
-
_resolve(null);
|
|
520
|
-
}, function (error) {
|
|
521
|
-
console.log('Nucleus.Notifications: Failed to remove registration from server.', error);
|
|
522
|
-
_reject(error);
|
|
523
|
-
});
|
|
524
|
-
}).catch(function (error) { return _reject(error); });
|
|
525
|
-
});
|
|
526
|
-
};
|
|
527
|
-
NucleusNotificationsService.prototype.refresh = function (notifyAboutNew) {
|
|
528
|
-
var _this = this;
|
|
529
|
-
if (notifyAboutNew === void 0) { notifyAboutNew = false; }
|
|
530
|
-
this.http.get(this.apiUrl + 'notifications').subscribe(function (res) {
|
|
531
|
-
_this.updateNotifications(res, notifyAboutNew);
|
|
532
|
-
});
|
|
533
|
-
};
|
|
534
|
-
NucleusNotificationsService.prototype.getNotification = function (id) {
|
|
535
|
-
var localNotification = this.notifications.find(function (x) { return x.id === id; });
|
|
536
|
-
if (localNotification) {
|
|
537
|
-
return rxjs.of(localNotification);
|
|
538
|
-
}
|
|
539
|
-
return this.http.get(this.apiUrl + 'notifications/' + id);
|
|
540
|
-
};
|
|
541
|
-
NucleusNotificationsService.prototype.readNotification = function (id) {
|
|
542
|
-
var n = this.notifications.find(function (x) { return x.id === id; });
|
|
543
|
-
if (n && !n.isRead) {
|
|
544
|
-
n.isRead = true;
|
|
545
|
-
this.notifyStateChanged();
|
|
546
|
-
}
|
|
547
|
-
this.http.get(this.apiUrl + 'notifications/read/' + id).subscribe();
|
|
548
|
-
};
|
|
549
|
-
NucleusNotificationsService.prototype.dismissNotification = function (id) {
|
|
550
|
-
this.deleteNotificaton(id);
|
|
551
|
-
this.http.delete(this.apiUrl + 'notifications/' + id).subscribe();
|
|
552
|
-
this.removeDeliveredNotification(id);
|
|
553
|
-
};
|
|
554
|
-
NucleusNotificationsService.prototype.dismissAll = function () {
|
|
555
|
-
this.notifications.splice(0);
|
|
556
|
-
this.notifyStateChanged();
|
|
557
|
-
this.http.delete(this.apiUrl + 'notifications/all').subscribe();
|
|
558
|
-
if (this._platform === 'ios' || this._platform === 'android') {
|
|
559
|
-
pushNotifications.PushNotifications.removeAllDeliveredNotifications();
|
|
560
|
-
}
|
|
561
|
-
else if (this._platform === 'web') {
|
|
562
|
-
// TODO: remove all web push notifications
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
NucleusNotificationsService.prototype.readAll = function () {
|
|
566
|
-
var e_1, _b;
|
|
567
|
-
try {
|
|
568
|
-
for (var _c = __values(this.notifications), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
569
|
-
var n = _d.value;
|
|
570
|
-
n.isRead = true;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
574
|
-
finally {
|
|
575
|
-
try {
|
|
576
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
577
|
-
}
|
|
578
|
-
finally { if (e_1) throw e_1.error; }
|
|
579
|
-
}
|
|
580
|
-
this.notifyStateChanged();
|
|
581
|
-
this.http.get(this.apiUrl + 'notifications/read/all').subscribe();
|
|
582
|
-
};
|
|
583
|
-
NucleusNotificationsService.prototype.getChannelConfig = function (senderId, channelId, language) {
|
|
584
|
-
if (language === void 0) { language = null; }
|
|
585
|
-
return this.http.get(this.apiUrl + ("settings/channel/" + senderId + "/" + channelId + "?language=" + language));
|
|
586
|
-
};
|
|
587
|
-
NucleusNotificationsService.prototype.getChannelConfigsForSender = function (senderId, channelIds, language) {
|
|
588
|
-
if (language === void 0) { language = null; }
|
|
589
|
-
var idsStr = channelIds.map(function (x) { return senderId + ',' + x; }).join(';');
|
|
590
|
-
return this.getChannelConfigsInternal(idsStr, language);
|
|
591
|
-
};
|
|
592
|
-
NucleusNotificationsService.prototype.getChannelConfigs = function (ids, language) {
|
|
593
|
-
if (language === void 0) { language = null; }
|
|
594
|
-
var idsStr = ids.map(function (x) { return x.senderId + ',' + x.channelId; }).join(';');
|
|
595
|
-
return this.getChannelConfigsInternal(idsStr, language);
|
|
596
|
-
};
|
|
597
|
-
NucleusNotificationsService.prototype.setChannelConfig = function (senderId, config) {
|
|
598
|
-
return this.http.post(this.apiUrl + "settings/channel/" + senderId, config);
|
|
599
|
-
};
|
|
600
|
-
NucleusNotificationsService.prototype.setChannelConfigs = function (configs) {
|
|
601
|
-
return this.http.post(this.apiUrl + "settings/channels", configs);
|
|
602
|
-
};
|
|
603
|
-
NucleusNotificationsService.prototype.getChannelConfigsInternal = function (ids, language) {
|
|
604
|
-
return this.http.get(this.apiUrl + "settings/channels?ids=" + ids + "&language=" + language);
|
|
605
|
-
};
|
|
606
|
-
NucleusNotificationsService.prototype.updateNotifications = function (newNotifications, notifyAboutNew) {
|
|
607
|
-
var e_2, _b;
|
|
608
|
-
if (notifyAboutNew === void 0) { notifyAboutNew = false; }
|
|
609
|
-
var stateChanged = false;
|
|
610
|
-
var _loop_1 = function (n) {
|
|
611
|
-
var existing = this_1.notifications.find(function (x) { return x.id === n.id; });
|
|
612
|
-
if (existing) {
|
|
613
|
-
if (existing.isRead !== n.isRead) {
|
|
614
|
-
existing.isRead = n.isRead;
|
|
615
|
-
stateChanged = true;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
var i = 0;
|
|
620
|
-
while (i < this_1.notifications.length && n.dateCreated < this_1.notifications[i].dateCreated) {
|
|
621
|
-
i++;
|
|
622
|
-
}
|
|
623
|
-
this_1.notifications.splice(i, 0, n);
|
|
624
|
-
stateChanged = true;
|
|
625
|
-
if (notifyAboutNew) {
|
|
626
|
-
this_1._newNotifications.next(n);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
var this_1 = this;
|
|
631
|
-
try {
|
|
632
|
-
for (var newNotifications_1 = __values(newNotifications), newNotifications_1_1 = newNotifications_1.next(); !newNotifications_1_1.done; newNotifications_1_1 = newNotifications_1.next()) {
|
|
633
|
-
var n = newNotifications_1_1.value;
|
|
634
|
-
_loop_1(n);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
638
|
-
finally {
|
|
639
|
-
try {
|
|
640
|
-
if (newNotifications_1_1 && !newNotifications_1_1.done && (_b = newNotifications_1.return)) _b.call(newNotifications_1);
|
|
641
|
-
}
|
|
642
|
-
finally { if (e_2) throw e_2.error; }
|
|
643
|
-
}
|
|
644
|
-
var now = Date.now();
|
|
645
|
-
var _loop_2 = function (i) {
|
|
646
|
-
var n = this_2.notifications[i];
|
|
647
|
-
if (new Date(n.expirationDate).getTime() < now || !newNotifications.find(function (x) { return x.id === n.id; })) {
|
|
648
|
-
this_2.notifications.splice(i, 1);
|
|
649
|
-
stateChanged = true;
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
var this_2 = this;
|
|
653
|
-
for (var i = this.notifications.length - 1; i >= 0; i--) {
|
|
654
|
-
_loop_2(i);
|
|
655
|
-
}
|
|
656
|
-
if (stateChanged) {
|
|
657
|
-
this.notifyStateChanged();
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
NucleusNotificationsService.prototype.saveToStorage = function () {
|
|
661
|
-
var str = JSON.stringify(this.notifications);
|
|
662
|
-
window.localStorage.setItem(this.notificationsStorageKey, str);
|
|
663
|
-
};
|
|
664
|
-
NucleusNotificationsService.prototype.loadFromStorage = function () {
|
|
665
|
-
try {
|
|
666
|
-
var str = window.localStorage.getItem(this.notificationsStorageKey);
|
|
667
|
-
if (str) {
|
|
668
|
-
var notifications = JSON.parse(str);
|
|
669
|
-
this.notifications = notifications.filter(function (x) { return !!x; });
|
|
670
|
-
// precaution for notification.isRead of undefined error
|
|
671
|
-
this.notifyStateChanged(false);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
catch (_a) { }
|
|
675
|
-
};
|
|
676
|
-
NucleusNotificationsService.prototype.handleNotificationEvent = function (id, eventType) {
|
|
677
|
-
var _this = this;
|
|
678
|
-
if (eventType.startsWith('new') || eventType === 'updated') { // we are handling new and newSilent
|
|
679
|
-
this.getNotification(id).subscribe(function (n) {
|
|
680
|
-
if (eventType.startsWith('new') && !n.isRead) {
|
|
681
|
-
_this._newNotifications.next(n);
|
|
682
|
-
}
|
|
683
|
-
var existing = _this.notifications.find(function (x) { return x.id === n.id; });
|
|
684
|
-
if (existing) {
|
|
685
|
-
existing.isRead = n.isRead;
|
|
686
|
-
}
|
|
687
|
-
else {
|
|
688
|
-
_this.notifications.splice(0, 0, n);
|
|
689
|
-
}
|
|
690
|
-
_this.notifyStateChanged();
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
else if (eventType === 'deleted') {
|
|
694
|
-
this.deleteNotificaton(id);
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
this.refresh();
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
NucleusNotificationsService.prototype.deleteNotificaton = function (id) {
|
|
701
|
-
var i = this.notifications.findIndex(function (x) { return x.id === id; });
|
|
702
|
-
if (i >= 0) {
|
|
703
|
-
this.notifications.splice(i, 1);
|
|
704
|
-
this.notifyStateChanged();
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
NucleusNotificationsService.prototype.notifyStateChanged = function (persistState) {
|
|
708
|
-
if (persistState === void 0) { persistState = true; }
|
|
709
|
-
if (persistState) {
|
|
710
|
-
this.saveToStorage();
|
|
711
|
-
}
|
|
712
|
-
this._stateChangesSubject.next();
|
|
713
|
-
};
|
|
714
|
-
NucleusNotificationsService.prototype.handleNotificationAction = function (notificationAction) {
|
|
715
|
-
var arr = notificationAction.split(':');
|
|
716
|
-
var notificationClick = {
|
|
717
|
-
id: arr[0],
|
|
718
|
-
type: arr[1],
|
|
719
|
-
routerLink: arr[2]
|
|
720
|
-
};
|
|
721
|
-
var validNotificationClickTypes = ['default', 'deeplink'];
|
|
722
|
-
if (validNotificationClickTypes.includes(notificationClick.type)) {
|
|
723
|
-
this._clicksSubject.next(notificationClick);
|
|
724
|
-
}
|
|
725
|
-
else {
|
|
726
|
-
console.error("Nucleus.Notifications: Unknown notification action: '" + notificationAction + "'.");
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
NucleusNotificationsService.prototype.removeDeliveredNotification = function (id) {
|
|
730
|
-
var _this = this;
|
|
731
|
-
if (this._platform === 'ios' || this._platform === 'android') {
|
|
732
|
-
pushNotifications.PushNotifications.getDeliveredNotifications().then(function (list) {
|
|
733
|
-
var toRemove = list.notifications.filter(function (n) {
|
|
734
|
-
var data = _this.getNotificationPayloadData(n);
|
|
735
|
-
return (data.notificationId === id);
|
|
736
|
-
});
|
|
737
|
-
// TODO: On Android this does not currently work because notificationID is not set.
|
|
738
|
-
// This my solve the issue: https://github.com/ionic-team/capacitor/pull/3523
|
|
739
|
-
pushNotifications.PushNotifications.removeDeliveredNotifications({
|
|
740
|
-
notifications: toRemove
|
|
741
|
-
});
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
else if (this._platform === 'web') {
|
|
745
|
-
// TODO: remove web push notification
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
NucleusNotificationsService.prototype.getNotificationPayloadData = function (pushNotification) {
|
|
749
|
-
return (this._platform === 'ios') ? pushNotification.data.data : pushNotification.data;
|
|
750
|
-
};
|
|
751
|
-
NucleusNotificationsService.prototype.registerCapacitorEvents = function () {
|
|
752
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
753
|
-
var _this = this;
|
|
754
|
-
return __generator(this, function (_b) {
|
|
755
|
-
switch (_b.label) {
|
|
756
|
-
case 0: return [4 /*yield*/, pushNotifications.PushNotifications.addListener('pushNotificationReceived', function (n) {
|
|
757
|
-
var data = _this.getNotificationPayloadData(n);
|
|
758
|
-
console.log('Nucleus.Notifications: Received capacitor push event: ' + data.eventType, n);
|
|
759
|
-
_this.handleNotificationEvent(data.notificationId, data.eventType);
|
|
760
|
-
})];
|
|
761
|
-
case 1:
|
|
762
|
-
_b.sent();
|
|
763
|
-
return [4 /*yield*/, pushNotifications.PushNotifications.addListener('pushNotificationActionPerformed', function (a) {
|
|
764
|
-
var action = a.notification.data.notificationAction;
|
|
765
|
-
if (_this._platform === 'ios') {
|
|
766
|
-
action = a.notification.data.data.notificationAction;
|
|
767
|
-
}
|
|
768
|
-
console.log('Nucleus.Notifications: Received capacitor action event', action);
|
|
769
|
-
_this.handleNotificationAction(action);
|
|
770
|
-
})];
|
|
771
|
-
case 2:
|
|
772
|
-
_b.sent();
|
|
773
|
-
return [2 /*return*/];
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
});
|
|
777
|
-
};
|
|
778
|
-
NucleusNotificationsService.prototype.registerWebPushEvents = function () {
|
|
779
|
-
var _this = this;
|
|
780
|
-
this.swPush.messages.subscribe(function (n) {
|
|
781
|
-
var data = n.data;
|
|
782
|
-
console.log('Nucleus.Notifications: Received WebPush event: ' + data.eventType, n);
|
|
783
|
-
_this.handleNotificationEvent(data.notificationId, data.eventType);
|
|
784
|
-
});
|
|
785
|
-
this.swPush.notificationClicks.subscribe(function (action) {
|
|
786
|
-
console.log('Nucleus.Notifications: Received WebPush action event', action);
|
|
787
|
-
var tag = action.notification.tag;
|
|
788
|
-
_this.handleNotificationAction(tag);
|
|
789
|
-
});
|
|
790
|
-
};
|
|
791
|
-
NucleusNotificationsService.prototype.getRegistrationInfo = function () {
|
|
792
|
-
var _this = this;
|
|
793
|
-
return new Promise(function (_resolve, _reject) {
|
|
794
|
-
var registrationId = window.localStorage.getItem(_this.registrationStorageKey);
|
|
795
|
-
if (_this._platform === 'android' || _this._platform === 'ios') {
|
|
796
|
-
// capacitor platform
|
|
797
|
-
var listener_1 = pushNotifications.PushNotifications.addListener('registration', function (token) {
|
|
798
|
-
listener_1.remove();
|
|
799
|
-
_resolve({ id: registrationId, token: token.value, platform: _this._platform });
|
|
800
|
-
});
|
|
801
|
-
pushNotifications.PushNotifications.register().catch(function (error) { return _reject('Could not register for notifications:' + error); });
|
|
802
|
-
}
|
|
803
|
-
else if (_this._platform === 'web') {
|
|
804
|
-
// Web Push API
|
|
805
|
-
_this.http.get(_this.apiUrl + 'registration/webkey').subscribe(function (key) {
|
|
806
|
-
_this.getWebPushSubscription(key.publicKey).then(function (subscription) {
|
|
807
|
-
var t = JSON.stringify(subscription.toJSON());
|
|
808
|
-
_resolve({ id: registrationId, token: t, platform: 'web' });
|
|
809
|
-
});
|
|
810
|
-
}, function (error) { return _reject(error); });
|
|
811
|
-
}
|
|
812
|
-
else {
|
|
813
|
-
_reject("Nucleus.Notifications: Platform is not supported");
|
|
814
|
-
}
|
|
815
|
-
});
|
|
816
|
-
};
|
|
817
|
-
NucleusNotificationsService.prototype.getWebPushSubscription = function (publicKey) {
|
|
818
|
-
var _this = this;
|
|
819
|
-
return new Promise(function (_resolve, _reject) {
|
|
820
|
-
_this.swPush.subscription.subscribe(function (subscription) {
|
|
821
|
-
if (subscription != null) {
|
|
822
|
-
_resolve(subscription);
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
_this.swPush.requestSubscription({ serverPublicKey: publicKey }).then(function (s) { return _resolve(s); }).catch(function (e) { return _reject(e); });
|
|
826
|
-
}
|
|
827
|
-
}, function (error) {
|
|
828
|
-
console.error('Nucleus.Notifications: Cannot get web push subscription', error);
|
|
829
|
-
_reject(error);
|
|
830
|
-
});
|
|
831
|
-
});
|
|
832
|
-
};
|
|
833
|
-
return NucleusNotificationsService;
|
|
834
|
-
}());
|
|
835
|
-
NucleusNotificationsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsService, deps: [{ token: i1__namespace.HttpClient }, { token: i2__namespace.SwPush }, { token: i3__namespace.NucleusAppService }, { token: NucleusNotificationsConfig }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
836
|
-
NucleusNotificationsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsService, providedIn: 'root' });
|
|
837
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsService, decorators: [{
|
|
838
|
-
type: i0.Injectable,
|
|
839
|
-
args: [{
|
|
840
|
-
providedIn: 'root'
|
|
841
|
-
}]
|
|
842
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.HttpClient }, { type: i2__namespace.SwPush }, { type: i3__namespace.NucleusAppService }, { type: NucleusNotificationsConfig }]; } });
|
|
843
|
-
|
|
844
|
-
var NucleusNotificationsModule = /** @class */ (function () {
|
|
845
|
-
function NucleusNotificationsModule() {
|
|
846
|
-
}
|
|
847
|
-
NucleusNotificationsModule.forRoot = function (config) {
|
|
848
|
-
return {
|
|
849
|
-
ngModule: NucleusNotificationsModule,
|
|
850
|
-
providers: [
|
|
851
|
-
{ provide: NucleusNotificationsConfig, useValue: config }
|
|
852
|
-
]
|
|
853
|
-
};
|
|
854
|
-
};
|
|
855
|
-
return NucleusNotificationsModule;
|
|
856
|
-
}());
|
|
857
|
-
NucleusNotificationsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
858
|
-
NucleusNotificationsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsModule });
|
|
859
|
-
NucleusNotificationsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsModule, imports: [[]] });
|
|
860
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.3", ngImport: i0__namespace, type: NucleusNotificationsModule, decorators: [{
|
|
861
|
-
type: i0.NgModule,
|
|
862
|
-
args: [{
|
|
863
|
-
declarations: [],
|
|
864
|
-
imports: [],
|
|
865
|
-
exports: []
|
|
866
|
-
}]
|
|
867
|
-
}] });
|
|
868
|
-
|
|
869
|
-
/*
|
|
870
|
-
* Public API Surface of nucleus-notifications
|
|
871
|
-
*/
|
|
872
|
-
|
|
873
|
-
/**
|
|
874
|
-
* Generated bundle index. Do not edit.
|
|
875
|
-
*/
|
|
876
|
-
|
|
877
|
-
exports.Identity = Identity;
|
|
878
|
-
exports.Notification = Notification;
|
|
879
|
-
exports.NotificationClick = NotificationClick;
|
|
880
|
-
exports.NotificationData = NotificationData;
|
|
881
|
-
exports.NucleusNotificationsConfig = NucleusNotificationsConfig;
|
|
882
|
-
exports.NucleusNotificationsModule = NucleusNotificationsModule;
|
|
883
|
-
exports.NucleusNotificationsService = NucleusNotificationsService;
|
|
884
|
-
exports.PayloadData = PayloadData;
|
|
885
|
-
exports.Recipient = Recipient;
|
|
886
|
-
exports.Registration = Registration;
|
|
887
|
-
exports.RegistrationResult = RegistrationResult;
|
|
888
|
-
exports.UserChannelConfig = UserChannelConfig;
|
|
889
|
-
exports.WebKey = WebKey;
|
|
890
|
-
|
|
891
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
892
|
-
|
|
893
|
-
})));
|
|
894
|
-
//# sourceMappingURL=kolektor-nucleus-notifications.umd.js.map
|