GCM通过PhoneGap Push Plugin在我的Ionic App中注册2个注册ID [英] GCM Registering with 2 registration Id's in my Ionic App via PhoneGap Push Plugin

查看:221
本文介绍了GCM通过PhoneGap Push Plugin在我的Ionic App中注册2个注册ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的前端有一个Ionic App,后端有一个NodeJS应用。我正在尝试从前端模拟本机应用程序通知。

现在出现两个问题。

首先,有两种方法可以在谷歌上注册GCM。一个是通过控制台,一个是通过 developers.google.com 。虽然大多数教程都采用了控制台方法。有些人也选择第二种方法。我很困惑,因为它们都提供了projectID和API Key。

第二个问题。我在前端收到了一个regestration ID

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??

谢谢

推荐答案

第一个问题的答案是使用控制台,因为我正在制作混合应用程序,而不是本机应用程序。如果我正在制作本机应用程序,我会使用第二个选项。
第二个问题的答案是,如果您复制粘贴 node-gcm 示例。它在 push.init()中为android,ios和windows列出来其中windows尚未实现,只留下ios和android,现在有两个设备和两个注册ID ...知道了...那是抓住了。在您测试的任何平台上删除一个并保留另一个。

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.

这篇关于GCM通过PhoneGap Push Plugin在我的Ionic App中注册2个注册ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆