Skip to content

Commit 4eb71bd

Browse files
authored
Merge pull request #2135 from rittaschool/add-fcm-data-messages
Add fcm data messages (#2007)
2 parents 6aadff9 + 78c5aa8 commit 4eb71bd

File tree

6 files changed

+99
-198
lines changed

6 files changed

+99
-198
lines changed

docs/docs/channels/push/fcm.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ novu.trigger('event-name', {
2323
subscriberId: '...',
2424
},
2525
payload: {
26-
abc: 'def',
26+
abc: 'def', // If the notification is a data notification, the payload will be sent as the data
27+
},
28+
overrides: {
29+
fcm: {
30+
type: 'notification',
31+
// type: 'data' => will turn this into a FCM data notification, where the payload is sent as a data notification
32+
data: {
33+
key: 'value',
34+
// If type is "notification", you can use the "data" override to send notification messages with optional data payload
35+
},
36+
},
2737
},
2838
});
2939
```
@@ -38,7 +48,6 @@ import { Novu, PushProviderIdEnum } from '@novu/node';
3848

3949
const novu = new Novu(process.env.NOVU_API_KEY);
4050

41-
const body = req.body; // From your HTTPS listener
4251
await novu.subscribers.setCredentials('subscriberId', PushProviderIdEnum.FCM, {
4352
deviceTokens: ['token1', 'token2'],
4453
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"@commitlint/cli": "17.0.1",
6969
"@commitlint/config-angular": "^13.2.0",
7070
"@commitlint/config-conventional": "17.0.0",
71+
"@cspell/eslint-plugin": "^6.14.3",
7172
"@nrwl/cli": "13.8.5",
7273
"@nrwl/eslint-plugin-nx": "13.8.5",
7374
"@nrwl/jest": "13.8.5",
@@ -92,9 +93,9 @@
9293
"cspell": "^4.2.8",
9394
"cypress-intellij-reporter": "^0.0.6",
9495
"cz-conventional-changelog": "3.3.0",
96+
"deep-extend": "^0.6.0",
9597
"detect-port": "^1.3.0",
9698
"eslint": "7.32.0",
97-
"@cspell/eslint-plugin": "^6.14.3",
9899
"eslint-config-airbnb-typescript": "16.1.4",
99100
"eslint-config-prettier": "^7.2.0",
100101
"eslint-import-resolver-webpack": "^0.13.2",

packages/node/src/lib/events/events.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export type ITriggerOverrideDelayAction = {
6262
};
6363

6464
export type ITriggerOverrideFCM = {
65+
type?: 'notification' | 'data';
6566
tag?: string;
6667
body?: string;
6768
icon?: string;

packages/stateless/src/lib/provider/provider.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export interface IPushOptions {
3232
content: string;
3333
payload: object;
3434
overrides?: {
35+
type?: 'notification' | 'data';
36+
data?: { [key: string]: string };
3537
tag?: string;
3638
body?: string;
3739
icon?: string;

0 commit comments

Comments
 (0)