We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17e7fa8 commit e4b66adCopy full SHA for e4b66ad
api/server/services/fcm.ts
@@ -0,0 +1,30 @@
1
+import fetch from 'node-fetch';
2
+
3
+export interface FcmNotification {
4
+ title: string;
5
+ text: string;
6
+}
7
8
+export class FcmService {
9
+ private key: string = Meteor.settings.private.fcm.key;
10
11
+ sendNotification(notification: FcmNotification, destination: string) {
12
+ const body = {
13
+ notification: notification,
14
+ to: destination
15
+ };
16
17
+ const options = {
18
+ method: 'POST',
19
+ body: JSON.stringify(body),
20
+ headers: {
21
+ "Content-Type": "application/json",
22
+ Authorization: `key=${this.key}`
23
+ },
24
25
26
+ return fetch("https://fcm.googleapis.com/fcm/send", options);
27
+ }
28
29
30
+export const fcmService = new FcmService();
0 commit comments