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 206 forks source link

401 Error #151

Closed tonespy closed 8 years ago

tonespy commented 8 years ago

I'm getting a 401 error. I am kind of confused with the Naming Conventions though. Expecially the

var regIds = ['YOUR_REG_ID_HERE']; and var sender = new gcm.Sender('YOUR_API_KEY_HERE');

This is what I think. API_KEY in sender is the 10digit Project number given to you by google. and regIds is/are the Alpha-Numeric long String called Server API Key. I don't know what to debug since it's given 401 which means Unauthorized Access. But, this is what I'm doing I'm setting it up first on my sails/node app, but haven't set the mobile app to receive notification. But, that shouldn't return 401. Any help would be appreciated. Thanks

hypesystem commented 8 years ago

You have it wonky:

You get a 401 because your API key is incorrect.

tonespy commented 8 years ago

@hypesystem If I have to obtain regIds from the device, wouldn't that be another problem? Cause, then I've to get IDs of every device I install my app before I can send them PUSH? But, from what I think, I think the reg ids is/are the Project-Number on Developer Console. Cause, I notice that's what is used to generate token on the device.

hypesystem commented 8 years ago

You have to get registration ids of every device you install your app on. That is how GCM works.

tonespy commented 8 years ago

Yeah. Just thought it through too. Thanks.

SanjanaTailor commented 6 years ago

How to get Registration id for phonegap-plugin from cordova

eladnava commented 6 years ago

Hi @SanjanaTailor, Please consult StackOverflow or the phonegap-plugin-push documentation, your question is out of the scope of this project.