Skip to content

Commit 6a3db24

Browse files
committed
Update Webpush types in Messaging
Webpush Notification is a struct now: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushconfig
1 parent 2e1f464 commit 6a3db24

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

src/index.d.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,17 @@ declare namespace admin.messaging {
438438
title?: string;
439439
body?: string;
440440
};
441-
441+
442442
type WebpushConfig = {
443443
headers?: {[key: string]: string};
444444
data?: {[key: string]: string};
445445
notification?: WebpushNotification;
446446
};
447-
448-
type WebpushNotification = {
447+
448+
interface WebpushNotification extends NotificationOptions {
449449
title?: string;
450-
body?: string;
451-
icon?: string;
452-
};
450+
[key: string]: any;
451+
}
453452

454453
type DataMessagePayload = {
455454
[key: string]: string;

src/messaging/messaging.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ export interface WebpushConfig {
129129
notification?: WebpushNotification;
130130
}
131131

132-
export interface WebpushNotification {
132+
export interface WebpushNotification extends NotificationOptions {
133133
title?: string;
134-
body?: string;
135-
icon?: string;
134+
[key: string]: any;
136135
}
137136

138137
export interface ApnsConfig {

test/unit/messaging/messaging.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,22 @@ describe('Messaging', () => {
22362236
title: 'test.title',
22372237
body: 'test.body',
22382238
icon: 'test.icon',
2239+
actions: [{
2240+
action: 'test.action.1',
2241+
title: 'test.action.1.title',
2242+
icon: 'test.action.1.icon',
2243+
}, {
2244+
action: 'test.action.2',
2245+
title: 'test.action.2.title',
2246+
icon: 'test.action.2.icon',
2247+
}],
2248+
badge: 'test.badge',
2249+
data: {
2250+
key: 'value',
2251+
},
2252+
dir: 'auto',
2253+
image: 'test.image',
2254+
requireInteraction: true,
22392255
},
22402256
},
22412257
},

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"module": "commonjs",
44
"target": "es5",
55
"noImplicitAny": false,
6-
"lib": ["es5", "es2015.promise", "es2015"],
6+
"lib": ["es5", "es2015.promise", "es2015", "dom"],
77
"outDir": "lib",
88
// We manually craft typings in src/index.d.ts instead of auto-generating them.
99
// "declaration": true,

0 commit comments

Comments
 (0)