@lyxa.ai/core 1.2.10 → 1.2.11
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.
|
@@ -29,6 +29,15 @@ let FCMService = class FCMService {
|
|
|
29
29
|
const message = {
|
|
30
30
|
data: payload.data || {},
|
|
31
31
|
tokens,
|
|
32
|
+
android: { priority: 'high' },
|
|
33
|
+
apns: {
|
|
34
|
+
payload: {
|
|
35
|
+
aps: {
|
|
36
|
+
sound: payload.sound || 'default',
|
|
37
|
+
contentAvailable: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
32
41
|
};
|
|
33
42
|
if (!isInvisible) {
|
|
34
43
|
message.notification = {
|
|
@@ -36,17 +45,11 @@ let FCMService = class FCMService {
|
|
|
36
45
|
body: payload.body,
|
|
37
46
|
};
|
|
38
47
|
message.android = {
|
|
48
|
+
priority: 'high',
|
|
39
49
|
notification: {
|
|
40
50
|
channelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',
|
|
41
51
|
},
|
|
42
52
|
};
|
|
43
|
-
message.apns = {
|
|
44
|
-
payload: {
|
|
45
|
-
aps: {
|
|
46
|
-
sound: payload.sound || 'default',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
53
|
}
|
|
51
54
|
try {
|
|
52
55
|
const response = await this.messaging.sendEachForMulticast(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fcmService.js","sourceRoot":"/","sources":["libraries/firebase/fcmService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA2C;AAC3C,6BAAqC;AACrC,mCAAiC;AAWpB,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AACvC,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAG7C,IAAM,UAAU,GAAhB,MAAM,UAAU;IACd,SAAS,CAAuB;IAExC,YAAY,GAAS;QACp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AChC,CAAC;oBACD,OAAO,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC1E,CAAC;YACF,CAAC,CAAC,CAAC;YAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;QACxC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;YAClD,MAAM,GAAG,CAAC;QACX,CAAC;IACF,CAAC;CACD,CAAA;AA9EY,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CA8EtB","sourcesContent":["import { messaging } from 'firebase-admin';\nimport { getLibraries } from '../..';\nimport { Service } from 'typedi';\nimport { App } from 'firebase-admin/app';\n\nexport interface FCMNotificationPayload {\n\ttitle?: string;\n\tbody?: string;\n\tdata?: Record<string, string>;\n\tsound?: string;\n\tinvisible?: boolean;\n}\n\nexport const FCMServiceForUser = 'fcm.service.user';\nexport const FCMServiceForRider = 'fcm.service.rider';\nexport const FCMServiceForShop = 'fcm.service.shop';\n\n@Service()\nexport class FCMService {\n\tprivate messaging!: messaging.Messaging;\n\n\tconstructor(app?: App) {\n\t\tconst firebaseApp = app ?? getLibraries().getFirebaseService().superApp;\n\t\tthis.messaging = messaging(firebaseApp);\n\t}\n\n\t/**\n\t * Sends a push notification (visible or invisible) to multiple device tokens\n\t * @param payload - Notification title, body, and optional data\n\t * @param tokens - FCM device tokens\n\t * @returns Object containing success and invalid tokens\n\t */\n\tasync sendNotification(\n\t\tpayload: FCMNotificationPayload,\n\t\ttokens: string[]\n\t): Promise<{ successTokens: string[]; failedTokens: string[] }> {\n\t\tif (!tokens.length) return { successTokens: [], failedTokens: [] };\n\n\t\tconst isInvisible = payload.invisible === true;\n\n\t\tconst message: messaging.MulticastMessage = {\n\t\t\tdata: payload.data || {},\n\t\t\ttokens,\n\t\t\tandroid: { priority: 'high' },\n\t\t\tapns: {\n\t\t\t\tpayload: {\n\t\t\t\t\taps: {\n\t\t\t\t\t\tsound: payload.sound || 'default',\n\t\t\t\t\t\tcontentAvailable: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\t// Only add visible notification fields if not invisible\n\t\tif (!isInvisible) {\n\t\t\tmessage.notification = {\n\t\t\t\ttitle: payload.title,\n\t\t\t\tbody: payload.body,\n\t\t\t};\n\n\t\t\tmessage.android = {\n\t\t\t\tpriority: 'high',\n\t\t\t\tnotification: {\n\t\t\t\t\tchannelId: payload.sound ? 'android_Push_Notification_Channel_1' : 'default',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.messaging.sendEachForMulticast(message);\n\n\t\t\tconst successTokens: string[] = [];\n\t\t\tconst failedTokens: string[] = [];\n\n\t\t\tresponse.responses.forEach((resp, idx) => {\n\t\t\t\tif (resp.success) {\n\t\t\t\t\tsuccessTokens.push(tokens[idx]);\n\t\t\t\t} else {\n\t\t\t\t\tconst errorCode = resp.error?.code;\n\t\t\t\t\tif (\n\t\t\t\t\t\terrorCode === 'messaging/invalid-argument' ||\n\t\t\t\t\t\terrorCode === 'messaging/registration-token-not-registered'\n\t\t\t\t\t) {\n\t\t\t\t\t\tfailedTokens.push(tokens[idx]);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(`FCM Error for token ${tokens[idx]}:`, resp.error?.message);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn { successTokens, failedTokens };\n\t\t} catch (err) {\n\t\t\tconsole.error('FCM sendNotification error:', err);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED