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