手机间隙中的android推送通知未收到通知
嗨,我遵循下面的步骤 1) 我创建了cordova项目结构。手机间隙中的android推送通知未收到通知,android,cordova,phonegap-plugins,Android,Cordova,Phonegap Plugins,嗨,我遵循下面的步骤 1) 我创建了cordova项目结构。 2) 我添加了平台(android)。 3) 我添加了cordova插件 cordova plugin add https://github.com/phonegap-build/PushPlugin.git#2.4.0 4) 创建科尔多瓦项目。 5) 接下来,我将在android eclipse(4.4.2)中导入创建的应用程序 6) 我在index.js文件中编写了下面的代码 init: function(){ al
2) 我添加了平台(android)。
3) 我添加了cordova插件
cordova plugin add https://github.com/phonegap-build/PushPlugin.git#2.4.0
4) 创建科尔多瓦项目。5) 接下来,我将在android eclipse(4.4.2)中导入创建的应用程序
6) 我在
index.js
文件中编写了下面的代码
init: function(){
alert("init");
var pushNotification = window.plugins.pushNotification;
pushNotification.register(successHandler, errorHandler,
{
'senderID':'XXXXXXXXXX',
'ecb':'onNotificationGCM' // callback function
}
);
function successHandler(result) {
console.log('Success: '+ result);
alert(result);
}
function errorHandler(error) {
console.log('Error: '+ error);
}
function onNotificationGCM(e) {
alert("comming");
if('registered' === e.event) {
// Successfully registered device.
}
else if('error' === e.event) {
// Failed to register device.
}
};
我得到的响应是“OK”。我无法调用'ecb':onNotificationGCM'//回调函数
在Android控制台中,我收到了下面的消息
V/PushPlugin(2512): execute: action=register
V/PushPlugin(2512): execute: data= [{"senderID":"889953963751","ecb":"onNotificationGCM"}] V/PushPlugin(2512): execute: jo={"senderID":"889953963751","ecb":"onNotificationGCM"} V/PushPlugin(2512): execute: ECB=onNotificationGCM senderID=889953963751
09-12 03:13:33.453: D/GCMRegistrar(2512): resetting backoff for com.ensis.hello
09-12 03:13:33.613: V/GCMRegistrar(2512): Registering app com.ensis.hello of senders 889953963751
09-12 W/PluginManager(2512): THREAD WARNING: exec() call to PushPlugin.register blocked the main thread for 181ms. Plugin should use CordovaInterface.getThreadPool().
这是推送通知流:
registed
事件中的注册id(令牌):
function onNotificationGCM(e) {
alert("comming");
if('registered' === e.event) {
// Successfully registered device.
console.log("regID = " + e.regid);
// save/send this registration id on your server
} else if('error' === e.event) {
// Failed to register device.
}
};
对于iOS,您需要在register
函数的后续处理程序中捕获它
有关更多信息,请查看。您在GCM中注册了吗?是的,我已注册了您是否获得了GCM注册ID?否,我没有获得任何GCM注册ID,我正在发送senderIDin successHandler函数,我收到的响应为“确定”如何获得注册ID我没有收到内部警报(“提交”);