GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.7 KiB

2 months ago
  1. import firebase from '@firebase/app-compat';
  2. import { Component } from '@firebase/component';
  3. import { getToken, deleteToken, onMessage } from '@firebase/messaging';
  4. import { isIndexedDBAvailable, areCookiesEnabled } from '@firebase/util';
  5. import { onBackgroundMessage } from '@firebase/messaging/sw';
  6. const name = "@firebase/messaging-compat";
  7. const version = "0.2.1";
  8. /**
  9. * @license
  10. * Copyright 2020 Google LLC
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. function isSupported() {
  25. if (self && 'ServiceWorkerGlobalScope' in self) {
  26. // Running in ServiceWorker context
  27. return isSwSupported();
  28. }
  29. else {
  30. // Assume we are in the window context.
  31. return isWindowSupported();
  32. }
  33. }
  34. /**
  35. * Checks to see if the required APIs exist.
  36. * Unlike the modular version, it does not check if IndexedDB.open() is allowed
  37. * in order to keep isSupported() synchronous and maintain v8 compatibility.
  38. */
  39. function isWindowSupported() {
  40. return (typeof window !== 'undefined' &&
  41. isIndexedDBAvailable() &&
  42. areCookiesEnabled() &&
  43. 'serviceWorker' in navigator &&
  44. 'PushManager' in window &&
  45. 'Notification' in window &&
  46. 'fetch' in window &&
  47. ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
  48. PushSubscription.prototype.hasOwnProperty('getKey'));
  49. }
  50. /**
  51. * Checks to see if the required APIs exist within SW Context.
  52. */
  53. function isSwSupported() {
  54. return (isIndexedDBAvailable() &&
  55. 'PushManager' in self &&
  56. 'Notification' in self &&
  57. ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
  58. PushSubscription.prototype.hasOwnProperty('getKey'));
  59. }
  60. class MessagingCompatImpl {
  61. constructor(app, _delegate) {
  62. this.app = app;
  63. this._delegate = _delegate;
  64. this.app = app;
  65. this._delegate = _delegate;
  66. }
  67. async getToken(options) {
  68. return getToken(this._delegate, options);
  69. }
  70. async deleteToken() {
  71. return deleteToken(this._delegate);
  72. }
  73. onMessage(nextOrObserver) {
  74. return onMessage(this._delegate, nextOrObserver);
  75. }
  76. onBackgroundMessage(nextOrObserver) {
  77. return onBackgroundMessage(this._delegate, nextOrObserver);
  78. }
  79. }
  80. /**
  81. * @license
  82. * Copyright 2020 Google LLC
  83. *
  84. * Licensed under the Apache License, Version 2.0 (the "License");
  85. * you may not use this file except in compliance with the License.
  86. * You may obtain a copy of the License at
  87. *
  88. * http://www.apache.org/licenses/LICENSE-2.0
  89. *
  90. * Unless required by applicable law or agreed to in writing, software
  91. * distributed under the License is distributed on an "AS IS" BASIS,
  92. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  93. * See the License for the specific language governing permissions and
  94. * limitations under the License.
  95. */
  96. const messagingCompatFactory = (container) => {
  97. if (self && 'ServiceWorkerGlobalScope' in self) {
  98. // in sw
  99. return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging-sw').getImmediate());
  100. }
  101. else {
  102. // in window
  103. return new MessagingCompatImpl(container.getProvider('app-compat').getImmediate(), container.getProvider('messaging').getImmediate());
  104. }
  105. };
  106. const NAMESPACE_EXPORTS = {
  107. isSupported
  108. };
  109. function registerMessagingCompat() {
  110. firebase.INTERNAL.registerComponent(new Component('messaging-compat', messagingCompatFactory, "PUBLIC" /* ComponentType.PUBLIC */).setServiceProps(NAMESPACE_EXPORTS));
  111. }
  112. /**
  113. * @license
  114. * Copyright 2020 Google LLC
  115. *
  116. * Licensed under the Apache License, Version 2.0 (the "License");
  117. * you may not use this file except in compliance with the License.
  118. * You may obtain a copy of the License at
  119. *
  120. * http://www.apache.org/licenses/LICENSE-2.0
  121. *
  122. * Unless required by applicable law or agreed to in writing, software
  123. * distributed under the License is distributed on an "AS IS" BASIS,
  124. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  125. * See the License for the specific language governing permissions and
  126. * limitations under the License.
  127. */
  128. registerMessagingCompat();
  129. firebase.registerVersion(name, version);
  130. //# sourceMappingURL=index.esm2017.js.map