index.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*! firebase-admin v12.1.1 */
  2. "use strict";
  3. /*!
  4. * Copyright 2020 Google Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. exports.MessagingClientErrorCode = exports.FirebaseMessagingError = exports.getMessaging = exports.Messaging = void 0;
  20. /**
  21. * Firebase Cloud Messaging (FCM).
  22. *
  23. * @packageDocumentation
  24. */
  25. const app_1 = require("../app");
  26. const messaging_1 = require("./messaging");
  27. var messaging_2 = require("./messaging");
  28. Object.defineProperty(exports, "Messaging", { enumerable: true, get: function () { return messaging_2.Messaging; } });
  29. /**
  30. * Gets the {@link Messaging} service for the default app or a given app.
  31. *
  32. * `admin.messaging()` can be called with no arguments to access the default
  33. * app's `Messaging` service or as `admin.messaging(app)` to access the
  34. * `Messaging` service associated with aspecific app.
  35. *
  36. * @example
  37. * ```javascript
  38. * // Get the Messaging service for the default app
  39. * const defaultMessaging = getMessaging();
  40. * ```
  41. *
  42. * @example
  43. * ```javascript
  44. * // Get the Messaging service for a given app
  45. * const otherMessaging = getMessaging(otherApp);
  46. * ```
  47. *
  48. * @param app - Optional app whose `Messaging` service to
  49. * return. If not provided, the default `Messaging` service will be returned.
  50. *
  51. * @returns The default `Messaging` service if no
  52. * app is provided or the `Messaging` service associated with the provided
  53. * app.
  54. */
  55. function getMessaging(app) {
  56. if (typeof app === 'undefined') {
  57. app = (0, app_1.getApp)();
  58. }
  59. const firebaseApp = app;
  60. return firebaseApp.getOrInitService('messaging', (app) => new messaging_1.Messaging(app));
  61. }
  62. exports.getMessaging = getMessaging;
  63. var error_1 = require("../utils/error");
  64. Object.defineProperty(exports, "FirebaseMessagingError", { enumerable: true, get: function () { return error_1.FirebaseMessagingError; } });
  65. Object.defineProperty(exports, "MessagingClientErrorCode", { enumerable: true, get: function () { return error_1.MessagingClientErrorCode; } });