昨天我正在尝试在运行服务器php脚本时在我的Titanium Alloy App上实现通知。 一旦它工作但不知道之后发生了什么,在我的PHP服务器上调用CURL请求没有通知。将CURL调用到Android GCM发送后,响应即将发生
Sample response: id=0:1431949527356415%1ba0f8cc00000030
我检查了一切。 1.我的服务器IP列在Google API批准的服务器中。 2.项目ID相同(GCM_sender_id) 3.Api密钥与Google相同, 4.设备令牌是正确的
我写道:
var gcm = require('net.iamyellow.gcmjs')
var pendingData = gcm.data;
if (pendingData && pendingData !== null) {
// if we're here is because user has clicked on the notification
// and we set extras for the intent
// and the app WAS NOT running
// (don't worry, we'll see more of this later)
Ti.API.info('******* data (started) ' + JSON.stringify(pendingData));
}
gcm.registerForPushNotifications({
success: function (ev) {
// on successful registration
Ti.API.info('******* success, ' + ev.deviceToken);
},
error: function (ev) {
// when an error occurs
Ti.API.info('******* error, ' + ev.error);
},
callback: function () {
// when a gcm notification is received WHEN the app IS IN FOREGROUND
alert('hellow yellow!');
},
unregister: function (ev) {
// on unregister
Ti.API.info('******* unregister, ' + ev.deviceToken);
},
data: function (data) {
// if we're here is because user has clicked on the notification
// and we set extras in the intent
// and the app WAS RUNNING (=> RESUMED)
// (again don't worry, we'll see more of this later)
Ti.API.info('******* data (resumed) ' + JSON.stringify(data));
}
});
问题是,设备正在生成令牌,即转到成功部分,但现在没有进入回调
请有人知道解决方案吗?
答案 0 :(得分:0)
好的,这是我的wifi连接问题,可能谷歌发送网址。我切换到3G网络,一切都开始正常。