firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.63k stars 371 forks source link

Messages Undelivered when send with Multicast #2714

Closed mogili1402 closed 1 month ago

mogili1402 commented 1 month ago

I am sending a data message with priority high. I have an delivery event that will be triggered from the app when the message reaches the device I have 1000 sample tokens with me When I use send() with token and send messages one by one i am getting delivery rate around 78 % But when i use multicast or sendEach am getting less delivery rate round 53% I repeated this 5 time same results I am getting same success rate from all send() and multicast and sendEach() but Delivery rate are different i am not getting any Throttling and quotas issues or any type of error to catch

Code:

Send : _async function testsent() { let messagefcm = { android: { ttl: "86000s", priority: "high",}, }; messagefcm.data = {};

let notification = {}; notification.TITLE = "wqwqwqqw"; // notification.TITLE_8_32 = "રાહુલ ગાંધીએ દગો કર્યો";

notification.DESCRIPTION = ""; notification.URL = "http://im.way2app.com/images2/logo_way2news.png"; notification.TYPE = "news"; // news, sms notification.ID = "1";

notification.NOTIFYTYPE = "push";

notification.PRODUCT_ID = "147798"; notification.SHOW_TITLE = "0"; notification.SHOW_LANG = "0"; //0-main 1- language 2- invite 3-live

notification.FULL_IMG = 2; //1 - image notification.UPDATE = "0"; //1- play store notification.LANG_ID = "1"; notification.MSG_STYLE = "1"; notification.FCM = "TRUE";

notification.WITH_BG = "0"; notification.SILENT_PUSH_8_32 = "0"; notification.WITHOUT_LOGO = "0";

messagefcm.data.message = JSON.stringify(notification);

for (let token of tokens) { try { messagefcm.token = token; const response = await admin.messaging().send(messagefcm); console.log(JSON.stringify(response)); } catch (error) { console.error("ERROR IN PUSH ", error); } } console.timeEnd("TIME"); }_

Multicast :

_async function testsent() { let messagefcm = { android: { ttl: 8600000, priority: "high"}, }; messagefcm.data = {};

let notification = {}; notification.TITLE = "நீதிபதியின் சர்ச்சை கருத்து.. ரிப்போர்ட் கேட்ட SC222"; // notification.TITLE_8_32 = "રાહુલ ગાંધીએ દગો કર્યો";

notification.DESCRIPTION = ""; notification.URL = "http://im.way2app.com/images2/logo_way2news.png"; notification.TYPE = "news"; // news, sms notification.ID = "1";

notification.NOTIFYTYPE = "push";

notification.PRODUCT_ID = "23918"; notification.SHOW_TITLE = "0"; notification.SHOW_LANG = "0"; //0-main 1- language 2- invite 3-live

notification.FULL_IMG = 2; //1 - image notification.UPDATE = "0"; //1- play store notification.LANG_ID = "2"; notification.MSG_STYLE = "1"; notification.FCM = "TRUE";

notification.WITH_BG = "0"; notification.SILENT_PUSH_8_32 = "0"; notification.WITHOUT_LOGO = "0";

messagefcm.data.message = JSON.stringify(notification);

for (let tokenArray of [tokens.slice(0, 500), tokens.slice(500)]) { try { // const messages = tokenArray.map((token) => ({ ...messagefcm, token })); messagefcm.tokens=tokenArray const response = await admin.messaging().sendEachForMulticast(messagefcm); console.log(JSON.stringify(response)); } catch (error) { console.error("ERROR IN PUSH ", error); } } console.timeEnd("TIME")

}_

google-oss-bot commented 1 month ago

I found a few problems with this issue:

jonathanedey commented 1 month ago

Hi @mogili1402, to confirm you are experiencing a difference in messages successfully sent (response with message id) verses messages received in your app?

jonathanedey commented 1 month ago

If that is the case, to better investigate this issue, it would be great if you can file a ticket to Firebase Support https://firebase.google.com/support where you can share more information for us for debugging. Closing this here, please reopen if there are other concerns.