Skip to content

Commit

Permalink
feat(fcm): Add directBootOk field to AndroidConfig (#2745)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahirumaramba authored Oct 30, 2024
1 parent 8d49b7e commit f33ccd1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions etc/firebase-admin.messaging.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface AndroidConfig {
data?: {
[key: string]: string;
};
directBootOk?: boolean;
fcmOptions?: AndroidFcmOptions;
notification?: AndroidNotification;
priority?: ('high' | 'normal');
Expand Down
6 changes: 6 additions & 0 deletions src/messaging/messaging-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/messaging/messaging-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
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 @@ -45,6 +45,7 @@ const message: Message = {
},
android: {
restrictedPackageName: 'com.google.firebase.testing',
directBootOk: true,
notification: {
title: 'test.title',
ticker: 'test.ticker',
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 @@ -3961,6 +3961,7 @@ describe('Messaging', () => {
android: {
collapseKey: 'test.key',
restrictedPackageName: 'test.package',
directBootOk: true,
notification: {
clickAction: 'test.click.action',
titleLocKey: 'title.loc.key',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -4043,6 +4045,7 @@ describe('Messaging', () => {
priority: 'high',
collapseKey: 'test.key',
restrictedPackageName: 'test.package',
directBootOk: true,
ttl: 5,
data: {
k1: 'v1',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit f33ccd1

Please sign in to comment.