processMessage失败:Stack:ReferenceError:未定义onNotification

时间:2014-09-23 09:09:18

标签: javascript cordova

我正在尝试使用android中的push插件实现推送通知(cordova + ionicframework)。我将在控制台中获取注册ID,但永远不会调用onNotification(),并返回错误消息

09-22 11:38:46.151: I/Web Console(24662): processMessage failed: Stack: ReferenceError: onNotification is not defined

这是我的注册表输出

09-22 11:38:46.151: D/CordovaLog(24662): file:///android_asset/www/cordova.js: Line 1046 : processMessage failed: Message: Jjavascript:onNotification({"regid":"APA91bHDLg9BZl-eicx3tS-MjVGy-mcufmbRc-EpCuKzb9b_tPddG125jyxY-OhVR5vul6az-eJ2nZ0PEiOVPqP2KjClaUwAKTBQx5gsIluI0jsGIrpCvNQdUbtKUBxNNH0DH94RHuGpjU29xhTS5Cl8qIgH1MlJHw","event":"registered"}).Please help

1 个答案:

答案 0 :(得分:5)

onNotification必须在窗口中具有范围。

window.onNotification = function(){

}