Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions etc/firebase-admin.messaging.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface AndroidNotification {
localOnly?: boolean;
notificationCount?: number;
priority?: ('min' | 'low' | 'default' | 'high' | 'max');
proxy?: ('allow' | 'deny' | 'if_priority_lowered');
sound?: string;
sticky?: boolean;
tag?: string;
Expand Down
10 changes: 9 additions & 1 deletion src/messaging/messaging-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ export interface AndroidNotification {

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

Expand All @@ -608,6 +609,13 @@ export interface AndroidNotification {
* 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');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/messaging/messaging-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ function validateAndroidNotification(notification: AndroidNotification | undefin
(notification as any).priority = priority;
}

if (typeof notification.proxy !== 'undefined') {
const proxy = notification.proxy.toUpperCase();
(notification as any).proxy = proxy;
}

if (typeof notification.visibility !== 'undefined') {
const visibility = notification.visibility.toUpperCase();
(notification as any).visibility = visibility;
Expand Down
1 change: 1 addition & 0 deletions test/integration/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const message: Message = {
},
defaultLightSettings: false,
notificationCount: 1,
proxy: 'if_priority_lowered',
},
},
apns: {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/messaging/messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,7 @@ describe('Messaging', () => {
ticker: 'test.ticker',
sticky: true,
visibility: 'private',
proxy: 'deny',
},
},
},
Expand All @@ -1871,6 +1872,7 @@ describe('Messaging', () => {
ticker: 'test.ticker',
sticky: true,
visibility: 'PRIVATE',
proxy: 'DENY'
},
},
},
Expand Down Expand Up @@ -2001,6 +2003,7 @@ describe('Messaging', () => {
},
defaultLightSettings: false,
notificationCount: 1,
proxy: 'if_priority_lowered',
},
fcmOptions: {
analyticsLabel: 'test.analytics',
Expand Down Expand Up @@ -2053,6 +2056,7 @@ describe('Messaging', () => {
},
default_light_settings: false,
notification_count: 1,
proxy: 'IF_PRIORITY_LOWERED',
},
fcmOptions: {
analyticsLabel: 'test.analytics',
Expand Down