aeremmiddleware 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -28
- package/dist/Finance/ingenicoHtml.js +114 -114
- package/package.json +21 -20
- package/src/Finance/Ingenico.types.ts +21 -21
- package/src/Finance/crimeCheck.ts +135 -135
- package/src/Finance/crimecheck.types.ts +31 -31
- package/src/Finance/encrypt.ts +18 -18
- package/src/Finance/idfy.ts +542 -542
- package/src/Finance/index.ts +13 -13
- package/src/Finance/ingenico.ts +110 -110
- package/src/Finance/ingenicoHtml.ts +119 -119
- package/src/Finance/novel.ts +226 -226
- package/src/Finance/novel.types.ts +24 -24
- package/src/Finance/qbrik.ts +822 -822
- package/src/Finance/qbrik.types.ts +81 -81
- package/src/Socials/Sms.types.ts +9 -9
- package/src/Socials/SmsSender.ts +78 -78
- package/src/Socials/Whatsapp.types.ts +95 -95
- package/src/Socials/index.ts +6 -6
- package/src/Socials/whatsApp.ts +188 -188
- package/src/index.ts +7 -7
- package/src/pushNotification/pushNotificationFCM.ts +35 -35
- package/tsconfig.json +111 -111
- package/dist/Finance/qbrik.d.ts +0 -100
- package/dist/Finance/qbrik.js +0 -506
- package/dist/Finance/qbrik.js.map +0 -1
- package/dist/Finance/qbrik.types.d.ts +0 -76
- package/dist/Finance/qbrik.types.js +0 -3
- package/dist/Finance/qbrik.types.js.map +0 -1
- package/dist/pushNotification/pushNotificationFCM.d.ts +0 -1
- package/dist/pushNotification/pushNotificationFCM.js +0 -42
- package/dist/pushNotification/pushNotificationFCM.js.map +0 -1
package/src/Socials/whatsApp.ts
CHANGED
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { DemoBody, EmiReminderAug2023, Provider, WhatsAppTemplateDemoBody } from "./Whatsapp.types";
|
|
3
|
-
|
|
4
|
-
class WhatsappMessageSender {
|
|
5
|
-
private exotelSid: string;
|
|
6
|
-
private exotelToken: string;
|
|
7
|
-
private exotelApiKey: string;
|
|
8
|
-
private whatsappApiUrl!: string;
|
|
9
|
-
private provider: string;
|
|
10
|
-
|
|
11
|
-
constructor(payload: {
|
|
12
|
-
exotelSid: string;
|
|
13
|
-
exotelToken: string;
|
|
14
|
-
exotelApiKey: string;
|
|
15
|
-
provider: string;
|
|
16
|
-
}) {
|
|
17
|
-
const { exotelSid, exotelToken, exotelApiKey, provider } = payload;
|
|
18
|
-
this.exotelSid = exotelSid;
|
|
19
|
-
this.exotelToken = exotelToken;
|
|
20
|
-
this.exotelApiKey = exotelApiKey;
|
|
21
|
-
this.provider = provider;
|
|
22
|
-
|
|
23
|
-
if (this.provider === Provider.EXOTEL) {
|
|
24
|
-
this.whatsappApiUrl = `https://${exotelApiKey}:${exotelToken}@api.exotel.com/v2/accounts/${exotelSid}/messages`;
|
|
25
|
-
} else if (this.provider === Provider.GUPSHUP) {
|
|
26
|
-
// Define the URL for Gupshup API
|
|
27
|
-
// this.gupshupApiUrl = ...;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async getTemplates() {
|
|
32
|
-
const request = await axios.get(
|
|
33
|
-
`https://${this.exotelApiKey}:${this.exotelToken}@api.exotel.com/v2/accounts/${this.exotelSid}/templates?waba_id=114033855070320`
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return request.data.response.whatsapp.templates;
|
|
37
|
-
}
|
|
38
|
-
getUniquePlaceholderCount(str: string) {
|
|
39
|
-
const arr:Array<string> = [];
|
|
40
|
-
str.split("{{").map((s) => arr.push(...s.split("}}")));
|
|
41
|
-
const placeholders: Array<string> = arr.filter(
|
|
42
|
-
(i) => i.match(/[0-9]+/) && !isNaN(Number(i))
|
|
43
|
-
);
|
|
44
|
-
return [...new Set(placeholders)].length;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
validateTemplatePayload(template:EmiReminderAug2023, payload:any) {
|
|
48
|
-
const templateComponents = template.data.components;
|
|
49
|
-
if (templateComponents.length != 2) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const [headerTemplate, bodyTemplate] = templateComponents;
|
|
54
|
-
//this checks if placeholder is correct or not
|
|
55
|
-
for (let index = 0; index < payload.whatsapp.messages.length; index++) {
|
|
56
|
-
const message = payload.whatsapp.messages[index];
|
|
57
|
-
const payloadComponents = message.content.template.components;
|
|
58
|
-
for (let index2 = 0; index2 < payloadComponents.length; index2++) {
|
|
59
|
-
const payloadComponent = payloadComponents[index2];
|
|
60
|
-
// validate template header
|
|
61
|
-
if (payloadComponent.type === headerTemplate.type.toLowerCase()) {
|
|
62
|
-
const headerPlaceholdersCount = this.getUniquePlaceholderCount(
|
|
63
|
-
headerTemplate.text
|
|
64
|
-
);
|
|
65
|
-
if (payloadComponent.parameters.length != headerPlaceholdersCount) {
|
|
66
|
-
console.log("invalid header");
|
|
67
|
-
throw new Error("header count mismatch");
|
|
68
|
-
} else {
|
|
69
|
-
// header validated
|
|
70
|
-
// TODO: add more validations if required
|
|
71
|
-
}
|
|
72
|
-
} else if (payloadComponent.type === bodyTemplate.type.toLowerCase()) {
|
|
73
|
-
const bodyPlaceholdersCount = this.getUniquePlaceholderCount(
|
|
74
|
-
bodyTemplate.text
|
|
75
|
-
);
|
|
76
|
-
if (payloadComponent.parameters.length != bodyPlaceholdersCount) {
|
|
77
|
-
console.log("invalid body");
|
|
78
|
-
throw new Error("body count mismatch");
|
|
79
|
-
} else {
|
|
80
|
-
// validate template body
|
|
81
|
-
// body validated
|
|
82
|
-
// TODO: add more validations if required
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else
|
|
86
|
-
throw new Error("type mismatch or incorrect")
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
testType(obj: DemoBody) {
|
|
93
|
-
let returnValue = true;
|
|
94
|
-
obj.whatsapp.messages.every((message) => {
|
|
95
|
-
returnValue =
|
|
96
|
-
Boolean(message?.content?.type === "text" && message.content.text) ||
|
|
97
|
-
Boolean(
|
|
98
|
-
message?.content?.type === "document" && message.content.document
|
|
99
|
-
) ||
|
|
100
|
-
Boolean(message?.content?.type === "image" && message.content.image) ||
|
|
101
|
-
Boolean(message?.content?.type === "video" && message.content.video) ||
|
|
102
|
-
Boolean(
|
|
103
|
-
message?.content?.type === "template" && message.content.template
|
|
104
|
-
);
|
|
105
|
-
return returnValue;
|
|
106
|
-
});
|
|
107
|
-
return returnValue;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private async sendMessage(messageData: DemoBody): Promise<boolean> {
|
|
111
|
-
try {
|
|
112
|
-
let config = {
|
|
113
|
-
method: "post",
|
|
114
|
-
maxBodyLength: Infinity,
|
|
115
|
-
url: this.whatsappApiUrl,
|
|
116
|
-
headers: {
|
|
117
|
-
"Content-Type": "application/json",
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
data: JSON.stringify(messageData),
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const response = await axios.request(config);
|
|
124
|
-
if (response.data.metadata && response.data.metadata.success != 0) {
|
|
125
|
-
console.log("WhatsApp message sent successfully:", response.data);
|
|
126
|
-
return true;
|
|
127
|
-
} else {
|
|
128
|
-
console.error("Error sending WhatsApp message:", response.data);
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error("Error sending WhatsApp message:", error);
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private async sendTemplateMessage(
|
|
138
|
-
messageData: WhatsAppTemplateDemoBody
|
|
139
|
-
): Promise<boolean> {
|
|
140
|
-
try {
|
|
141
|
-
const config = {
|
|
142
|
-
method: "post",
|
|
143
|
-
maxBodyLength: Infinity,
|
|
144
|
-
url: this.whatsappApiUrl,
|
|
145
|
-
headers: {
|
|
146
|
-
"Content-Type": "application/json",
|
|
147
|
-
},
|
|
148
|
-
data: JSON.stringify(messageData),
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const response = await axios.request(config);
|
|
152
|
-
if (response.data.metadata && response.data.metadata.success !== 0) {
|
|
153
|
-
console.log(
|
|
154
|
-
"WhatsApp template message sent successfully:",
|
|
155
|
-
response.data
|
|
156
|
-
);
|
|
157
|
-
return true;
|
|
158
|
-
} else {
|
|
159
|
-
console.error(
|
|
160
|
-
"Error sending WhatsApp template message:",
|
|
161
|
-
response.data
|
|
162
|
-
);
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
} catch (error) {
|
|
166
|
-
console.error("Error sending WhatsApp template message:", error);
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async sendWhatsAppMessage(obj: DemoBody): Promise<boolean> {
|
|
172
|
-
if (this.testType(obj)) return this.sendMessage(obj);
|
|
173
|
-
else return false;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
async sendWhatsappTemplateMessage(
|
|
177
|
-
obj: WhatsAppTemplateDemoBody
|
|
178
|
-
): Promise<boolean> {
|
|
179
|
-
let templatevalue=await this.getTemplates();
|
|
180
|
-
let tempVariable=obj.whatsapp.messages[0].content.template.name;
|
|
181
|
-
let template = templatevalue.find((e:any)=>e.data.name==tempVariable)
|
|
182
|
-
if(this.validateTemplatePayload(template,obj)){
|
|
183
|
-
return this.sendTemplateMessage(obj)
|
|
184
|
-
}
|
|
185
|
-
else return false;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
export default WhatsappMessageSender;
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { DemoBody, EmiReminderAug2023, Provider, WhatsAppTemplateDemoBody } from "./Whatsapp.types";
|
|
3
|
+
|
|
4
|
+
class WhatsappMessageSender {
|
|
5
|
+
private exotelSid: string;
|
|
6
|
+
private exotelToken: string;
|
|
7
|
+
private exotelApiKey: string;
|
|
8
|
+
private whatsappApiUrl!: string;
|
|
9
|
+
private provider: string;
|
|
10
|
+
|
|
11
|
+
constructor(payload: {
|
|
12
|
+
exotelSid: string;
|
|
13
|
+
exotelToken: string;
|
|
14
|
+
exotelApiKey: string;
|
|
15
|
+
provider: string;
|
|
16
|
+
}) {
|
|
17
|
+
const { exotelSid, exotelToken, exotelApiKey, provider } = payload;
|
|
18
|
+
this.exotelSid = exotelSid;
|
|
19
|
+
this.exotelToken = exotelToken;
|
|
20
|
+
this.exotelApiKey = exotelApiKey;
|
|
21
|
+
this.provider = provider;
|
|
22
|
+
|
|
23
|
+
if (this.provider === Provider.EXOTEL) {
|
|
24
|
+
this.whatsappApiUrl = `https://${exotelApiKey}:${exotelToken}@api.exotel.com/v2/accounts/${exotelSid}/messages`;
|
|
25
|
+
} else if (this.provider === Provider.GUPSHUP) {
|
|
26
|
+
// Define the URL for Gupshup API
|
|
27
|
+
// this.gupshupApiUrl = ...;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getTemplates() {
|
|
32
|
+
const request = await axios.get(
|
|
33
|
+
`https://${this.exotelApiKey}:${this.exotelToken}@api.exotel.com/v2/accounts/${this.exotelSid}/templates?waba_id=114033855070320`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return request.data.response.whatsapp.templates;
|
|
37
|
+
}
|
|
38
|
+
getUniquePlaceholderCount(str: string) {
|
|
39
|
+
const arr:Array<string> = [];
|
|
40
|
+
str.split("{{").map((s) => arr.push(...s.split("}}")));
|
|
41
|
+
const placeholders: Array<string> = arr.filter(
|
|
42
|
+
(i) => i.match(/[0-9]+/) && !isNaN(Number(i))
|
|
43
|
+
);
|
|
44
|
+
return [...new Set(placeholders)].length;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
validateTemplatePayload(template:EmiReminderAug2023, payload:any) {
|
|
48
|
+
const templateComponents = template.data.components;
|
|
49
|
+
if (templateComponents.length != 2) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const [headerTemplate, bodyTemplate] = templateComponents;
|
|
54
|
+
//this checks if placeholder is correct or not
|
|
55
|
+
for (let index = 0; index < payload.whatsapp.messages.length; index++) {
|
|
56
|
+
const message = payload.whatsapp.messages[index];
|
|
57
|
+
const payloadComponents = message.content.template.components;
|
|
58
|
+
for (let index2 = 0; index2 < payloadComponents.length; index2++) {
|
|
59
|
+
const payloadComponent = payloadComponents[index2];
|
|
60
|
+
// validate template header
|
|
61
|
+
if (payloadComponent.type === headerTemplate.type.toLowerCase()) {
|
|
62
|
+
const headerPlaceholdersCount = this.getUniquePlaceholderCount(
|
|
63
|
+
headerTemplate.text
|
|
64
|
+
);
|
|
65
|
+
if (payloadComponent.parameters.length != headerPlaceholdersCount) {
|
|
66
|
+
console.log("invalid header");
|
|
67
|
+
throw new Error("header count mismatch");
|
|
68
|
+
} else {
|
|
69
|
+
// header validated
|
|
70
|
+
// TODO: add more validations if required
|
|
71
|
+
}
|
|
72
|
+
} else if (payloadComponent.type === bodyTemplate.type.toLowerCase()) {
|
|
73
|
+
const bodyPlaceholdersCount = this.getUniquePlaceholderCount(
|
|
74
|
+
bodyTemplate.text
|
|
75
|
+
);
|
|
76
|
+
if (payloadComponent.parameters.length != bodyPlaceholdersCount) {
|
|
77
|
+
console.log("invalid body");
|
|
78
|
+
throw new Error("body count mismatch");
|
|
79
|
+
} else {
|
|
80
|
+
// validate template body
|
|
81
|
+
// body validated
|
|
82
|
+
// TODO: add more validations if required
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
throw new Error("type mismatch or incorrect")
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
testType(obj: DemoBody) {
|
|
93
|
+
let returnValue = true;
|
|
94
|
+
obj.whatsapp.messages.every((message) => {
|
|
95
|
+
returnValue =
|
|
96
|
+
Boolean(message?.content?.type === "text" && message.content.text) ||
|
|
97
|
+
Boolean(
|
|
98
|
+
message?.content?.type === "document" && message.content.document
|
|
99
|
+
) ||
|
|
100
|
+
Boolean(message?.content?.type === "image" && message.content.image) ||
|
|
101
|
+
Boolean(message?.content?.type === "video" && message.content.video) ||
|
|
102
|
+
Boolean(
|
|
103
|
+
message?.content?.type === "template" && message.content.template
|
|
104
|
+
);
|
|
105
|
+
return returnValue;
|
|
106
|
+
});
|
|
107
|
+
return returnValue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private async sendMessage(messageData: DemoBody): Promise<boolean> {
|
|
111
|
+
try {
|
|
112
|
+
let config = {
|
|
113
|
+
method: "post",
|
|
114
|
+
maxBodyLength: Infinity,
|
|
115
|
+
url: this.whatsappApiUrl,
|
|
116
|
+
headers: {
|
|
117
|
+
"Content-Type": "application/json",
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
data: JSON.stringify(messageData),
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const response = await axios.request(config);
|
|
124
|
+
if (response.data.metadata && response.data.metadata.success != 0) {
|
|
125
|
+
console.log("WhatsApp message sent successfully:", response.data);
|
|
126
|
+
return true;
|
|
127
|
+
} else {
|
|
128
|
+
console.error("Error sending WhatsApp message:", response.data);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error("Error sending WhatsApp message:", error);
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private async sendTemplateMessage(
|
|
138
|
+
messageData: WhatsAppTemplateDemoBody
|
|
139
|
+
): Promise<boolean> {
|
|
140
|
+
try {
|
|
141
|
+
const config = {
|
|
142
|
+
method: "post",
|
|
143
|
+
maxBodyLength: Infinity,
|
|
144
|
+
url: this.whatsappApiUrl,
|
|
145
|
+
headers: {
|
|
146
|
+
"Content-Type": "application/json",
|
|
147
|
+
},
|
|
148
|
+
data: JSON.stringify(messageData),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const response = await axios.request(config);
|
|
152
|
+
if (response.data.metadata && response.data.metadata.success !== 0) {
|
|
153
|
+
console.log(
|
|
154
|
+
"WhatsApp template message sent successfully:",
|
|
155
|
+
response.data
|
|
156
|
+
);
|
|
157
|
+
return true;
|
|
158
|
+
} else {
|
|
159
|
+
console.error(
|
|
160
|
+
"Error sending WhatsApp template message:",
|
|
161
|
+
response.data
|
|
162
|
+
);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error("Error sending WhatsApp template message:", error);
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async sendWhatsAppMessage(obj: DemoBody): Promise<boolean> {
|
|
172
|
+
if (this.testType(obj)) return this.sendMessage(obj);
|
|
173
|
+
else return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async sendWhatsappTemplateMessage(
|
|
177
|
+
obj: WhatsAppTemplateDemoBody
|
|
178
|
+
): Promise<boolean> {
|
|
179
|
+
let templatevalue=await this.getTemplates();
|
|
180
|
+
let tempVariable=obj.whatsapp.messages[0].content.template.name;
|
|
181
|
+
let template = templatevalue.find((e:any)=>e.data.name==tempVariable)
|
|
182
|
+
if(this.validateTemplatePayload(template,obj)){
|
|
183
|
+
return this.sendTemplateMessage(obj)
|
|
184
|
+
}
|
|
185
|
+
else return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export default WhatsappMessageSender;
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { finance } from "./Finance";
|
|
2
|
-
import { socials } from "./Socials";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const AeremMiddleware = {
|
|
6
|
-
finance,socials
|
|
7
|
-
|
|
1
|
+
import { finance } from "./Finance";
|
|
2
|
+
import { socials } from "./Socials";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const AeremMiddleware = {
|
|
6
|
+
finance,socials
|
|
7
|
+
|
|
8
8
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const FCM = require("fcm-node");
|
|
2
|
-
|
|
3
|
-
export async function sendPushNotification(
|
|
4
|
-
serverKey:string,
|
|
5
|
-
registrationIds: string[],
|
|
6
|
-
title: string,
|
|
7
|
-
body: string,
|
|
8
|
-
data: {},
|
|
9
|
-
icon?: string,
|
|
10
|
-
sound?: string,
|
|
11
|
-
): Promise<any> {
|
|
12
|
-
const fcm = new FCM(serverKey);
|
|
13
|
-
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
const pushMessage = {
|
|
16
|
-
registration_ids: registrationIds,
|
|
17
|
-
notification: {
|
|
18
|
-
body: body,
|
|
19
|
-
icon: icon || "myicon",
|
|
20
|
-
sound: sound || "mySound",
|
|
21
|
-
title: title,
|
|
22
|
-
},
|
|
23
|
-
data: data,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
fcm.send(pushMessage, (err: any, response: any) => {
|
|
27
|
-
if (err) {
|
|
28
|
-
console.log("Something has gone wrong!", err);
|
|
29
|
-
reject(err);
|
|
30
|
-
} else {
|
|
31
|
-
console.log("Push notification sent.", response);
|
|
32
|
-
resolve(response);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
1
|
+
const FCM = require("fcm-node");
|
|
2
|
+
|
|
3
|
+
export async function sendPushNotification(
|
|
4
|
+
serverKey:string,
|
|
5
|
+
registrationIds: string[],
|
|
6
|
+
title: string,
|
|
7
|
+
body: string,
|
|
8
|
+
data: {},
|
|
9
|
+
icon?: string,
|
|
10
|
+
sound?: string,
|
|
11
|
+
): Promise<any> {
|
|
12
|
+
const fcm = new FCM(serverKey);
|
|
13
|
+
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const pushMessage = {
|
|
16
|
+
registration_ids: registrationIds,
|
|
17
|
+
notification: {
|
|
18
|
+
body: body,
|
|
19
|
+
icon: icon || "myicon",
|
|
20
|
+
sound: sound || "mySound",
|
|
21
|
+
title: title,
|
|
22
|
+
},
|
|
23
|
+
data: data,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
fcm.send(pushMessage, (err: any, response: any) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
console.log("Something has gone wrong!", err);
|
|
29
|
+
reject(err);
|
|
30
|
+
} else {
|
|
31
|
+
console.log("Push notification sent.", response);
|
|
32
|
+
resolve(response);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
36
|
}
|