ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 208 forks source link

Support more exhaustive data in the result parameters. #329

Closed Haakh closed 5 years ago

Haakh commented 5 years ago

Support more data inside the result parameters, in the example below see I'm trying to send notification to 4 device tokens. Out of which 2 are successful and 2 error out. Android Response:

"results":[
  {"message_id":"0:1540545319375832%082a886ef9fd7ecd"},
  {"error":"NotRegistered"},
  {"message_id":"0:1540545319370910%082a886ef9fd7ecd"},
  {"error":"NotRegistered"}
]}

All I know from the result is that 2 tokens error out, but i'm not sure which ones. As you can see the tokens that errored out sent just the error message and not the respective token alongside it. The result data should be more consistent: as in each object related to a token should have the token status and the response( success or failure reason).

Suggested response:

[ 
  {"deviceId": "***", "status": "400", "response": {"reason": "BadDeviceToken"}},
  {"deviceId": "****", "status": "200"}
]
eladnava commented 5 years ago

Hi @Haakh, Thanks for the suggestion, there is a duplicate issue for this (an easier way to identify invalid tokens): https://github.com/ToothlessGear/node-gcm/issues/226#issuecomment-426644464

Closing this one, please continue discussion there. If you would like to submit a PR that would be greatly encouraged 👍