firebase-admin 9.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/LICENSE +201 -0
- package/README.md +90 -0
- package/lib/app-check/app-check-api-client-internal.js +197 -0
- package/lib/app-check/app-check.js +79 -0
- package/lib/app-check/index.d.ts +160 -0
- package/lib/app-check/index.js +19 -0
- package/lib/app-check/token-generator.js +161 -0
- package/lib/app-check/token-verifier.js +152 -0
- package/lib/auth/action-code-settings-builder.js +118 -0
- package/lib/auth/auth-api-request.js +1856 -0
- package/lib/auth/auth-config.js +636 -0
- package/lib/auth/auth.js +836 -0
- package/lib/auth/identifier.js +40 -0
- package/lib/auth/index.d.ts +1927 -0
- package/lib/auth/index.js +18 -0
- package/lib/auth/tenant-manager.js +140 -0
- package/lib/auth/tenant.js +171 -0
- package/lib/auth/token-generator.js +200 -0
- package/lib/auth/token-verifier.js +259 -0
- package/lib/auth/user-import-builder.js +387 -0
- package/lib/auth/user-record.js +346 -0
- package/lib/credential/credential-internal.js +391 -0
- package/lib/credential/credential.js +44 -0
- package/lib/credential/index.d.ts +169 -0
- package/lib/credential/index.js +23 -0
- package/lib/database/database-internal.js +266 -0
- package/lib/database/index.d.ts +89 -0
- package/lib/database/index.js +31 -0
- package/lib/default-namespace.js +31 -0
- package/lib/firebase-app.js +349 -0
- package/lib/firebase-namespace-api.d.ts +243 -0
- package/lib/firebase-namespace-api.js +18 -0
- package/lib/firebase-namespace.d.ts +31 -0
- package/lib/firebase-namespace.js +417 -0
- package/lib/firestore/firestore-internal.js +105 -0
- package/lib/firestore/index.d.ts +50 -0
- package/lib/firestore/index.js +47 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +27 -0
- package/lib/installations/index.d.ts +81 -0
- package/lib/installations/index.js +18 -0
- package/lib/installations/installations-request-handler.js +117 -0
- package/lib/installations/installations.js +62 -0
- package/lib/instance-id/index.d.ts +83 -0
- package/lib/instance-id/index.js +18 -0
- package/lib/instance-id/instance-id.js +87 -0
- package/lib/machine-learning/index.d.ts +249 -0
- package/lib/machine-learning/index.js +18 -0
- package/lib/machine-learning/machine-learning-api-client.js +304 -0
- package/lib/machine-learning/machine-learning-utils.js +62 -0
- package/lib/machine-learning/machine-learning.js +364 -0
- package/lib/messaging/batch-request-internal.js +129 -0
- package/lib/messaging/index.d.ts +1174 -0
- package/lib/messaging/index.js +18 -0
- package/lib/messaging/messaging-api-request-internal.js +128 -0
- package/lib/messaging/messaging-errors-internal.js +106 -0
- package/lib/messaging/messaging-internal.js +484 -0
- package/lib/messaging/messaging.js +846 -0
- package/lib/project-management/android-app.js +176 -0
- package/lib/project-management/index.d.ts +363 -0
- package/lib/project-management/index.js +41 -0
- package/lib/project-management/ios-app.js +88 -0
- package/lib/project-management/project-management-api-request-internal.js +273 -0
- package/lib/project-management/project-management.js +254 -0
- package/lib/remote-config/index.d.ts +369 -0
- package/lib/remote-config/index.js +18 -0
- package/lib/remote-config/remote-config-api-client-internal.js +407 -0
- package/lib/remote-config/remote-config.js +304 -0
- package/lib/security-rules/index.d.ts +216 -0
- package/lib/security-rules/index.js +18 -0
- package/lib/security-rules/security-rules-api-client-internal.js +237 -0
- package/lib/security-rules/security-rules-internal.js +41 -0
- package/lib/security-rules/security-rules.js +310 -0
- package/lib/storage/index.d.ts +60 -0
- package/lib/storage/index.js +18 -0
- package/lib/storage/storage.js +123 -0
- package/lib/utils/api-request.js +845 -0
- package/lib/utils/crypto-signer.js +237 -0
- package/lib/utils/deep-copy.js +78 -0
- package/lib/utils/error.js +1063 -0
- package/lib/utils/index.js +217 -0
- package/lib/utils/jwt.js +355 -0
- package/lib/utils/validator.js +271 -0
- package/package.json +122 -0
|
@@ -0,0 +1,1174 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2020 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { app, FirebaseError, FirebaseArrayIndexError } from '../firebase-namespace-api';
|
|
18
|
+
/**
|
|
19
|
+
* Gets the {@link messaging.Messaging `Messaging`} service for the
|
|
20
|
+
* default app or a given app.
|
|
21
|
+
*
|
|
22
|
+
* `admin.messaging()` can be called with no arguments to access the default
|
|
23
|
+
* app's {@link messaging.Messaging `Messaging`} service or as
|
|
24
|
+
* `admin.messaging(app)` to access the
|
|
25
|
+
* {@link messaging.Messaging `Messaging`} service associated with a
|
|
26
|
+
* specific app.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```javascript
|
|
30
|
+
* // Get the Messaging service for the default app
|
|
31
|
+
* var defaultMessaging = admin.messaging();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```javascript
|
|
36
|
+
* // Get the Messaging service for a given app
|
|
37
|
+
* var otherMessaging = admin.messaging(otherApp);
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param app Optional app whose `Messaging` service to
|
|
41
|
+
* return. If not provided, the default `Messaging` service will be returned.
|
|
42
|
+
*
|
|
43
|
+
* @return The default `Messaging` service if no
|
|
44
|
+
* app is provided or the `Messaging` service associated with the provided
|
|
45
|
+
* app.
|
|
46
|
+
*/
|
|
47
|
+
export declare function messaging(app?: app.App): messaging.Messaging;
|
|
48
|
+
export declare namespace messaging {
|
|
49
|
+
interface BaseMessage {
|
|
50
|
+
data?: {
|
|
51
|
+
[key: string]: string;
|
|
52
|
+
};
|
|
53
|
+
notification?: Notification;
|
|
54
|
+
android?: AndroidConfig;
|
|
55
|
+
webpush?: WebpushConfig;
|
|
56
|
+
apns?: ApnsConfig;
|
|
57
|
+
fcmOptions?: FcmOptions;
|
|
58
|
+
}
|
|
59
|
+
export interface TokenMessage extends BaseMessage {
|
|
60
|
+
token: string;
|
|
61
|
+
}
|
|
62
|
+
export interface TopicMessage extends BaseMessage {
|
|
63
|
+
topic: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ConditionMessage extends BaseMessage {
|
|
66
|
+
condition: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Payload for the `admin.messaging.send()` operation. The payload contains all the fields
|
|
70
|
+
* in the `BaseMessage` type, and exactly one of token, topic or condition.
|
|
71
|
+
*/
|
|
72
|
+
export type Message = TokenMessage | TopicMessage | ConditionMessage;
|
|
73
|
+
/**
|
|
74
|
+
* Payload for the `admin.messaging.sendMulticast()` method. The payload contains all the fields
|
|
75
|
+
* in the `BaseMessage` type, and a list of tokens.
|
|
76
|
+
*/
|
|
77
|
+
export interface MulticastMessage extends BaseMessage {
|
|
78
|
+
tokens: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A notification that can be included in {@link messaging.Message}.
|
|
82
|
+
*/
|
|
83
|
+
export interface Notification {
|
|
84
|
+
/**
|
|
85
|
+
* The title of the notification.
|
|
86
|
+
*/
|
|
87
|
+
title?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The notification body
|
|
90
|
+
*/
|
|
91
|
+
body?: string;
|
|
92
|
+
/**
|
|
93
|
+
* URL of an image to be displayed in the notification.
|
|
94
|
+
*/
|
|
95
|
+
imageUrl?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Represents platform-independent options for features provided by the FCM SDKs.
|
|
99
|
+
*/
|
|
100
|
+
export interface FcmOptions {
|
|
101
|
+
/**
|
|
102
|
+
* The label associated with the message's analytics data.
|
|
103
|
+
*/
|
|
104
|
+
analyticsLabel?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Represents the WebPush protocol options that can be included in an
|
|
108
|
+
* {@link messaging.Message}.
|
|
109
|
+
*/
|
|
110
|
+
export interface WebpushConfig {
|
|
111
|
+
/**
|
|
112
|
+
* A collection of WebPush headers. Header values must be strings.
|
|
113
|
+
*
|
|
114
|
+
* See [WebPush specification](https://tools.ietf.org/html/rfc8030#section-5)
|
|
115
|
+
* for supported headers.
|
|
116
|
+
*/
|
|
117
|
+
headers?: {
|
|
118
|
+
[key: string]: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* A collection of data fields.
|
|
122
|
+
*/
|
|
123
|
+
data?: {
|
|
124
|
+
[key: string]: string;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* A WebPush notification payload to be included in the message.
|
|
128
|
+
*/
|
|
129
|
+
notification?: WebpushNotification;
|
|
130
|
+
/**
|
|
131
|
+
* Options for features provided by the FCM SDK for Web.
|
|
132
|
+
*/
|
|
133
|
+
fcmOptions?: WebpushFcmOptions;
|
|
134
|
+
}
|
|
135
|
+
/** Represents options for features provided by the FCM SDK for Web
|
|
136
|
+
* (which are not part of the Webpush standard).
|
|
137
|
+
*/
|
|
138
|
+
export interface WebpushFcmOptions {
|
|
139
|
+
/**
|
|
140
|
+
* The link to open when the user clicks on the notification.
|
|
141
|
+
* For all URL values, HTTPS is required.
|
|
142
|
+
*/
|
|
143
|
+
link?: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Represents the WebPush-specific notification options that can be included in
|
|
147
|
+
* {@link messaging.WebpushConfig}. This supports most of the standard
|
|
148
|
+
* options as defined in the Web Notification
|
|
149
|
+
* [specification](https://developer.mozilla.org/en-US/docs/Web/API/notification/Notification).
|
|
150
|
+
*/
|
|
151
|
+
export interface WebpushNotification {
|
|
152
|
+
/**
|
|
153
|
+
* Title text of the notification.
|
|
154
|
+
*/
|
|
155
|
+
title?: string;
|
|
156
|
+
/**
|
|
157
|
+
* An array of notification actions representing the actions
|
|
158
|
+
* available to the user when the notification is presented.
|
|
159
|
+
*/
|
|
160
|
+
actions?: Array<{
|
|
161
|
+
/**
|
|
162
|
+
* An action available to the user when the notification is presented
|
|
163
|
+
*/
|
|
164
|
+
action: string;
|
|
165
|
+
/**
|
|
166
|
+
* Optional icon for a notification action.
|
|
167
|
+
*/
|
|
168
|
+
icon?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Title of the notification action.
|
|
171
|
+
*/
|
|
172
|
+
title: string;
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* URL of the image used to represent the notification when there is
|
|
176
|
+
* not enough space to display the notification itself.
|
|
177
|
+
*/
|
|
178
|
+
badge?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Body text of the notification.
|
|
181
|
+
*/
|
|
182
|
+
body?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Arbitrary data that you want associated with the notification.
|
|
185
|
+
* This can be of any data type.
|
|
186
|
+
*/
|
|
187
|
+
data?: any;
|
|
188
|
+
/**
|
|
189
|
+
* The direction in which to display the notification. Must be one
|
|
190
|
+
* of `auto`, `ltr` or `rtl`.
|
|
191
|
+
*/
|
|
192
|
+
dir?: 'auto' | 'ltr' | 'rtl';
|
|
193
|
+
/**
|
|
194
|
+
* URL to the notification icon.
|
|
195
|
+
*/
|
|
196
|
+
icon?: string;
|
|
197
|
+
/**
|
|
198
|
+
* URL of an image to be displayed in the notification.
|
|
199
|
+
*/
|
|
200
|
+
image?: string;
|
|
201
|
+
/**
|
|
202
|
+
* The notification's language as a BCP 47 language tag.
|
|
203
|
+
*/
|
|
204
|
+
lang?: string;
|
|
205
|
+
/**
|
|
206
|
+
* A boolean specifying whether the user should be notified after a
|
|
207
|
+
* new notification replaces an old one. Defaults to false.
|
|
208
|
+
*/
|
|
209
|
+
renotify?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Indicates that a notification should remain active until the user
|
|
212
|
+
* clicks or dismisses it, rather than closing automatically.
|
|
213
|
+
* Defaults to false.
|
|
214
|
+
*/
|
|
215
|
+
requireInteraction?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* A boolean specifying whether the notification should be silent.
|
|
218
|
+
* Defaults to false.
|
|
219
|
+
*/
|
|
220
|
+
silent?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* An identifying tag for the notification.
|
|
223
|
+
*/
|
|
224
|
+
tag?: string;
|
|
225
|
+
/**
|
|
226
|
+
* Timestamp of the notification. Refer to
|
|
227
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/notification/timestamp
|
|
228
|
+
* for details.
|
|
229
|
+
*/
|
|
230
|
+
timestamp?: number;
|
|
231
|
+
/**
|
|
232
|
+
* A vibration pattern for the device's vibration hardware to emit
|
|
233
|
+
* when the notification fires.
|
|
234
|
+
*/
|
|
235
|
+
vibrate?: number | number[];
|
|
236
|
+
[key: string]: any;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Represents the APNs-specific options that can be included in an
|
|
240
|
+
* {@link messaging.Message}. Refer to
|
|
241
|
+
* [Apple documentation](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html)
|
|
242
|
+
* for various headers and payload fields supported by APNs.
|
|
243
|
+
*/
|
|
244
|
+
export interface ApnsConfig {
|
|
245
|
+
/**
|
|
246
|
+
* A collection of APNs headers. Header values must be strings.
|
|
247
|
+
*/
|
|
248
|
+
headers?: {
|
|
249
|
+
[key: string]: string;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* An APNs payload to be included in the message.
|
|
253
|
+
*/
|
|
254
|
+
payload?: ApnsPayload;
|
|
255
|
+
/**
|
|
256
|
+
* Options for features provided by the FCM SDK for iOS.
|
|
257
|
+
*/
|
|
258
|
+
fcmOptions?: ApnsFcmOptions;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Represents the payload of an APNs message. Mainly consists of the `aps`
|
|
262
|
+
* dictionary. But may also contain other arbitrary custom keys.
|
|
263
|
+
*/
|
|
264
|
+
export interface ApnsPayload {
|
|
265
|
+
/**
|
|
266
|
+
* The `aps` dictionary to be included in the message.
|
|
267
|
+
*/
|
|
268
|
+
aps: Aps;
|
|
269
|
+
[customData: string]: any;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Represents the [aps dictionary](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html)
|
|
273
|
+
* that is part of APNs messages.
|
|
274
|
+
*/
|
|
275
|
+
export interface Aps {
|
|
276
|
+
/**
|
|
277
|
+
* Alert to be included in the message. This may be a string or an object of
|
|
278
|
+
* type `admin.messaging.ApsAlert`.
|
|
279
|
+
*/
|
|
280
|
+
alert?: string | ApsAlert;
|
|
281
|
+
/**
|
|
282
|
+
* Badge to be displayed with the message. Set to 0 to remove the badge. When
|
|
283
|
+
* not specified, the badge will remain unchanged.
|
|
284
|
+
*/
|
|
285
|
+
badge?: number;
|
|
286
|
+
/**
|
|
287
|
+
* Sound to be played with the message.
|
|
288
|
+
*/
|
|
289
|
+
sound?: string | CriticalSound;
|
|
290
|
+
/**
|
|
291
|
+
* Specifies whether to configure a background update notification.
|
|
292
|
+
*/
|
|
293
|
+
contentAvailable?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Specifies whether to set the `mutable-content` property on the message
|
|
296
|
+
* so the clients can modify the notification via app extensions.
|
|
297
|
+
*/
|
|
298
|
+
mutableContent?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Type of the notification.
|
|
301
|
+
*/
|
|
302
|
+
category?: string;
|
|
303
|
+
/**
|
|
304
|
+
* An app-specific identifier for grouping notifications.
|
|
305
|
+
*/
|
|
306
|
+
threadId?: string;
|
|
307
|
+
[customData: string]: any;
|
|
308
|
+
}
|
|
309
|
+
export interface ApsAlert {
|
|
310
|
+
title?: string;
|
|
311
|
+
subtitle?: string;
|
|
312
|
+
body?: string;
|
|
313
|
+
locKey?: string;
|
|
314
|
+
locArgs?: string[];
|
|
315
|
+
titleLocKey?: string;
|
|
316
|
+
titleLocArgs?: string[];
|
|
317
|
+
subtitleLocKey?: string;
|
|
318
|
+
subtitleLocArgs?: string[];
|
|
319
|
+
actionLocKey?: string;
|
|
320
|
+
launchImage?: string;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Represents a critical sound configuration that can be included in the
|
|
324
|
+
* `aps` dictionary of an APNs payload.
|
|
325
|
+
*/
|
|
326
|
+
export interface CriticalSound {
|
|
327
|
+
/**
|
|
328
|
+
* The critical alert flag. Set to `true` to enable the critical alert.
|
|
329
|
+
*/
|
|
330
|
+
critical?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* The name of a sound file in the app's main bundle or in the `Library/Sounds`
|
|
333
|
+
* folder of the app's container directory. Specify the string "default" to play
|
|
334
|
+
* the system sound.
|
|
335
|
+
*/
|
|
336
|
+
name: string;
|
|
337
|
+
/**
|
|
338
|
+
* The volume for the critical alert's sound. Must be a value between 0.0
|
|
339
|
+
* (silent) and 1.0 (full volume).
|
|
340
|
+
*/
|
|
341
|
+
volume?: number;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Represents options for features provided by the FCM SDK for iOS.
|
|
345
|
+
*/
|
|
346
|
+
export interface ApnsFcmOptions {
|
|
347
|
+
/**
|
|
348
|
+
* The label associated with the message's analytics data.
|
|
349
|
+
*/
|
|
350
|
+
analyticsLabel?: string;
|
|
351
|
+
/**
|
|
352
|
+
* URL of an image to be displayed in the notification.
|
|
353
|
+
*/
|
|
354
|
+
imageUrl?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Represents the Android-specific options that can be included in an
|
|
358
|
+
* {@link messaging.Message}.
|
|
359
|
+
*/
|
|
360
|
+
export interface AndroidConfig {
|
|
361
|
+
/**
|
|
362
|
+
* Collapse key for the message. Collapse key serves as an identifier for a
|
|
363
|
+
* group of messages that can be collapsed, so that only the last message gets
|
|
364
|
+
* sent when delivery can be resumed. A maximum of four different collapse keys
|
|
365
|
+
* may be active at any given time.
|
|
366
|
+
*/
|
|
367
|
+
collapseKey?: string;
|
|
368
|
+
/**
|
|
369
|
+
* Priority of the message. Must be either `normal` or `high`.
|
|
370
|
+
*/
|
|
371
|
+
priority?: ('high' | 'normal');
|
|
372
|
+
/**
|
|
373
|
+
* Time-to-live duration of the message in milliseconds.
|
|
374
|
+
*/
|
|
375
|
+
ttl?: number;
|
|
376
|
+
/**
|
|
377
|
+
* Package name of the application where the registration tokens must match
|
|
378
|
+
* in order to receive the message.
|
|
379
|
+
*/
|
|
380
|
+
restrictedPackageName?: string;
|
|
381
|
+
/**
|
|
382
|
+
* A collection of data fields to be included in the message. All values must
|
|
383
|
+
* be strings. When provided, overrides any data fields set on the top-level
|
|
384
|
+
* `admin.messaging.Message`.}
|
|
385
|
+
*/
|
|
386
|
+
data?: {
|
|
387
|
+
[key: string]: string;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* Android notification to be included in the message.
|
|
391
|
+
*/
|
|
392
|
+
notification?: AndroidNotification;
|
|
393
|
+
/**
|
|
394
|
+
* Options for features provided by the FCM SDK for Android.
|
|
395
|
+
*/
|
|
396
|
+
fcmOptions?: AndroidFcmOptions;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Represents the Android-specific notification options that can be included in
|
|
400
|
+
* {@link messaging.AndroidConfig}.
|
|
401
|
+
*/
|
|
402
|
+
export interface AndroidNotification {
|
|
403
|
+
/**
|
|
404
|
+
* Title of the Android notification. When provided, overrides the title set via
|
|
405
|
+
* `admin.messaging.Notification`.
|
|
406
|
+
*/
|
|
407
|
+
title?: string;
|
|
408
|
+
/**
|
|
409
|
+
* Body of the Android notification. When provided, overrides the body set via
|
|
410
|
+
* `admin.messaging.Notification`.
|
|
411
|
+
*/
|
|
412
|
+
body?: string;
|
|
413
|
+
/**
|
|
414
|
+
* Icon resource for the Android notification.
|
|
415
|
+
*/
|
|
416
|
+
icon?: string;
|
|
417
|
+
/**
|
|
418
|
+
* Notification icon color in `#rrggbb` format.
|
|
419
|
+
*/
|
|
420
|
+
color?: string;
|
|
421
|
+
/**
|
|
422
|
+
* File name of the sound to be played when the device receives the
|
|
423
|
+
* notification.
|
|
424
|
+
*/
|
|
425
|
+
sound?: string;
|
|
426
|
+
/**
|
|
427
|
+
* Notification tag. This is an identifier used to replace existing
|
|
428
|
+
* notifications in the notification drawer. If not specified, each request
|
|
429
|
+
* creates a new notification.
|
|
430
|
+
*/
|
|
431
|
+
tag?: string;
|
|
432
|
+
/**
|
|
433
|
+
* URL of an image to be displayed in the notification.
|
|
434
|
+
*/
|
|
435
|
+
imageUrl?: string;
|
|
436
|
+
/**
|
|
437
|
+
* Action associated with a user click on the notification. If specified, an
|
|
438
|
+
* activity with a matching Intent Filter is launched when a user clicks on the
|
|
439
|
+
* notification.
|
|
440
|
+
*/
|
|
441
|
+
clickAction?: string;
|
|
442
|
+
/**
|
|
443
|
+
* Key of the body string in the app's string resource to use to localize the
|
|
444
|
+
* body text.
|
|
445
|
+
*
|
|
446
|
+
*/
|
|
447
|
+
bodyLocKey?: string;
|
|
448
|
+
/**
|
|
449
|
+
* An array of resource keys that will be used in place of the format
|
|
450
|
+
* specifiers in `bodyLocKey`.
|
|
451
|
+
*/
|
|
452
|
+
bodyLocArgs?: string[];
|
|
453
|
+
/**
|
|
454
|
+
* Key of the title string in the app's string resource to use to localize the
|
|
455
|
+
* title text.
|
|
456
|
+
*/
|
|
457
|
+
titleLocKey?: string;
|
|
458
|
+
/**
|
|
459
|
+
* An array of resource keys that will be used in place of the format
|
|
460
|
+
* specifiers in `titleLocKey`.
|
|
461
|
+
*/
|
|
462
|
+
titleLocArgs?: string[];
|
|
463
|
+
/**
|
|
464
|
+
* The Android notification channel ID (new in Android O). The app must create
|
|
465
|
+
* a channel with this channel ID before any notification with this channel ID
|
|
466
|
+
* can be received. If you don't send this channel ID in the request, or if the
|
|
467
|
+
* channel ID provided has not yet been created by the app, FCM uses the channel
|
|
468
|
+
* ID specified in the app manifest.
|
|
469
|
+
*/
|
|
470
|
+
channelId?: string;
|
|
471
|
+
/**
|
|
472
|
+
* Sets the "ticker" text, which is sent to accessibility services. Prior to
|
|
473
|
+
* API level 21 (Lollipop), sets the text that is displayed in the status bar
|
|
474
|
+
* when the notification first arrives.
|
|
475
|
+
*/
|
|
476
|
+
ticker?: string;
|
|
477
|
+
/**
|
|
478
|
+
* When set to `false` or unset, the notification is automatically dismissed when
|
|
479
|
+
* the user clicks it in the panel. When set to `true`, the notification persists
|
|
480
|
+
* even when the user clicks it.
|
|
481
|
+
*/
|
|
482
|
+
sticky?: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* For notifications that inform users about events with an absolute time reference, sets
|
|
485
|
+
* the time that the event in the notification occurred. Notifications
|
|
486
|
+
* in the panel are sorted by this time.
|
|
487
|
+
*/
|
|
488
|
+
eventTimestamp?: Date;
|
|
489
|
+
/**
|
|
490
|
+
* Sets whether or not this notification is relevant only to the current device.
|
|
491
|
+
* Some notifications can be bridged to other devices for remote display, such as
|
|
492
|
+
* a Wear OS watch. This hint can be set to recommend this notification not be bridged.
|
|
493
|
+
* See [Wear OS guides](https://developer.android.com/training/wearables/notifications/bridger#existing-method-of-preventing-bridging)
|
|
494
|
+
*/
|
|
495
|
+
localOnly?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* Sets the relative priority for this notification. Low-priority notifications
|
|
498
|
+
* may be hidden from the user in certain situations. Note this priority differs
|
|
499
|
+
* from `AndroidMessagePriority`. This priority is processed by the client after
|
|
500
|
+
* the message has been delivered. Whereas `AndroidMessagePriority` is an FCM concept
|
|
501
|
+
* that controls when the message is delivered.
|
|
502
|
+
*/
|
|
503
|
+
priority?: ('min' | 'low' | 'default' | 'high' | 'max');
|
|
504
|
+
/**
|
|
505
|
+
* Sets the vibration pattern to use. Pass in an array of milliseconds to
|
|
506
|
+
* turn the vibrator on or off. The first value indicates the duration to wait before
|
|
507
|
+
* turning the vibrator on. The next value indicates the duration to keep the
|
|
508
|
+
* vibrator on. Subsequent values alternate between duration to turn the vibrator
|
|
509
|
+
* off and to turn the vibrator on. If `vibrate_timings` is set and `default_vibrate_timings`
|
|
510
|
+
* is set to `true`, the default value is used instead of the user-specified `vibrate_timings`.
|
|
511
|
+
*/
|
|
512
|
+
vibrateTimingsMillis?: number[];
|
|
513
|
+
/**
|
|
514
|
+
* If set to `true`, use the Android framework's default vibrate pattern for the
|
|
515
|
+
* notification. Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml).
|
|
516
|
+
* If `default_vibrate_timings` is set to `true` and `vibrate_timings` is also set,
|
|
517
|
+
* the default value is used instead of the user-specified `vibrate_timings`.
|
|
518
|
+
*/
|
|
519
|
+
defaultVibrateTimings?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* If set to `true`, use the Android framework's default sound for the notification.
|
|
522
|
+
* Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml).
|
|
523
|
+
*/
|
|
524
|
+
defaultSound?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Settings to control the notification's LED blinking rate and color if LED is
|
|
527
|
+
* available on the device. The total blinking time is controlled by the OS.
|
|
528
|
+
*/
|
|
529
|
+
lightSettings?: LightSettings;
|
|
530
|
+
/**
|
|
531
|
+
* If set to `true`, use the Android framework's default LED light settings
|
|
532
|
+
* for the notification. Default values are specified in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml).
|
|
533
|
+
* If `default_light_settings` is set to `true` and `light_settings` is also set,
|
|
534
|
+
* the user-specified `light_settings` is used instead of the default value.
|
|
535
|
+
*/
|
|
536
|
+
defaultLightSettings?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Sets the visibility of the notification. Must be either `private`, `public`,
|
|
539
|
+
* or `secret`. If unspecified, defaults to `private`.
|
|
540
|
+
*/
|
|
541
|
+
visibility?: ('private' | 'public' | 'secret');
|
|
542
|
+
/**
|
|
543
|
+
* Sets the number of items this notification represents. May be displayed as a
|
|
544
|
+
* badge count for Launchers that support badging. See [`NotificationBadge`(https://developer.android.com/training/notify-user/badges).
|
|
545
|
+
* For example, this might be useful if you're using just one notification to
|
|
546
|
+
* represent multiple new messages but you want the count here to represent
|
|
547
|
+
* the number of total new messages. If zero or unspecified, systems
|
|
548
|
+
* that support badging use the default, which is to increment a number
|
|
549
|
+
* displayed on the long-press menu each time a new notification arrives.
|
|
550
|
+
*/
|
|
551
|
+
notificationCount?: number;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Represents settings to control notification LED that can be included in
|
|
555
|
+
* {@link messaging.AndroidNotification}.
|
|
556
|
+
*/
|
|
557
|
+
export interface LightSettings {
|
|
558
|
+
/**
|
|
559
|
+
* Required. Sets color of the LED in `#rrggbb` or `#rrggbbaa` format.
|
|
560
|
+
*/
|
|
561
|
+
color: string;
|
|
562
|
+
/**
|
|
563
|
+
* Required. Along with `light_off_duration`, defines the blink rate of LED flashes.
|
|
564
|
+
*/
|
|
565
|
+
lightOnDurationMillis: number;
|
|
566
|
+
/**
|
|
567
|
+
* Required. Along with `light_on_duration`, defines the blink rate of LED flashes.
|
|
568
|
+
*/
|
|
569
|
+
lightOffDurationMillis: number;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Represents options for features provided by the FCM SDK for Android.
|
|
573
|
+
*/
|
|
574
|
+
export interface AndroidFcmOptions {
|
|
575
|
+
/**
|
|
576
|
+
* The label associated with the message's analytics data.
|
|
577
|
+
*/
|
|
578
|
+
analyticsLabel?: string;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Interface representing an FCM legacy API data message payload. Data
|
|
582
|
+
* messages let developers send up to 4KB of custom key-value pairs. The
|
|
583
|
+
* keys and values must both be strings. Keys can be any custom string,
|
|
584
|
+
* except for the following reserved strings:
|
|
585
|
+
*
|
|
586
|
+
* * `"from"`
|
|
587
|
+
* * Anything starting with `"google."`.
|
|
588
|
+
*
|
|
589
|
+
* See [Build send requests](/docs/cloud-messaging/send-message)
|
|
590
|
+
* for code samples and detailed documentation.
|
|
591
|
+
*/
|
|
592
|
+
export interface DataMessagePayload {
|
|
593
|
+
[key: string]: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Interface representing an FCM legacy API notification message payload.
|
|
597
|
+
* Notification messages let developers send up to 4KB of predefined
|
|
598
|
+
* key-value pairs. Accepted keys are outlined below.
|
|
599
|
+
*
|
|
600
|
+
* See [Build send requests](/docs/cloud-messaging/send-message)
|
|
601
|
+
* for code samples and detailed documentation.
|
|
602
|
+
*/
|
|
603
|
+
export interface NotificationMessagePayload {
|
|
604
|
+
/**
|
|
605
|
+
* Identifier used to replace existing notifications in the notification drawer.
|
|
606
|
+
*
|
|
607
|
+
* If not specified, each request creates a new notification.
|
|
608
|
+
*
|
|
609
|
+
* If specified and a notification with the same tag is already being shown,
|
|
610
|
+
* the new notification replaces the existing one in the notification drawer.
|
|
611
|
+
*
|
|
612
|
+
* **Platforms:** Android
|
|
613
|
+
*/
|
|
614
|
+
tag?: string;
|
|
615
|
+
/**
|
|
616
|
+
* The notification's body text.
|
|
617
|
+
*
|
|
618
|
+
* **Platforms:** iOS, Android, Web
|
|
619
|
+
*/
|
|
620
|
+
body?: string;
|
|
621
|
+
/**
|
|
622
|
+
* The notification's icon.
|
|
623
|
+
*
|
|
624
|
+
* **Android:** Sets the notification icon to `myicon` for drawable resource
|
|
625
|
+
* `myicon`. If you don't send this key in the request, FCM displays the
|
|
626
|
+
* launcher icon specified in your app manifest.
|
|
627
|
+
*
|
|
628
|
+
* **Web:** The URL to use for the notification's icon.
|
|
629
|
+
*
|
|
630
|
+
* **Platforms:** Android, Web
|
|
631
|
+
*/
|
|
632
|
+
icon?: string;
|
|
633
|
+
/**
|
|
634
|
+
* The value of the badge on the home screen app icon.
|
|
635
|
+
*
|
|
636
|
+
* If not specified, the badge is not changed.
|
|
637
|
+
*
|
|
638
|
+
* If set to `0`, the badge is removed.
|
|
639
|
+
*
|
|
640
|
+
* **Platforms:** iOS
|
|
641
|
+
*/
|
|
642
|
+
badge?: string;
|
|
643
|
+
/**
|
|
644
|
+
* The notification icon's color, expressed in `#rrggbb` format.
|
|
645
|
+
*
|
|
646
|
+
* **Platforms:** Android
|
|
647
|
+
*/
|
|
648
|
+
color?: string;
|
|
649
|
+
/**
|
|
650
|
+
* The sound to be played when the device receives a notification. Supports
|
|
651
|
+
* "default" for the default notification sound of the device or the filename of a
|
|
652
|
+
* sound resource bundled in the app.
|
|
653
|
+
* Sound files must reside in `/res/raw/`.
|
|
654
|
+
*
|
|
655
|
+
* **Platforms:** Android
|
|
656
|
+
*/
|
|
657
|
+
sound?: string;
|
|
658
|
+
/**
|
|
659
|
+
* The notification's title.
|
|
660
|
+
*
|
|
661
|
+
* **Platforms:** iOS, Android, Web
|
|
662
|
+
*/
|
|
663
|
+
title?: string;
|
|
664
|
+
/**
|
|
665
|
+
* The key to the body string in the app's string resources to use to localize
|
|
666
|
+
* the body text to the user's current localization.
|
|
667
|
+
*
|
|
668
|
+
* **iOS:** Corresponds to `loc-key` in the APNs payload. See
|
|
669
|
+
* [Payload Key Reference](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html)
|
|
670
|
+
* and
|
|
671
|
+
* [Localizing the Content of Your Remote Notifications](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW9)
|
|
672
|
+
* for more information.
|
|
673
|
+
*
|
|
674
|
+
* **Android:** See
|
|
675
|
+
* [String Resources](http://developer.android.com/guide/topics/resources/string-resource.html) * for more information.
|
|
676
|
+
*
|
|
677
|
+
* **Platforms:** iOS, Android
|
|
678
|
+
*/
|
|
679
|
+
bodyLocKey?: string;
|
|
680
|
+
/**
|
|
681
|
+
* Variable string values to be used in place of the format specifiers in
|
|
682
|
+
* `body_loc_key` to use to localize the body text to the user's current
|
|
683
|
+
* localization.
|
|
684
|
+
*
|
|
685
|
+
* The value should be a stringified JSON array.
|
|
686
|
+
*
|
|
687
|
+
* **iOS:** Corresponds to `loc-args` in the APNs payload. See
|
|
688
|
+
* [Payload Key Reference](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html)
|
|
689
|
+
* and
|
|
690
|
+
* [Localizing the Content of Your Remote Notifications](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW9)
|
|
691
|
+
* for more information.
|
|
692
|
+
*
|
|
693
|
+
* **Android:** See
|
|
694
|
+
* [Formatting and Styling](http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling)
|
|
695
|
+
* for more information.
|
|
696
|
+
*
|
|
697
|
+
* **Platforms:** iOS, Android
|
|
698
|
+
*/
|
|
699
|
+
bodyLocArgs?: string;
|
|
700
|
+
/**
|
|
701
|
+
* Action associated with a user click on the notification. If specified, an
|
|
702
|
+
* activity with a matching Intent Filter is launched when a user clicks on the
|
|
703
|
+
* notification.
|
|
704
|
+
*
|
|
705
|
+
* * **Platforms:** Android
|
|
706
|
+
*/
|
|
707
|
+
clickAction?: string;
|
|
708
|
+
/**
|
|
709
|
+
* The key to the title string in the app's string resources to use to localize
|
|
710
|
+
* the title text to the user's current localization.
|
|
711
|
+
*
|
|
712
|
+
* **iOS:** Corresponds to `title-loc-key` in the APNs payload. See
|
|
713
|
+
* [Payload Key Reference](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html)
|
|
714
|
+
* and
|
|
715
|
+
* [Localizing the Content of Your Remote Notifications](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW9)
|
|
716
|
+
* for more information.
|
|
717
|
+
*
|
|
718
|
+
* **Android:** See
|
|
719
|
+
* [String Resources](http://developer.android.com/guide/topics/resources/string-resource.html)
|
|
720
|
+
* for more information.
|
|
721
|
+
*
|
|
722
|
+
* **Platforms:** iOS, Android
|
|
723
|
+
*/
|
|
724
|
+
titleLocKey?: string;
|
|
725
|
+
/**
|
|
726
|
+
* Variable string values to be used in place of the format specifiers in
|
|
727
|
+
* `title_loc_key` to use to localize the title text to the user's current
|
|
728
|
+
* localization.
|
|
729
|
+
*
|
|
730
|
+
* The value should be a stringified JSON array.
|
|
731
|
+
*
|
|
732
|
+
* **iOS:** Corresponds to `title-loc-args` in the APNs payload. See
|
|
733
|
+
* [Payload Key Reference](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html)
|
|
734
|
+
* and
|
|
735
|
+
* [Localizing the Content of Your Remote Notifications](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW9)
|
|
736
|
+
* for more information.
|
|
737
|
+
*
|
|
738
|
+
* **Android:** See
|
|
739
|
+
* [Formatting and Styling](http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling)
|
|
740
|
+
* for more information.
|
|
741
|
+
*
|
|
742
|
+
* **Platforms:** iOS, Android
|
|
743
|
+
*/
|
|
744
|
+
titleLocArgs?: string;
|
|
745
|
+
[key: string]: string | undefined;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Interface representing a Firebase Cloud Messaging message payload. One or
|
|
749
|
+
* both of the `data` and `notification` keys are required.
|
|
750
|
+
*
|
|
751
|
+
* See
|
|
752
|
+
* [Build send requests](/docs/cloud-messaging/send-message)
|
|
753
|
+
* for code samples and detailed documentation.
|
|
754
|
+
*/
|
|
755
|
+
export interface MessagingPayload {
|
|
756
|
+
/**
|
|
757
|
+
* The data message payload.
|
|
758
|
+
*/
|
|
759
|
+
data?: DataMessagePayload;
|
|
760
|
+
/**
|
|
761
|
+
* The notification message payload.
|
|
762
|
+
*/
|
|
763
|
+
notification?: NotificationMessagePayload;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Interface representing the options that can be provided when sending a
|
|
767
|
+
* message via the FCM legacy APIs.
|
|
768
|
+
*
|
|
769
|
+
* See [Build send requests](/docs/cloud-messaging/send-message)
|
|
770
|
+
* for code samples and detailed documentation.
|
|
771
|
+
*/
|
|
772
|
+
export interface MessagingOptions {
|
|
773
|
+
/**
|
|
774
|
+
* Whether or not the message should actually be sent. When set to `true`,
|
|
775
|
+
* allows developers to test a request without actually sending a message. When
|
|
776
|
+
* set to `false`, the message will be sent.
|
|
777
|
+
*
|
|
778
|
+
* **Default value:** `false`
|
|
779
|
+
*/
|
|
780
|
+
dryRun?: boolean;
|
|
781
|
+
/**
|
|
782
|
+
* The priority of the message. Valid values are `"normal"` and `"high".` On
|
|
783
|
+
* iOS, these correspond to APNs priorities `5` and `10`.
|
|
784
|
+
*
|
|
785
|
+
* By default, notification messages are sent with high priority, and data
|
|
786
|
+
* messages are sent with normal priority. Normal priority optimizes the client
|
|
787
|
+
* app's battery consumption and should be used unless immediate delivery is
|
|
788
|
+
* required. For messages with normal priority, the app may receive the message
|
|
789
|
+
* with unspecified delay.
|
|
790
|
+
*
|
|
791
|
+
* When a message is sent with high priority, it is sent immediately, and the
|
|
792
|
+
* app can wake a sleeping device and open a network connection to your server.
|
|
793
|
+
*
|
|
794
|
+
* For more information, see
|
|
795
|
+
* [Setting the priority of a message](/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message).
|
|
796
|
+
*
|
|
797
|
+
* **Default value:** `"high"` for notification messages, `"normal"` for data
|
|
798
|
+
* messages
|
|
799
|
+
*/
|
|
800
|
+
priority?: string;
|
|
801
|
+
/**
|
|
802
|
+
* How long (in seconds) the message should be kept in FCM storage if the device
|
|
803
|
+
* is offline. The maximum time to live supported is four weeks, and the default
|
|
804
|
+
* value is also four weeks. For more information, see
|
|
805
|
+
* [Setting the lifespan of a message](/docs/cloud-messaging/concept-options#ttl).
|
|
806
|
+
*
|
|
807
|
+
* **Default value:** `2419200` (representing four weeks, in seconds)
|
|
808
|
+
*/
|
|
809
|
+
timeToLive?: number;
|
|
810
|
+
/**
|
|
811
|
+
* String identifying a group of messages (for example, "Updates Available")
|
|
812
|
+
* that can be collapsed, so that only the last message gets sent when delivery
|
|
813
|
+
* can be resumed. This is used to avoid sending too many of the same messages
|
|
814
|
+
* when the device comes back online or becomes active.
|
|
815
|
+
*
|
|
816
|
+
* There is no guarantee of the order in which messages get sent.
|
|
817
|
+
*
|
|
818
|
+
* A maximum of four different collapse keys is allowed at any given time. This
|
|
819
|
+
* means FCM server can simultaneously store four different
|
|
820
|
+
* send-to-sync messages per client app. If you exceed this number, there is no
|
|
821
|
+
* guarantee which four collapse keys the FCM server will keep.
|
|
822
|
+
*
|
|
823
|
+
* **Default value:** None
|
|
824
|
+
*/
|
|
825
|
+
collapseKey?: string;
|
|
826
|
+
/**
|
|
827
|
+
* On iOS, use this field to represent `mutable-content` in the APNs payload.
|
|
828
|
+
* When a notification is sent and this is set to `true`, the content of the
|
|
829
|
+
* notification can be modified before it is displayed, using a
|
|
830
|
+
* [Notification Service app extension](https://developer.apple.com/reference/usernotifications/unnotificationserviceextension)
|
|
831
|
+
*
|
|
832
|
+
* On Android and Web, this parameter will be ignored.
|
|
833
|
+
*
|
|
834
|
+
* **Default value:** `false`
|
|
835
|
+
*/
|
|
836
|
+
mutableContent?: boolean;
|
|
837
|
+
/**
|
|
838
|
+
* On iOS, use this field to represent `content-available` in the APNs payload.
|
|
839
|
+
* When a notification or data message is sent and this is set to `true`, an
|
|
840
|
+
* inactive client app is awoken. On Android, data messages wake the app by
|
|
841
|
+
* default. On Chrome, this flag is currently not supported.
|
|
842
|
+
*
|
|
843
|
+
* **Default value:** `false`
|
|
844
|
+
*/
|
|
845
|
+
contentAvailable?: boolean;
|
|
846
|
+
/**
|
|
847
|
+
* The package name of the application which the registration tokens must match
|
|
848
|
+
* in order to receive the message.
|
|
849
|
+
*
|
|
850
|
+
* **Default value:** None
|
|
851
|
+
*/
|
|
852
|
+
restrictedPackageName?: string;
|
|
853
|
+
[key: string]: any | undefined;
|
|
854
|
+
}
|
|
855
|
+
export interface MessagingDeviceResult {
|
|
856
|
+
/**
|
|
857
|
+
* The error that occurred when processing the message for the recipient.
|
|
858
|
+
*/
|
|
859
|
+
error?: FirebaseError;
|
|
860
|
+
/**
|
|
861
|
+
* A unique ID for the successfully processed message.
|
|
862
|
+
*/
|
|
863
|
+
messageId?: string;
|
|
864
|
+
/**
|
|
865
|
+
* The canonical registration token for the client app that the message was
|
|
866
|
+
* processed and sent to. You should use this value as the registration token
|
|
867
|
+
* for future requests. Otherwise, future messages might be rejected.
|
|
868
|
+
*/
|
|
869
|
+
canonicalRegistrationToken?: string;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Interface representing the status of a message sent to an individual device
|
|
873
|
+
* via the FCM legacy APIs.
|
|
874
|
+
*
|
|
875
|
+
* See
|
|
876
|
+
* [Send to individual devices](/docs/cloud-messaging/admin/send-messages#send_to_individual_devices)
|
|
877
|
+
* for code samples and detailed documentation.
|
|
878
|
+
*/
|
|
879
|
+
export interface MessagingDevicesResponse {
|
|
880
|
+
canonicalRegistrationTokenCount: number;
|
|
881
|
+
failureCount: number;
|
|
882
|
+
multicastId: number;
|
|
883
|
+
results: MessagingDeviceResult[];
|
|
884
|
+
successCount: number;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Interface representing the server response from the
|
|
888
|
+
* {@link messaging.Messaging.sendToDeviceGroup `sendToDeviceGroup()`}
|
|
889
|
+
* method.
|
|
890
|
+
*
|
|
891
|
+
* See
|
|
892
|
+
* [Send messages to device groups](/docs/cloud-messaging/send-message?authuser=0#send_messages_to_device_groups)
|
|
893
|
+
* for code samples and detailed documentation.
|
|
894
|
+
*/
|
|
895
|
+
export interface MessagingDeviceGroupResponse {
|
|
896
|
+
/**
|
|
897
|
+
* The number of messages that could not be processed and resulted in an error.
|
|
898
|
+
*/
|
|
899
|
+
successCount: number;
|
|
900
|
+
/**
|
|
901
|
+
* The number of messages that could not be processed and resulted in an error.
|
|
902
|
+
*/
|
|
903
|
+
failureCount: number;
|
|
904
|
+
/**
|
|
905
|
+
* An array of registration tokens that failed to receive the message.
|
|
906
|
+
*/
|
|
907
|
+
failedRegistrationTokens: string[];
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Interface representing the server response from the legacy
|
|
911
|
+
* {@link messaging.Messaging.sendToTopic `sendToTopic()`} method.
|
|
912
|
+
*
|
|
913
|
+
* See
|
|
914
|
+
* [Send to a topic](/docs/cloud-messaging/admin/send-messages#send_to_a_topic)
|
|
915
|
+
* for code samples and detailed documentation.
|
|
916
|
+
*/
|
|
917
|
+
export interface MessagingTopicResponse {
|
|
918
|
+
/**
|
|
919
|
+
* The message ID for a successfully received request which FCM will attempt to
|
|
920
|
+
* deliver to all subscribed devices.
|
|
921
|
+
*/
|
|
922
|
+
messageId: number;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Interface representing the server response from the legacy
|
|
926
|
+
* {@link messaging.Messaging.sendToCondition `sendToCondition()`} method.
|
|
927
|
+
*
|
|
928
|
+
* See
|
|
929
|
+
* [Send to a condition](/docs/cloud-messaging/admin/send-messages#send_to_a_condition)
|
|
930
|
+
* for code samples and detailed documentation.
|
|
931
|
+
*/
|
|
932
|
+
export interface MessagingConditionResponse {
|
|
933
|
+
/**
|
|
934
|
+
* The message ID for a successfully received request which FCM will attempt to
|
|
935
|
+
* deliver to all subscribed devices.
|
|
936
|
+
*/
|
|
937
|
+
messageId: number;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Interface representing the server response from the
|
|
941
|
+
* {@link messaging.Messaging.subscribeToTopic `subscribeToTopic()`} and
|
|
942
|
+
* {@link messaging.Messaging.unsubscribeFromTopic `unsubscribeFromTopic()`}
|
|
943
|
+
* methods.
|
|
944
|
+
*
|
|
945
|
+
* See
|
|
946
|
+
* [Manage topics from the server](/docs/cloud-messaging/manage-topics)
|
|
947
|
+
* for code samples and detailed documentation.
|
|
948
|
+
*/
|
|
949
|
+
export interface MessagingTopicManagementResponse {
|
|
950
|
+
/**
|
|
951
|
+
* The number of registration tokens that could not be subscribed to the topic
|
|
952
|
+
* and resulted in an error.
|
|
953
|
+
*/
|
|
954
|
+
failureCount: number;
|
|
955
|
+
/**
|
|
956
|
+
* The number of registration tokens that were successfully subscribed to the
|
|
957
|
+
* topic.
|
|
958
|
+
*/
|
|
959
|
+
successCount: number;
|
|
960
|
+
/**
|
|
961
|
+
* An array of errors corresponding to the provided registration token(s). The
|
|
962
|
+
* length of this array will be equal to [`failureCount`](#failureCount).
|
|
963
|
+
*/
|
|
964
|
+
errors: FirebaseArrayIndexError[];
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Interface representing the server response from the
|
|
968
|
+
* {@link messaging.Messaging.sendAll `sendAll()`} and
|
|
969
|
+
* {@link messaging.Messaging.sendMulticast `sendMulticast()`} methods.
|
|
970
|
+
*/
|
|
971
|
+
export interface BatchResponse {
|
|
972
|
+
/**
|
|
973
|
+
* An array of responses, each corresponding to a message.
|
|
974
|
+
*/
|
|
975
|
+
responses: SendResponse[];
|
|
976
|
+
/**
|
|
977
|
+
* The number of messages that were successfully handed off for sending.
|
|
978
|
+
*/
|
|
979
|
+
successCount: number;
|
|
980
|
+
/**
|
|
981
|
+
* The number of messages that resulted in errors when sending.
|
|
982
|
+
*/
|
|
983
|
+
failureCount: number;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Interface representing the status of an individual message that was sent as
|
|
987
|
+
* part of a batch request.
|
|
988
|
+
*/
|
|
989
|
+
export interface SendResponse {
|
|
990
|
+
/**
|
|
991
|
+
* A boolean indicating if the message was successfully handed off to FCM or
|
|
992
|
+
* not. When true, the `messageId` attribute is guaranteed to be set. When
|
|
993
|
+
* false, the `error` attribute is guaranteed to be set.
|
|
994
|
+
*/
|
|
995
|
+
success: boolean;
|
|
996
|
+
/**
|
|
997
|
+
* A unique message ID string, if the message was handed off to FCM for
|
|
998
|
+
* delivery.
|
|
999
|
+
*
|
|
1000
|
+
*/
|
|
1001
|
+
messageId?: string;
|
|
1002
|
+
/**
|
|
1003
|
+
* An error, if the message was not handed off to FCM successfully.
|
|
1004
|
+
*/
|
|
1005
|
+
error?: FirebaseError;
|
|
1006
|
+
}
|
|
1007
|
+
export interface Messaging {
|
|
1008
|
+
/**
|
|
1009
|
+
* The {@link app.App app} associated with the current `Messaging` service
|
|
1010
|
+
* instance.
|
|
1011
|
+
*
|
|
1012
|
+
* @example
|
|
1013
|
+
* ```javascript
|
|
1014
|
+
* var app = messaging.app;
|
|
1015
|
+
* ```
|
|
1016
|
+
*/
|
|
1017
|
+
app: app.App;
|
|
1018
|
+
/**
|
|
1019
|
+
* Sends the given message via FCM.
|
|
1020
|
+
*
|
|
1021
|
+
* @param message The message payload.
|
|
1022
|
+
* @param dryRun Whether to send the message in the dry-run
|
|
1023
|
+
* (validation only) mode.
|
|
1024
|
+
* @return A promise fulfilled with a unique message ID
|
|
1025
|
+
* string after the message has been successfully handed off to the FCM
|
|
1026
|
+
* service for delivery.
|
|
1027
|
+
*/
|
|
1028
|
+
send(message: Message, dryRun?: boolean): Promise<string>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Sends all the messages in the given array via Firebase Cloud Messaging.
|
|
1031
|
+
* Employs batching to send the entire list as a single RPC call. Compared
|
|
1032
|
+
* to the `send()` method, this method is a significantly more efficient way
|
|
1033
|
+
* to send multiple messages.
|
|
1034
|
+
*
|
|
1035
|
+
* The responses list obtained from the return value
|
|
1036
|
+
* corresponds to the order of tokens in the `MulticastMessage`. An error
|
|
1037
|
+
* from this method indicates a total failure -- i.e. none of the messages in
|
|
1038
|
+
* the list could be sent. Partial failures are indicated by a `BatchResponse`
|
|
1039
|
+
* return value.
|
|
1040
|
+
*
|
|
1041
|
+
* @param messages A non-empty array
|
|
1042
|
+
* containing up to 500 messages.
|
|
1043
|
+
* @param dryRun Whether to send the messages in the dry-run
|
|
1044
|
+
* (validation only) mode.
|
|
1045
|
+
* @return A Promise fulfilled with an object representing the result of the
|
|
1046
|
+
* send operation.
|
|
1047
|
+
*/
|
|
1048
|
+
sendAll(messages: Array<Message>, dryRun?: boolean): Promise<BatchResponse>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Sends the given multicast message to all the FCM registration tokens
|
|
1051
|
+
* specified in it.
|
|
1052
|
+
*
|
|
1053
|
+
* This method uses the `sendAll()` API under the hood to send the given
|
|
1054
|
+
* message to all the target recipients. The responses list obtained from the
|
|
1055
|
+
* return value corresponds to the order of tokens in the `MulticastMessage`.
|
|
1056
|
+
* An error from this method indicates a total failure -- i.e. the message was
|
|
1057
|
+
* not sent to any of the tokens in the list. Partial failures are indicated by
|
|
1058
|
+
* a `BatchResponse` return value.
|
|
1059
|
+
*
|
|
1060
|
+
* @param message A multicast message
|
|
1061
|
+
* containing up to 500 tokens.
|
|
1062
|
+
* @param dryRun Whether to send the message in the dry-run
|
|
1063
|
+
* (validation only) mode.
|
|
1064
|
+
* @return A Promise fulfilled with an object representing the result of the
|
|
1065
|
+
* send operation.
|
|
1066
|
+
*/
|
|
1067
|
+
sendMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
|
|
1068
|
+
/**
|
|
1069
|
+
* Sends an FCM message to a single device corresponding to the provided
|
|
1070
|
+
* registration token.
|
|
1071
|
+
*
|
|
1072
|
+
* See
|
|
1073
|
+
* [Send to individual devices](/docs/cloud-messaging/admin/legacy-fcm#send_to_individual_devices)
|
|
1074
|
+
* for code samples and detailed documentation. Takes either a
|
|
1075
|
+
* `registrationToken` to send to a single device or a
|
|
1076
|
+
* `registrationTokens` parameter containing an array of tokens to send
|
|
1077
|
+
* to multiple devices.
|
|
1078
|
+
*
|
|
1079
|
+
* @param registrationToken A device registration token or an array of
|
|
1080
|
+
* device registration tokens to which the message should be sent.
|
|
1081
|
+
* @param payload The message payload.
|
|
1082
|
+
* @param options Optional options to
|
|
1083
|
+
* alter the message.
|
|
1084
|
+
*
|
|
1085
|
+
* @return A promise fulfilled with the server's response after the message
|
|
1086
|
+
* has been sent.
|
|
1087
|
+
*/
|
|
1088
|
+
sendToDevice(registrationToken: string | string[], payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingDevicesResponse>;
|
|
1089
|
+
/**
|
|
1090
|
+
* Sends an FCM message to a device group corresponding to the provided
|
|
1091
|
+
* notification key.
|
|
1092
|
+
*
|
|
1093
|
+
* See
|
|
1094
|
+
* [Send to a device group](/docs/cloud-messaging/admin/legacy-fcm#send_to_a_device_group)
|
|
1095
|
+
* for code samples and detailed documentation.
|
|
1096
|
+
*
|
|
1097
|
+
* @param notificationKey The notification key for the device group to
|
|
1098
|
+
* which to send the message.
|
|
1099
|
+
* @param payload The message payload.
|
|
1100
|
+
* @param options Optional options to
|
|
1101
|
+
* alter the message.
|
|
1102
|
+
*
|
|
1103
|
+
* @return A promise fulfilled with the server's response after the message
|
|
1104
|
+
* has been sent.
|
|
1105
|
+
*/
|
|
1106
|
+
sendToDeviceGroup(notificationKey: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingDeviceGroupResponse>;
|
|
1107
|
+
/**
|
|
1108
|
+
* Sends an FCM message to a topic.
|
|
1109
|
+
*
|
|
1110
|
+
* See
|
|
1111
|
+
* [Send to a topic](/docs/cloud-messaging/admin/legacy-fcm#send_to_a_topic)
|
|
1112
|
+
* for code samples and detailed documentation.
|
|
1113
|
+
*
|
|
1114
|
+
* @param topic The topic to which to send the message.
|
|
1115
|
+
* @param payload The message payload.
|
|
1116
|
+
* @param options Optional options to
|
|
1117
|
+
* alter the message.
|
|
1118
|
+
*
|
|
1119
|
+
* @return A promise fulfilled with the server's response after the message
|
|
1120
|
+
* has been sent.
|
|
1121
|
+
*/
|
|
1122
|
+
sendToTopic(topic: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingTopicResponse>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Sends an FCM message to a condition.
|
|
1125
|
+
*
|
|
1126
|
+
* See
|
|
1127
|
+
* [Send to a condition](/docs/cloud-messaging/admin/legacy-fcm#send_to_a_condition)
|
|
1128
|
+
* for code samples and detailed documentation.
|
|
1129
|
+
*
|
|
1130
|
+
* @param condition The condition determining to which topics to send
|
|
1131
|
+
* the message.
|
|
1132
|
+
* @param payload The message payload.
|
|
1133
|
+
* @param options Optional options to
|
|
1134
|
+
* alter the message.
|
|
1135
|
+
*
|
|
1136
|
+
* @return A promise fulfilled with the server's response after the message
|
|
1137
|
+
* has been sent.
|
|
1138
|
+
*/
|
|
1139
|
+
sendToCondition(condition: string, payload: MessagingPayload, options?: MessagingOptions): Promise<MessagingConditionResponse>;
|
|
1140
|
+
/**
|
|
1141
|
+
* Subscribes a device to an FCM topic.
|
|
1142
|
+
*
|
|
1143
|
+
* See [Subscribe to a
|
|
1144
|
+
* topic](/docs/cloud-messaging/manage-topics#suscribe_and_unsubscribe_using_the)
|
|
1145
|
+
* for code samples and detailed documentation. Optionally, you can provide an
|
|
1146
|
+
* array of tokens to subscribe multiple devices.
|
|
1147
|
+
*
|
|
1148
|
+
* @param registrationTokens A token or array of registration tokens
|
|
1149
|
+
* for the devices to subscribe to the topic.
|
|
1150
|
+
* @param topic The topic to which to subscribe.
|
|
1151
|
+
*
|
|
1152
|
+
* @return A promise fulfilled with the server's response after the device has been
|
|
1153
|
+
* subscribed to the topic.
|
|
1154
|
+
*/
|
|
1155
|
+
subscribeToTopic(registrationTokens: string | string[], topic: string): Promise<MessagingTopicManagementResponse>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Unsubscribes a device from an FCM topic.
|
|
1158
|
+
*
|
|
1159
|
+
* See [Unsubscribe from a
|
|
1160
|
+
* topic](/docs/cloud-messaging/admin/manage-topic-subscriptions#unsubscribe_from_a_topic)
|
|
1161
|
+
* for code samples and detailed documentation. Optionally, you can provide an
|
|
1162
|
+
* array of tokens to unsubscribe multiple devices.
|
|
1163
|
+
*
|
|
1164
|
+
* @param registrationTokens A device registration token or an array of
|
|
1165
|
+
* device registration tokens to unsubscribe from the topic.
|
|
1166
|
+
* @param topic The topic from which to unsubscribe.
|
|
1167
|
+
*
|
|
1168
|
+
* @return A promise fulfilled with the server's response after the device has been
|
|
1169
|
+
* unsubscribed from the topic.
|
|
1170
|
+
*/
|
|
1171
|
+
unsubscribeFromTopic(registrationTokens: string | string[], topic: string): Promise<MessagingTopicManagementResponse>;
|
|
1172
|
+
}
|
|
1173
|
+
export {};
|
|
1174
|
+
}
|