No Description
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.

index-public.d.ts 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import { FirebaseApp } from '@firebase/app';
  2. import { NextFn , Observer , Unsubscribe } from '@firebase/util';
  3. /**
  4. * Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By
  5. * default, message delivery metrics are not exported to BigQuery. Use this method to enable or
  6. * disable the export at runtime.
  7. *
  8. * @param messaging - The `FirebaseMessaging` instance.
  9. * @param enable - Whether Firebase Cloud Messaging should export message delivery metrics to
  10. * BigQuery.
  11. *
  12. * @public
  13. */
  14. export declare function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging: Messaging, enable: boolean): void;
  15. /**
  16. * Options for features provided by the FCM SDK for Web. See {@link
  17. * https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions |
  18. * WebpushFcmOptions}
  19. *
  20. * @public
  21. */
  22. export declare interface FcmOptions {
  23. /**
  24. * The link to open when the user clicks on the notification.
  25. */
  26. link?: string;
  27. /**
  28. * The label associated with the message's analytics data.
  29. */
  30. analyticsLabel?: string;
  31. }
  32. /* Excluded from this release type: _FirebaseMessagingName */
  33. /**
  34. * Retrieves a Firebase Cloud Messaging instance.
  35. *
  36. * @returns The Firebase Cloud Messaging instance associated with the provided firebase app.
  37. *
  38. * @public
  39. */
  40. export declare function getMessaging(app?: FirebaseApp): Messaging;
  41. /**
  42. * Options for {@link getToken}
  43. *
  44. * @public
  45. */
  46. export declare interface GetTokenOptions {
  47. /**
  48. * The public server key provided to push services. It is used to
  49. * authenticate the push subscribers to receive push messages only from sending servers that hold
  50. * the corresponding private key. If it is not provided, a default VAPID key is used. Note that some
  51. * push services (Chrome Push Service) require a non-default VAPID key. Therefore, it is recommended
  52. * to generate and import a VAPID key for your project with
  53. * {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_with_fcm | Configure Web Credentials with FCM}.
  54. * See
  55. * {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol | The Web Push Protocol}
  56. * for details on web push services.
  57. */
  58. vapidKey?: string;
  59. /**
  60. * The service worker registration for receiving push
  61. * messaging. If the registration is not provided explicitly, you need to have a
  62. * `firebase-messaging-sw.js` at your root location. See
  63. * {@link https://firebase.google.com/docs/cloud-messaging/js/client#retrieve-the-current-registration-token | Retrieve the current registration token}
  64. * for more details.
  65. */
  66. serviceWorkerRegistration?: ServiceWorkerRegistration;
  67. }
  68. /**
  69. * Checks whether all required APIs exist within SW Context
  70. * @returns a Promise that resolves to a boolean.
  71. *
  72. * @public
  73. */
  74. export declare function isSupported(): Promise<boolean>;
  75. /**
  76. * Message payload that contains the notification payload that is represented with
  77. * {@link NotificationPayload} and the data payload that contains an arbitrary
  78. * number of key-value pairs sent by developers through the
  79. * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}
  80. *
  81. * @public
  82. */
  83. export declare interface MessagePayload {
  84. /**
  85. * {@inheritdoc NotificationPayload}
  86. */
  87. notification?: NotificationPayload;
  88. /**
  89. * Arbitrary key/value payload.
  90. */
  91. data?: {
  92. [key: string]: string;
  93. };
  94. /**
  95. * {@inheritdoc FcmOptions}
  96. */
  97. fcmOptions?: FcmOptions;
  98. /**
  99. * The sender of this message.
  100. */
  101. from: string;
  102. /**
  103. * The collapse key of the message. See
  104. * {@link https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages | Non-collapsible and collapsible messages}
  105. */
  106. collapseKey: string;
  107. /**
  108. * The message id of a message.
  109. */
  110. messageId: string;
  111. }
  112. /**
  113. * Public interface of the Firebase Cloud Messaging SDK.
  114. *
  115. * @public
  116. */
  117. export declare interface Messaging {
  118. /**
  119. * The {@link @firebase/app#FirebaseApp} this `Messaging` instance is associated with.
  120. */
  121. app: FirebaseApp;
  122. }
  123. export { NextFn };
  124. /**
  125. * Display notification details. They are sent through the
  126. * {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification | Send API}
  127. *
  128. * @public
  129. */
  130. export declare interface NotificationPayload {
  131. /**
  132. * The notification's title.
  133. */
  134. title?: string;
  135. /**
  136. * The notification's body text.
  137. */
  138. body?: string;
  139. /**
  140. * The URL of an image that is downloaded on the device and displayed in the notification.
  141. */
  142. image?: string;
  143. /**
  144. * The URL to use for the notification's icon. If you don't send this key in the request,
  145. * FCM displays the launcher icon specified in your app manifest.
  146. */
  147. icon?: string;
  148. }
  149. export { Observer };
  150. /**
  151. * Called when a message is received while the app is in the background. An app is considered to be
  152. * in the background if no active window is displayed.
  153. *
  154. * @param messaging - The {@link Messaging} instance.
  155. * @param nextOrObserver - This function, or observer object with `next` defined, is called when a
  156. * message is received and the app is currently in the background.
  157. *
  158. * @returns To stop listening for messages execute this returned function
  159. *
  160. * @public
  161. */
  162. export declare function onBackgroundMessage(messaging: Messaging, nextOrObserver: NextFn<MessagePayload> | Observer<MessagePayload>): Unsubscribe;
  163. export { Unsubscribe };
  164. export {};