From 6a3db24886a0e481af05b4aea460b7debc4d5aaf Mon Sep 17 00:00:00 2001 From: Mertcan Mermerkaya Date: Fri, 1 Jun 2018 11:55:20 +0100 Subject: [PATCH] Update Webpush types in Messaging Webpush Notification is a struct now: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushconfig --- src/index.d.ts | 11 +++++------ src/messaging/messaging.ts | 5 ++--- test/unit/messaging/messaging.spec.ts | 16 ++++++++++++++++ tsconfig.json | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index cf242d5f29..75d5be15b1 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -438,18 +438,17 @@ declare namespace admin.messaging { title?: string; body?: string; }; - + type WebpushConfig = { headers?: {[key: string]: string}; data?: {[key: string]: string}; notification?: WebpushNotification; }; - - type WebpushNotification = { + + interface WebpushNotification extends NotificationOptions { title?: string; - body?: string; - icon?: string; - }; + [key: string]: any; + } type DataMessagePayload = { [key: string]: string; diff --git a/src/messaging/messaging.ts b/src/messaging/messaging.ts index c112857aa5..2153f00808 100644 --- a/src/messaging/messaging.ts +++ b/src/messaging/messaging.ts @@ -129,10 +129,9 @@ export interface WebpushConfig { notification?: WebpushNotification; } -export interface WebpushNotification { +export interface WebpushNotification extends NotificationOptions { title?: string; - body?: string; - icon?: string; + [key: string]: any; } export interface ApnsConfig { diff --git a/test/unit/messaging/messaging.spec.ts b/test/unit/messaging/messaging.spec.ts index d40d90f51b..09de589def 100644 --- a/test/unit/messaging/messaging.spec.ts +++ b/test/unit/messaging/messaging.spec.ts @@ -2236,6 +2236,22 @@ describe('Messaging', () => { title: 'test.title', body: 'test.body', icon: 'test.icon', + actions: [{ + action: 'test.action.1', + title: 'test.action.1.title', + icon: 'test.action.1.icon', + }, { + action: 'test.action.2', + title: 'test.action.2.title', + icon: 'test.action.2.icon', + }], + badge: 'test.badge', + data: { + key: 'value', + }, + dir: 'auto', + image: 'test.image', + requireInteraction: true, }, }, }, diff --git a/tsconfig.json b/tsconfig.json index 76c69140fc..6b177e9a30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es5", "noImplicitAny": false, - "lib": ["es5", "es2015.promise", "es2015"], + "lib": ["es5", "es2015.promise", "es2015", "dom"], "outDir": "lib", // We manually craft typings in src/index.d.ts instead of auto-generating them. // "declaration": true,