Skip to content

Commit 3e512af

Browse files
committed
feat(fcm): Support proxy field on AndroidNotification
1 parent 8beb1a3 commit 3e512af

5 files changed

Lines changed: 18 additions & 0 deletions

File tree

etc/firebase-admin.messaging.api.md

Lines changed: 1 addition & 0 deletions
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;

src/messaging/messaging-api.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,13 @@ export interface AndroidNotification {
608608
* displayed on the long-press menu each time a new notification arrives.
609609
*/
610610
notificationCount?: number;
611+
612+
/**
613+
* Sets if this notification should be proxied. Must be either `allow`,
614+
* `deny` or `if_priority_lowered`. If unspecified, defaults to
615+
* `if_priority_lowered`.
616+
*/
617+
proxy?: ('allow' | 'deny' | 'if_priority_lowered');
611618
}
612619

613620
/**

src/messaging/messaging-internal.ts

Lines changed: 5 additions & 0 deletions
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;

test/integration/messaging.spec.ts

Lines changed: 1 addition & 0 deletions
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: {

test/unit/messaging/messaging.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,7 @@ describe('Messaging', () => {
18241824
ticker: 'test.ticker',
18251825
sticky: true,
18261826
visibility: 'private',
1827+
proxy: 'deny',
18271828
},
18281829
},
18291830
},
@@ -1840,6 +1841,7 @@ describe('Messaging', () => {
18401841
ticker: 'test.ticker',
18411842
sticky: true,
18421843
visibility: 'PRIVATE',
1844+
proxy: 'DENY'
18431845
},
18441846
},
18451847
},
@@ -1970,6 +1972,7 @@ describe('Messaging', () => {
19701972
},
19711973
defaultLightSettings: false,
19721974
notificationCount: 1,
1975+
proxy: 'if_priority_lowered',
19731976
},
19741977
fcmOptions: {
19751978
analyticsLabel: 'test.analytics',
@@ -2022,6 +2025,7 @@ describe('Messaging', () => {
20222025
},
20232026
default_light_settings: false,
20242027
notification_count: 1,
2028+
proxy: 'IF_PRIORITY_LOWERED',
20252029
},
20262030
fcmOptions: {
20272031
analyticsLabel: 'test.analytics',

0 commit comments

Comments
 (0)