From f33ccd1d5abcb6af46398432cd7a50ae10b0510c Mon Sep 17 00:00:00 2001 From: Lahiru Maramba Date: Wed, 30 Oct 2024 13:07:06 -0400 Subject: [PATCH] feat(fcm): Add directBootOk field to AndroidConfig (#2745) --- etc/firebase-admin.messaging.api.md | 1 + src/messaging/messaging-api.ts | 6 ++++++ src/messaging/messaging-internal.ts | 1 + test/integration/messaging.spec.ts | 1 + test/unit/messaging/messaging.spec.ts | 4 ++++ 5 files changed, 13 insertions(+) diff --git a/etc/firebase-admin.messaging.api.md b/etc/firebase-admin.messaging.api.md index 78cb17c5ce..f78156eb5a 100644 --- a/etc/firebase-admin.messaging.api.md +++ b/etc/firebase-admin.messaging.api.md @@ -14,6 +14,7 @@ export interface AndroidConfig { data?: { [key: string]: string; }; + directBootOk?: boolean; fcmOptions?: AndroidFcmOptions; notification?: AndroidNotification; priority?: ('high' | 'normal'); diff --git a/src/messaging/messaging-api.ts b/src/messaging/messaging-api.ts index c8b5ce1781..8d85faa7a7 100644 --- a/src/messaging/messaging-api.ts +++ b/src/messaging/messaging-api.ts @@ -418,6 +418,12 @@ export interface AndroidConfig { * 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; } /** diff --git a/src/messaging/messaging-internal.ts b/src/messaging/messaging-internal.ts index c0379fac70..6f1f7a3c74 100644 --- a/src/messaging/messaging-internal.ts +++ b/src/messaging/messaging-internal.ts @@ -398,6 +398,7 @@ function validateAndroidConfig(config: AndroidConfig | undefined): void { const propertyMappings = { collapseKey: 'collapse_key', restrictedPackageName: 'restricted_package_name', + directBootOk: 'direct_boot_ok', }; renameProperties(config, propertyMappings); } diff --git a/test/integration/messaging.spec.ts b/test/integration/messaging.spec.ts index dc6d662f0b..409261f6aa 100644 --- a/test/integration/messaging.spec.ts +++ b/test/integration/messaging.spec.ts @@ -45,6 +45,7 @@ const message: Message = { }, android: { restrictedPackageName: 'com.google.firebase.testing', + directBootOk: true, notification: { title: 'test.title', ticker: 'test.ticker', diff --git a/test/unit/messaging/messaging.spec.ts b/test/unit/messaging/messaging.spec.ts index a391dceb28..4fb5264d5c 100644 --- a/test/unit/messaging/messaging.spec.ts +++ b/test/unit/messaging/messaging.spec.ts @@ -3961,6 +3961,7 @@ describe('Messaging', () => { android: { collapseKey: 'test.key', restrictedPackageName: 'test.package', + directBootOk: true, notification: { clickAction: 'test.click.action', titleLocKey: 'title.loc.key', @@ -3988,6 +3989,7 @@ describe('Messaging', () => { android: { collapse_key: 'test.key', restricted_package_name: 'test.package', + direct_boot_ok: true, notification: { click_action: 'test.click.action', title_loc_key: 'title.loc.key', @@ -4043,6 +4045,7 @@ describe('Messaging', () => { priority: 'high', collapseKey: 'test.key', restrictedPackageName: 'test.package', + directBootOk: true, ttl: 5, data: { k1: 'v1', @@ -4089,6 +4092,7 @@ describe('Messaging', () => { priority: 'high', collapse_key: 'test.key', restricted_package_name: 'test.package', + direct_boot_ok: true, ttl: '0.005000000s', // 5 ms = 5,000,000 ns data: { k1: 'v1',