appfeel / node-pushnotifications

Push notifications for GCM, APNS, MPNS, AMZ (automatic detection from device token)
MIT License
532 stars 121 forks source link

retriedResults undefined #182

Open MichalNemec opened 1 year ago

MichalNemec commented 1 year ago

Hello, im trying to send notifications to device group (it works), it worked when i passed in just a device token

const settings = {
    gcm: {
      id: "...",
      phonegap: false,
    },
    isAlwaysUseFCM: true,
  };
  const push = new PushNotifications(settings);

  const deviceGroups = [];
  deviceGroups.push(
    "..."
  );

  push.send(deviceGroups, data, (err, result) => {
    if (err) {
      console.log(err);
      res.status(500).send(JSON.stringify(err, null, 2));
    } else {
      console.log(result[0].message);
      res.status(200).send(`ok`);
    }
  });
{
    "data": {
        "message": "Bad Gateway"
    },
    "type": "client_error",
    "version": "2"
}

/opt/project/functions/node_modules/node-gcm/lib/sender.js:125
        results[regTokenPositionMap[i]] = retriedResults[i];
                                          ^

TypeError: Cannot read properties of undefined (reading '0')
    at updateResults (/opt/project/functions/node_modules/node-gcm/lib/sender.js:125:43)
    at updateResponse (/opt/project/functions/node_modules/node-gcm/lib/sender.js:118:5)
    at <anonymous> (/opt/project/functions/node_modules/node-gcm/lib/sender.js:64:28)
    at Request._callback (/opt/project/functions/node_modules/node-gcm/lib/sender.js:178:13)
    at Request.self.callback (/opt/project/functions/node_modules/request/request.js:185:22)
    at Request.emit (node:events:513:28)
    at Request.emit (node:domain:489:12)
    at Request.<anonymous> (/opt/project/functions/node_modules/request/request.js:1154:10)
    at Request.emit (node:events:513:28)
    at Request.emit (node:domain:489:12)
alex-friedl commented 1 month ago

@MichalNemec Sorry for not getting to this earlier. Is this still an issue? Seems like it should be fixed in node-gcm, if it hasn't in the meantime?