Skip to content

Commit a46086b

Browse files
authored
feat(fcm): Support proxy field in FCM AndroidNotification (#2874)
* feat(fcm): Support `proxy` field on `AndroidNotification` * update doc string * fix: Update `proxy` and `visibility` doc string with TW suggestion
1 parent d0d40bf commit a46086b

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

Diff for: etc/firebase-admin.messaging.api.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface AndroidNotification {
4343
localOnly?: boolean;
4444
notificationCount?: number;
4545
priority?: ('min' | 'low' | 'default' | 'high' | 'max');
46+
proxy?: ('allow' | 'deny' | 'if_priority_lowered');
4647
sound?: string;
4748
sticky?: boolean;
4849
tag?: string;

Diff for: src/messaging/messaging-api.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ export interface AndroidNotification {
593593

594594
/**
595595
* Sets the visibility of the notification. Must be either `private`, `public`,
596-
* or `secret`. If unspecified, defaults to `private`.
596+
* or `secret`. If unspecified, it remains undefined in the Admin SDK, and
597+
* defers to the FCM backend's default mapping.
597598
*/
598599
visibility?: ('private' | 'public' | 'secret');
599600

@@ -608,6 +609,13 @@ export interface AndroidNotification {
608609
* displayed on the long-press menu each time a new notification arrives.
609610
*/
610611
notificationCount?: number;
612+
613+
/**
614+
* Sets if this notification should attempt to be proxied. Must be either
615+
* `allow`, `deny` or `if_priority_lowered`. If unspecified, it remains
616+
* undefined in the Admin SDK, and defers to the FCM backend's default mapping.
617+
*/
618+
proxy?: ('allow' | 'deny' | 'if_priority_lowered');
611619
}
612620

613621
/**

Diff for: src/messaging/messaging-internal.ts

+5
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,11 @@ function validateAndroidNotification(notification: AndroidNotification | undefin
475475
(notification as any).priority = priority;
476476
}
477477

478+
if (typeof notification.proxy !== 'undefined') {
479+
const proxy = notification.proxy.toUpperCase();
480+
(notification as any).proxy = proxy;
481+
}
482+
478483
if (typeof notification.visibility !== 'undefined') {
479484
const visibility = notification.visibility.toUpperCase();
480485
(notification as any).visibility = visibility;

Diff for: test/integration/messaging.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const message: Message = {
6464
},
6565
defaultLightSettings: false,
6666
notificationCount: 1,
67+
proxy: 'if_priority_lowered',
6768
},
6869
},
6970
apns: {

Diff for: test/unit/messaging/messaging.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,7 @@ describe('Messaging', () => {
18551855
ticker: 'test.ticker',
18561856
sticky: true,
18571857
visibility: 'private',
1858+
proxy: 'deny',
18581859
},
18591860
},
18601861
},
@@ -1871,6 +1872,7 @@ describe('Messaging', () => {
18711872
ticker: 'test.ticker',
18721873
sticky: true,
18731874
visibility: 'PRIVATE',
1875+
proxy: 'DENY'
18741876
},
18751877
},
18761878
},
@@ -2001,6 +2003,7 @@ describe('Messaging', () => {
20012003
},
20022004
defaultLightSettings: false,
20032005
notificationCount: 1,
2006+
proxy: 'if_priority_lowered',
20042007
},
20052008
fcmOptions: {
20062009
analyticsLabel: 'test.analytics',
@@ -2053,6 +2056,7 @@ describe('Messaging', () => {
20532056
},
20542057
default_light_settings: false,
20552058
notification_count: 1,
2059+
proxy: 'IF_PRIORITY_LOWERED',
20562060
},
20572061
fcmOptions: {
20582062
analyticsLabel: 'test.analytics',

0 commit comments

Comments
 (0)