diff --git a/etc/firebase-admin.messaging.api.md b/etc/firebase-admin.messaging.api.md index b4ee30a9f0..f0adaa0f35 100644 --- a/etc/firebase-admin.messaging.api.md +++ b/etc/firebase-admin.messaging.api.md @@ -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; diff --git a/src/messaging/messaging-api.ts b/src/messaging/messaging-api.ts index 01c20c7291..69c16382d5 100644 --- a/src/messaging/messaging-api.ts +++ b/src/messaging/messaging-api.ts @@ -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'); @@ -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'); } /** diff --git a/src/messaging/messaging-internal.ts b/src/messaging/messaging-internal.ts index 6f1f7a3c74..725769bb32 100644 --- a/src/messaging/messaging-internal.ts +++ b/src/messaging/messaging-internal.ts @@ -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; diff --git a/test/integration/messaging.spec.ts b/test/integration/messaging.spec.ts index 409261f6aa..97adc8e008 100644 --- a/test/integration/messaging.spec.ts +++ b/test/integration/messaging.spec.ts @@ -64,6 +64,7 @@ const message: Message = { }, defaultLightSettings: false, notificationCount: 1, + proxy: 'if_priority_lowered', }, }, apns: { diff --git a/test/unit/messaging/messaging.spec.ts b/test/unit/messaging/messaging.spec.ts index 1ea0c059de..79942f73d2 100644 --- a/test/unit/messaging/messaging.spec.ts +++ b/test/unit/messaging/messaging.spec.ts @@ -1855,6 +1855,7 @@ describe('Messaging', () => { ticker: 'test.ticker', sticky: true, visibility: 'private', + proxy: 'deny', }, }, }, @@ -1871,6 +1872,7 @@ describe('Messaging', () => { ticker: 'test.ticker', sticky: true, visibility: 'PRIVATE', + proxy: 'DENY' }, }, }, @@ -2001,6 +2003,7 @@ describe('Messaging', () => { }, defaultLightSettings: false, notificationCount: 1, + proxy: 'if_priority_lowered', }, fcmOptions: { analyticsLabel: 'test.analytics', @@ -2053,6 +2056,7 @@ describe('Messaging', () => { }, default_light_settings: false, notification_count: 1, + proxy: 'IF_PRIORITY_LOWERED', }, fcmOptions: { analyticsLabel: 'test.analytics',