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

README: Example on getting the tokens you should remove #323

Closed johanforssell closed 6 years ago

johanforssell commented 6 years ago

Example of how to find the tokens which you couldn't send to. I'm maching the two arrays together and then filtering it to get a list of tokens.

hypesystem commented 6 years ago

Thanks for the quick update :smile:

I still think the check for res.error might be wrong --- shouldn't it be !res.error?

johanforssell commented 6 years ago

My thinking is that the .map() goes through the array of results. Where there is an error, pick the token from the other array. Otherwise, pick nothing/null. Remember, we're collecting the tokens of erronous sends, in order to purge them from the database.

hypesystem commented 6 years ago

Ah yes, you are absolutely right, I was just reading it wrong! I blame being tired :smile:

Maybe we could avoid people like me misunderstanding the code in the future by adding a bit more of a comment?

hypesystem commented 6 years ago

This looks good to me! Remember to add yourself to contributors in package.json :smile:

@eladnava any comments on this before we merge?

eladnava commented 6 years ago

Just reviewed, looks good to me! 💯 Thanks so much @johanforssell for the excellent work.

hypesystem commented 6 years ago

Thanks for the contribution @johanforssell ! :smile: