@firebase/messaging 0.11.0 → 0.12.0
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/CHANGELOG.md +14 -0
- package/dist/esm/index.esm.js +78 -82
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/index.esm2017.js +42 -46
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/testing/fakes/service-worker.d.ts +0 -1
- package/dist/esm/src/util/sw-types.d.ts +1 -1
- package/dist/index.cjs.js +78 -82
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.sw.cjs +64 -67
- package/dist/index.sw.cjs.map +1 -1
- package/dist/index.sw.esm2017.js +34 -37
- package/dist/index.sw.esm2017.js.map +1 -1
- package/dist/src/testing/fakes/service-worker.d.ts +0 -1
- package/dist/src/util/sw-types.d.ts +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @firebase/messaging
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1625f7a95`](https://github.com/firebase/firebase-js-sdk/commit/1625f7a95cc3ffb666845db0a8044329be74b5be) [#6799](https://github.com/firebase/firebase-js-sdk/pull/6799) - Update TypeScript version to 4.7.4.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`c20633ed3`](https://github.com/firebase/firebase-js-sdk/commit/c20633ed35056cbadc9d65d9ceddf4e28d1ea666), [`1625f7a95`](https://github.com/firebase/firebase-js-sdk/commit/1625f7a95cc3ffb666845db0a8044329be74b5be)]:
|
|
12
|
+
- @firebase/util@1.8.0
|
|
13
|
+
- @firebase/component@0.6.0
|
|
14
|
+
- @firebase/installations@0.6.0
|
|
15
|
+
- @firebase/messaging-interop-types@0.2.0
|
|
16
|
+
|
|
3
17
|
## 0.11.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -74,7 +74,7 @@ var MessageType;
|
|
|
74
74
|
*/
|
|
75
75
|
function arrayToBase64(array) {
|
|
76
76
|
var uint8Array = new Uint8Array(array);
|
|
77
|
-
var base64String = btoa(String.fromCharCode.apply(String, __spreadArray([], __read(uint8Array))));
|
|
77
|
+
var base64String = btoa(String.fromCharCode.apply(String, __spreadArray([], __read(uint8Array), false)));
|
|
78
78
|
return base64String.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
|
79
79
|
}
|
|
80
80
|
function base64ToArray(base64String) {
|
|
@@ -389,26 +389,26 @@ function getKey(_a) {
|
|
|
389
389
|
*/
|
|
390
390
|
var _a;
|
|
391
391
|
var ERROR_MAP = (_a = {},
|
|
392
|
-
_a["missing-app-config-values" /* MISSING_APP_CONFIG_VALUES */] = 'Missing App configuration value: "{$valueName}"',
|
|
393
|
-
_a["only-available-in-window" /* AVAILABLE_IN_WINDOW */] = 'This method is available in a Window context.',
|
|
394
|
-
_a["only-available-in-sw" /* AVAILABLE_IN_SW */] = 'This method is available in a service worker context.',
|
|
395
|
-
_a["permission-default" /* PERMISSION_DEFAULT */] = 'The notification permission was not granted and dismissed instead.',
|
|
396
|
-
_a["permission-blocked" /* PERMISSION_BLOCKED */] = 'The notification permission was not granted and blocked instead.',
|
|
397
|
-
_a["unsupported-browser" /* UNSUPPORTED_BROWSER */] = "This browser doesn't support the API's required to use the Firebase SDK.",
|
|
398
|
-
_a["indexed-db-unsupported" /* INDEXED_DB_UNSUPPORTED */] = "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
|
|
399
|
-
_a["failed-service-worker-registration" /* FAILED_DEFAULT_REGISTRATION */] = 'We are unable to register the default service worker. {$browserErrorMessage}',
|
|
400
|
-
_a["token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */] = 'A problem occurred while subscribing the user to FCM: {$errorInfo}',
|
|
401
|
-
_a["token-subscribe-no-token" /* TOKEN_SUBSCRIBE_NO_TOKEN */] = 'FCM returned no token when subscribing the user to push.',
|
|
402
|
-
_a["token-unsubscribe-failed" /* TOKEN_UNSUBSCRIBE_FAILED */] = 'A problem occurred while unsubscribing the ' +
|
|
392
|
+
_a["missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */] = 'Missing App configuration value: "{$valueName}"',
|
|
393
|
+
_a["only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */] = 'This method is available in a Window context.',
|
|
394
|
+
_a["only-available-in-sw" /* ErrorCode.AVAILABLE_IN_SW */] = 'This method is available in a service worker context.',
|
|
395
|
+
_a["permission-default" /* ErrorCode.PERMISSION_DEFAULT */] = 'The notification permission was not granted and dismissed instead.',
|
|
396
|
+
_a["permission-blocked" /* ErrorCode.PERMISSION_BLOCKED */] = 'The notification permission was not granted and blocked instead.',
|
|
397
|
+
_a["unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */] = "This browser doesn't support the API's required to use the Firebase SDK.",
|
|
398
|
+
_a["indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */] = "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
|
|
399
|
+
_a["failed-service-worker-registration" /* ErrorCode.FAILED_DEFAULT_REGISTRATION */] = 'We are unable to register the default service worker. {$browserErrorMessage}',
|
|
400
|
+
_a["token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */] = 'A problem occurred while subscribing the user to FCM: {$errorInfo}',
|
|
401
|
+
_a["token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */] = 'FCM returned no token when subscribing the user to push.',
|
|
402
|
+
_a["token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */] = 'A problem occurred while unsubscribing the ' +
|
|
403
403
|
'user from FCM: {$errorInfo}',
|
|
404
|
-
_a["token-update-failed" /* TOKEN_UPDATE_FAILED */] = 'A problem occurred while updating the user from FCM: {$errorInfo}',
|
|
405
|
-
_a["token-update-no-token" /* TOKEN_UPDATE_NO_TOKEN */] = 'FCM returned no token when updating the user to push.',
|
|
406
|
-
_a["use-sw-after-get-token" /* USE_SW_AFTER_GET_TOKEN */] = 'The useServiceWorker() method may only be called once and must be ' +
|
|
404
|
+
_a["token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */] = 'A problem occurred while updating the user from FCM: {$errorInfo}',
|
|
405
|
+
_a["token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */] = 'FCM returned no token when updating the user to push.',
|
|
406
|
+
_a["use-sw-after-get-token" /* ErrorCode.USE_SW_AFTER_GET_TOKEN */] = 'The useServiceWorker() method may only be called once and must be ' +
|
|
407
407
|
'called before calling getToken() to ensure your service worker is used.',
|
|
408
|
-
_a["invalid-sw-registration" /* INVALID_SW_REGISTRATION */] = 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',
|
|
409
|
-
_a["invalid-bg-handler" /* INVALID_BG_HANDLER */] = 'The input to setBackgroundMessageHandler() must be a function.',
|
|
410
|
-
_a["invalid-vapid-key" /* INVALID_VAPID_KEY */] = 'The public VAPID key must be a string.',
|
|
411
|
-
_a["use-vapid-key-after-get-token" /* USE_VAPID_KEY_AFTER_GET_TOKEN */] = 'The usePublicVapidKey() method may only be called once and must be ' +
|
|
408
|
+
_a["invalid-sw-registration" /* ErrorCode.INVALID_SW_REGISTRATION */] = 'The input to useServiceWorker() must be a ServiceWorkerRegistration.',
|
|
409
|
+
_a["invalid-bg-handler" /* ErrorCode.INVALID_BG_HANDLER */] = 'The input to setBackgroundMessageHandler() must be a function.',
|
|
410
|
+
_a["invalid-vapid-key" /* ErrorCode.INVALID_VAPID_KEY */] = 'The public VAPID key must be a string.',
|
|
411
|
+
_a["use-vapid-key-after-get-token" /* ErrorCode.USE_VAPID_KEY_AFTER_GET_TOKEN */] = 'The usePublicVapidKey() method may only be called once and must be ' +
|
|
412
412
|
'called before calling getToken() to ensure your VAPID key is used.',
|
|
413
413
|
_a);
|
|
414
414
|
var ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
|
|
@@ -430,44 +430,43 @@ var ERROR_FACTORY = new ErrorFactory('messaging', 'Messaging', ERROR_MAP);
|
|
|
430
430
|
* limitations under the License.
|
|
431
431
|
*/
|
|
432
432
|
function requestGetToken(firebaseDependencies, subscriptionOptions) {
|
|
433
|
-
var _a;
|
|
434
433
|
return __awaiter(this, void 0, void 0, function () {
|
|
435
434
|
var headers, body, subscribeOptions, responseData, response, err_1, message;
|
|
436
|
-
return __generator(this, function (
|
|
437
|
-
switch (
|
|
435
|
+
return __generator(this, function (_a) {
|
|
436
|
+
switch (_a.label) {
|
|
438
437
|
case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];
|
|
439
438
|
case 1:
|
|
440
|
-
headers =
|
|
439
|
+
headers = _a.sent();
|
|
441
440
|
body = getBody(subscriptionOptions);
|
|
442
441
|
subscribeOptions = {
|
|
443
442
|
method: 'POST',
|
|
444
443
|
headers: headers,
|
|
445
444
|
body: JSON.stringify(body)
|
|
446
445
|
};
|
|
447
|
-
|
|
446
|
+
_a.label = 2;
|
|
448
447
|
case 2:
|
|
449
|
-
|
|
448
|
+
_a.trys.push([2, 5, , 6]);
|
|
450
449
|
return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig), subscribeOptions)];
|
|
451
450
|
case 3:
|
|
452
|
-
response =
|
|
451
|
+
response = _a.sent();
|
|
453
452
|
return [4 /*yield*/, response.json()];
|
|
454
453
|
case 4:
|
|
455
|
-
responseData =
|
|
454
|
+
responseData = _a.sent();
|
|
456
455
|
return [3 /*break*/, 6];
|
|
457
456
|
case 5:
|
|
458
|
-
err_1 =
|
|
459
|
-
throw ERROR_FACTORY.create("token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */, {
|
|
460
|
-
errorInfo:
|
|
457
|
+
err_1 = _a.sent();
|
|
458
|
+
throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
|
|
459
|
+
errorInfo: err_1 === null || err_1 === void 0 ? void 0 : err_1.toString()
|
|
461
460
|
});
|
|
462
461
|
case 6:
|
|
463
462
|
if (responseData.error) {
|
|
464
463
|
message = responseData.error.message;
|
|
465
|
-
throw ERROR_FACTORY.create("token-subscribe-failed" /* TOKEN_SUBSCRIBE_FAILED */, {
|
|
464
|
+
throw ERROR_FACTORY.create("token-subscribe-failed" /* ErrorCode.TOKEN_SUBSCRIBE_FAILED */, {
|
|
466
465
|
errorInfo: message
|
|
467
466
|
});
|
|
468
467
|
}
|
|
469
468
|
if (!responseData.token) {
|
|
470
|
-
throw ERROR_FACTORY.create("token-subscribe-no-token" /* TOKEN_SUBSCRIBE_NO_TOKEN */);
|
|
469
|
+
throw ERROR_FACTORY.create("token-subscribe-no-token" /* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */);
|
|
471
470
|
}
|
|
472
471
|
return [2 /*return*/, responseData.token];
|
|
473
472
|
}
|
|
@@ -475,44 +474,43 @@ function requestGetToken(firebaseDependencies, subscriptionOptions) {
|
|
|
475
474
|
});
|
|
476
475
|
}
|
|
477
476
|
function requestUpdateToken(firebaseDependencies, tokenDetails) {
|
|
478
|
-
var _a;
|
|
479
477
|
return __awaiter(this, void 0, void 0, function () {
|
|
480
478
|
var headers, body, updateOptions, responseData, response, err_2, message;
|
|
481
|
-
return __generator(this, function (
|
|
482
|
-
switch (
|
|
479
|
+
return __generator(this, function (_a) {
|
|
480
|
+
switch (_a.label) {
|
|
483
481
|
case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];
|
|
484
482
|
case 1:
|
|
485
|
-
headers =
|
|
483
|
+
headers = _a.sent();
|
|
486
484
|
body = getBody(tokenDetails.subscriptionOptions);
|
|
487
485
|
updateOptions = {
|
|
488
486
|
method: 'PATCH',
|
|
489
487
|
headers: headers,
|
|
490
488
|
body: JSON.stringify(body)
|
|
491
489
|
};
|
|
492
|
-
|
|
490
|
+
_a.label = 2;
|
|
493
491
|
case 2:
|
|
494
|
-
|
|
495
|
-
return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig)
|
|
492
|
+
_a.trys.push([2, 5, , 6]);
|
|
493
|
+
return [4 /*yield*/, fetch("".concat(getEndpoint(firebaseDependencies.appConfig), "/").concat(tokenDetails.token), updateOptions)];
|
|
496
494
|
case 3:
|
|
497
|
-
response =
|
|
495
|
+
response = _a.sent();
|
|
498
496
|
return [4 /*yield*/, response.json()];
|
|
499
497
|
case 4:
|
|
500
|
-
responseData =
|
|
498
|
+
responseData = _a.sent();
|
|
501
499
|
return [3 /*break*/, 6];
|
|
502
500
|
case 5:
|
|
503
|
-
err_2 =
|
|
504
|
-
throw ERROR_FACTORY.create("token-update-failed" /* TOKEN_UPDATE_FAILED */, {
|
|
505
|
-
errorInfo:
|
|
501
|
+
err_2 = _a.sent();
|
|
502
|
+
throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
|
|
503
|
+
errorInfo: err_2 === null || err_2 === void 0 ? void 0 : err_2.toString()
|
|
506
504
|
});
|
|
507
505
|
case 6:
|
|
508
506
|
if (responseData.error) {
|
|
509
507
|
message = responseData.error.message;
|
|
510
|
-
throw ERROR_FACTORY.create("token-update-failed" /* TOKEN_UPDATE_FAILED */, {
|
|
508
|
+
throw ERROR_FACTORY.create("token-update-failed" /* ErrorCode.TOKEN_UPDATE_FAILED */, {
|
|
511
509
|
errorInfo: message
|
|
512
510
|
});
|
|
513
511
|
}
|
|
514
512
|
if (!responseData.token) {
|
|
515
|
-
throw ERROR_FACTORY.create("token-update-no-token" /* TOKEN_UPDATE_NO_TOKEN */);
|
|
513
|
+
throw ERROR_FACTORY.create("token-update-no-token" /* ErrorCode.TOKEN_UPDATE_NO_TOKEN */);
|
|
516
514
|
}
|
|
517
515
|
return [2 /*return*/, responseData.token];
|
|
518
516
|
}
|
|
@@ -520,38 +518,37 @@ function requestUpdateToken(firebaseDependencies, tokenDetails) {
|
|
|
520
518
|
});
|
|
521
519
|
}
|
|
522
520
|
function requestDeleteToken(firebaseDependencies, token) {
|
|
523
|
-
var _a;
|
|
524
521
|
return __awaiter(this, void 0, void 0, function () {
|
|
525
522
|
var headers, unsubscribeOptions, response, responseData, message, err_3;
|
|
526
|
-
return __generator(this, function (
|
|
527
|
-
switch (
|
|
523
|
+
return __generator(this, function (_a) {
|
|
524
|
+
switch (_a.label) {
|
|
528
525
|
case 0: return [4 /*yield*/, getHeaders(firebaseDependencies)];
|
|
529
526
|
case 1:
|
|
530
|
-
headers =
|
|
527
|
+
headers = _a.sent();
|
|
531
528
|
unsubscribeOptions = {
|
|
532
529
|
method: 'DELETE',
|
|
533
530
|
headers: headers
|
|
534
531
|
};
|
|
535
|
-
|
|
532
|
+
_a.label = 2;
|
|
536
533
|
case 2:
|
|
537
|
-
|
|
538
|
-
return [4 /*yield*/, fetch(getEndpoint(firebaseDependencies.appConfig)
|
|
534
|
+
_a.trys.push([2, 5, , 6]);
|
|
535
|
+
return [4 /*yield*/, fetch("".concat(getEndpoint(firebaseDependencies.appConfig), "/").concat(token), unsubscribeOptions)];
|
|
539
536
|
case 3:
|
|
540
|
-
response =
|
|
537
|
+
response = _a.sent();
|
|
541
538
|
return [4 /*yield*/, response.json()];
|
|
542
539
|
case 4:
|
|
543
|
-
responseData =
|
|
540
|
+
responseData = _a.sent();
|
|
544
541
|
if (responseData.error) {
|
|
545
542
|
message = responseData.error.message;
|
|
546
|
-
throw ERROR_FACTORY.create("token-unsubscribe-failed" /* TOKEN_UNSUBSCRIBE_FAILED */, {
|
|
543
|
+
throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
|
|
547
544
|
errorInfo: message
|
|
548
545
|
});
|
|
549
546
|
}
|
|
550
547
|
return [3 /*break*/, 6];
|
|
551
548
|
case 5:
|
|
552
|
-
err_3 =
|
|
553
|
-
throw ERROR_FACTORY.create("token-unsubscribe-failed" /* TOKEN_UNSUBSCRIBE_FAILED */, {
|
|
554
|
-
errorInfo:
|
|
549
|
+
err_3 = _a.sent();
|
|
550
|
+
throw ERROR_FACTORY.create("token-unsubscribe-failed" /* ErrorCode.TOKEN_UNSUBSCRIBE_FAILED */, {
|
|
551
|
+
errorInfo: err_3 === null || err_3 === void 0 ? void 0 : err_3.toString()
|
|
555
552
|
});
|
|
556
553
|
case 6: return [2 /*return*/];
|
|
557
554
|
}
|
|
@@ -560,7 +557,7 @@ function requestDeleteToken(firebaseDependencies, token) {
|
|
|
560
557
|
}
|
|
561
558
|
function getEndpoint(_a) {
|
|
562
559
|
var projectId = _a.projectId;
|
|
563
|
-
return ENDPOINT
|
|
560
|
+
return "".concat(ENDPOINT, "/projects/").concat(projectId, "/registrations");
|
|
564
561
|
}
|
|
565
562
|
function getHeaders(_a) {
|
|
566
563
|
var appConfig = _a.appConfig, installations = _a.installations;
|
|
@@ -575,7 +572,7 @@ function getHeaders(_a) {
|
|
|
575
572
|
'Content-Type': 'application/json',
|
|
576
573
|
Accept: 'application/json',
|
|
577
574
|
'x-goog-api-key': appConfig.apiKey,
|
|
578
|
-
'x-goog-firebase-installations-auth': "FIS "
|
|
575
|
+
'x-goog-firebase-installations-auth': "FIS ".concat(authToken)
|
|
579
576
|
})];
|
|
580
577
|
}
|
|
581
578
|
});
|
|
@@ -964,7 +961,7 @@ function extractAppConfig(app) {
|
|
|
964
961
|
};
|
|
965
962
|
}
|
|
966
963
|
function getMissingValueError(valueName) {
|
|
967
|
-
return ERROR_FACTORY.create("missing-app-config-values" /* MISSING_APP_CONFIG_VALUES */, {
|
|
964
|
+
return ERROR_FACTORY.create("missing-app-config-values" /* ErrorCode.MISSING_APP_CONFIG_VALUES */, {
|
|
968
965
|
valueName: valueName
|
|
969
966
|
});
|
|
970
967
|
}
|
|
@@ -1024,19 +1021,18 @@ var MessagingService = /** @class */ (function () {
|
|
|
1024
1021
|
* limitations under the License.
|
|
1025
1022
|
*/
|
|
1026
1023
|
function registerDefaultSw(messaging) {
|
|
1027
|
-
var _a;
|
|
1028
1024
|
return __awaiter(this, void 0, void 0, function () {
|
|
1029
|
-
var
|
|
1030
|
-
return __generator(this, function (
|
|
1031
|
-
switch (
|
|
1025
|
+
var _a, e_1;
|
|
1026
|
+
return __generator(this, function (_b) {
|
|
1027
|
+
switch (_b.label) {
|
|
1032
1028
|
case 0:
|
|
1033
|
-
|
|
1034
|
-
|
|
1029
|
+
_b.trys.push([0, 2, , 3]);
|
|
1030
|
+
_a = messaging;
|
|
1035
1031
|
return [4 /*yield*/, navigator.serviceWorker.register(DEFAULT_SW_PATH, {
|
|
1036
1032
|
scope: DEFAULT_SW_SCOPE
|
|
1037
1033
|
})];
|
|
1038
1034
|
case 1:
|
|
1039
|
-
|
|
1035
|
+
_a.swRegistration = _b.sent();
|
|
1040
1036
|
// The timing when browser updates sw when sw has an update is unreliable from experiment. It
|
|
1041
1037
|
// leads to version conflict when the SDK upgrades to a newer version in the main page, but sw
|
|
1042
1038
|
// is stuck with the old version. For example,
|
|
@@ -1047,9 +1043,9 @@ function registerDefaultSw(messaging) {
|
|
|
1047
1043
|
});
|
|
1048
1044
|
return [3 /*break*/, 3];
|
|
1049
1045
|
case 2:
|
|
1050
|
-
e_1 =
|
|
1051
|
-
throw ERROR_FACTORY.create("failed-service-worker-registration" /* FAILED_DEFAULT_REGISTRATION */, {
|
|
1052
|
-
browserErrorMessage:
|
|
1046
|
+
e_1 = _b.sent();
|
|
1047
|
+
throw ERROR_FACTORY.create("failed-service-worker-registration" /* ErrorCode.FAILED_DEFAULT_REGISTRATION */, {
|
|
1048
|
+
browserErrorMessage: e_1 === null || e_1 === void 0 ? void 0 : e_1.message
|
|
1053
1049
|
});
|
|
1054
1050
|
case 3: return [2 /*return*/];
|
|
1055
1051
|
}
|
|
@@ -1088,7 +1084,7 @@ function updateSwReg(messaging, swRegistration) {
|
|
|
1088
1084
|
return [2 /*return*/];
|
|
1089
1085
|
}
|
|
1090
1086
|
if (!(swRegistration instanceof ServiceWorkerRegistration)) {
|
|
1091
|
-
throw ERROR_FACTORY.create("invalid-sw-registration" /* INVALID_SW_REGISTRATION */);
|
|
1087
|
+
throw ERROR_FACTORY.create("invalid-sw-registration" /* ErrorCode.INVALID_SW_REGISTRATION */);
|
|
1092
1088
|
}
|
|
1093
1089
|
messaging.swRegistration = swRegistration;
|
|
1094
1090
|
return [2 /*return*/];
|
|
@@ -1149,7 +1145,7 @@ function getToken$1(messaging, options) {
|
|
|
1149
1145
|
switch (_a.label) {
|
|
1150
1146
|
case 0:
|
|
1151
1147
|
if (!navigator) {
|
|
1152
|
-
throw ERROR_FACTORY.create("only-available-in-window" /* AVAILABLE_IN_WINDOW */);
|
|
1148
|
+
throw ERROR_FACTORY.create("only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */);
|
|
1153
1149
|
}
|
|
1154
1150
|
if (!(Notification.permission === 'default')) return [3 /*break*/, 2];
|
|
1155
1151
|
return [4 /*yield*/, Notification.requestPermission()];
|
|
@@ -1158,7 +1154,7 @@ function getToken$1(messaging, options) {
|
|
|
1158
1154
|
_a.label = 2;
|
|
1159
1155
|
case 2:
|
|
1160
1156
|
if (Notification.permission !== 'granted') {
|
|
1161
|
-
throw ERROR_FACTORY.create("permission-blocked" /* PERMISSION_BLOCKED */);
|
|
1157
|
+
throw ERROR_FACTORY.create("permission-blocked" /* ErrorCode.PERMISSION_BLOCKED */);
|
|
1162
1158
|
}
|
|
1163
1159
|
return [4 /*yield*/, updateVapidKey(messaging, options === null || options === void 0 ? void 0 : options.vapidKey)];
|
|
1164
1160
|
case 3:
|
|
@@ -1271,7 +1267,7 @@ function messageEventListener(messaging, event) {
|
|
|
1271
1267
|
}
|
|
1272
1268
|
|
|
1273
1269
|
var name = "@firebase/messaging";
|
|
1274
|
-
var version = "0.
|
|
1270
|
+
var version = "0.12.0";
|
|
1275
1271
|
|
|
1276
1272
|
/**
|
|
1277
1273
|
* @license
|
|
@@ -1306,8 +1302,8 @@ var WindowMessagingInternalFactory = function (container) {
|
|
|
1306
1302
|
return messagingInternal;
|
|
1307
1303
|
};
|
|
1308
1304
|
function registerMessagingInWindow() {
|
|
1309
|
-
_registerComponent(new Component('messaging', WindowMessagingFactory, "PUBLIC" /* PUBLIC */));
|
|
1310
|
-
_registerComponent(new Component('messaging-internal', WindowMessagingInternalFactory, "PRIVATE" /* PRIVATE */));
|
|
1305
|
+
_registerComponent(new Component('messaging', WindowMessagingFactory, "PUBLIC" /* ComponentType.PUBLIC */));
|
|
1306
|
+
_registerComponent(new Component('messaging-internal', WindowMessagingInternalFactory, "PRIVATE" /* ComponentType.PRIVATE */));
|
|
1311
1307
|
registerVersion(name, version);
|
|
1312
1308
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
1313
1309
|
registerVersion(name, version, 'esm5');
|
|
@@ -1392,7 +1388,7 @@ function deleteToken$1(messaging) {
|
|
|
1392
1388
|
switch (_a.label) {
|
|
1393
1389
|
case 0:
|
|
1394
1390
|
if (!navigator) {
|
|
1395
|
-
throw ERROR_FACTORY.create("only-available-in-window" /* AVAILABLE_IN_WINDOW */);
|
|
1391
|
+
throw ERROR_FACTORY.create("only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */);
|
|
1396
1392
|
}
|
|
1397
1393
|
if (!!messaging.swRegistration) return [3 /*break*/, 2];
|
|
1398
1394
|
return [4 /*yield*/, registerDefaultSw(messaging)];
|
|
@@ -1423,7 +1419,7 @@ function deleteToken$1(messaging) {
|
|
|
1423
1419
|
*/
|
|
1424
1420
|
function onMessage$1(messaging, nextOrObserver) {
|
|
1425
1421
|
if (!navigator) {
|
|
1426
|
-
throw ERROR_FACTORY.create("only-available-in-window" /* AVAILABLE_IN_WINDOW */);
|
|
1422
|
+
throw ERROR_FACTORY.create("only-available-in-window" /* ErrorCode.AVAILABLE_IN_WINDOW */);
|
|
1427
1423
|
}
|
|
1428
1424
|
messaging.onMessageHandler = nextOrObserver;
|
|
1429
1425
|
return function () {
|
|
@@ -1463,11 +1459,11 @@ function getMessagingInWindow(app) {
|
|
|
1463
1459
|
isWindowSupported().then(function (isSupported) {
|
|
1464
1460
|
// If `isWindowSupported()` resolved, but returned false.
|
|
1465
1461
|
if (!isSupported) {
|
|
1466
|
-
throw ERROR_FACTORY.create("unsupported-browser" /* UNSUPPORTED_BROWSER */);
|
|
1462
|
+
throw ERROR_FACTORY.create("unsupported-browser" /* ErrorCode.UNSUPPORTED_BROWSER */);
|
|
1467
1463
|
}
|
|
1468
1464
|
}, function (_) {
|
|
1469
1465
|
// If `isWindowSupported()` rejected.
|
|
1470
|
-
throw ERROR_FACTORY.create("indexed-db-unsupported" /* INDEXED_DB_UNSUPPORTED */);
|
|
1466
|
+
throw ERROR_FACTORY.create("indexed-db-unsupported" /* ErrorCode.INDEXED_DB_UNSUPPORTED */);
|
|
1471
1467
|
});
|
|
1472
1468
|
return _getProvider(getModularInstance(app), 'messaging').getImmediate();
|
|
1473
1469
|
}
|