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