n00r / node-fcm

16 stars 3 forks source link

invalid host address #2

Closed 4502040 closed 8 years ago

4502040 commented 8 years ago

Hi! i am install your package fcm, but in fcm.js file found host address as : 'android.googleapis.com'

Also, official documentation FCM recommend url https://fcm.googleapis.com/fcm/send as fcm host. which is correct ? see https://firebase.google.com/docs/cloud-messaging/http-server-ref

chris08002 commented 8 years ago

Hi, for me the module didn't work but it now does with some changes. I guess they are not very well designed, but I post it anyway, maybe it helps somebody to get things right.

Server change:

this.fcmOptions = { host: 'fcm.googleapis.com', path: '/fcm/send', .... };

I use a JSON, so I changed the conversion to JSON.stringyfy:

var postData = JSON.stringify(packet);

And the response is now an object, not a string, so I also changed someting:

var error = null, id = null; data = JSON.parse(data); if (data.failure != 0) { error = data; } else if (data.success > 0) { id = data.results; } else { error = 'InvalidServerResponse' + data; }

Sorry about the formating....

ans-4175 commented 8 years ago

he is forked from same repo as me, but I already solved this issues here https://github.com/eFishery/fcm-push-notif