UNPKG

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