GCM Registering with 2 registration Id's in my

2019-08-13 14:58发布

问题:

I have an Ionic App in the front end and a NodeJS app in the backend. I am trying to simulate a native app notification from front end.
Now arise two questions.
First there are two methods to register for GCM on google. One is via Console and one is via developers.google.com. While most of the tutorials go for the console method. Some go for the second method too. I am confused as to which method to follow as both give projectID and API Key.
Second Question. I am receiving a regestration ID in front end by

pushNot.on('registration', function(data) {
        console.log(data.registrationId);

Now the problem is there are two values coming here, both of them different. Which one is correct and which one should be sent to backend??

Thanks

回答1:

The answer to the first question is to use console because I am making a hybrid app, not a native app.If I was making a native app, I would use the second option. The answer to the second question is if you copy-paste the node-gcm example. It lists it out for android,ios and windows in push.init() in which windows is not yet implemented which leaves only ios and android, now two device and two registration id's... Gotcha... That was the catch. Delete one and keep the other, on whichever platform you are testing.