【发布时间】:2015-04-23 01:10:03
【问题描述】:
我正在尝试构建一个可用于获取推送通知数据并在 angularJS 范围内处理它的应用程序。推送即将到达设备,我将它们显示在托盘上。当我单击推送时 - 应用程序打开。但我无法在 JS 中接收数据。 这些插件已安装:https://github.com/phonegap-build/PushPlugin 和 https://github.com/avivais/phonegap-parse-plugin
parsePlugin.initialize('xxxxxxxxxxxxxxx', 'xxxxxxxxxxxxx', function() {
//okay, we are registered!
parsePlugin.getInstallationObjectId(function(data) {
alert('Okay!');
}, function(e) {
alert('error');
});
}, function(e) {
alert('error while authenticating!');
});
嗯,它正在注册。我还有一个 onNotification 函数,由 PushPlugin 调用
var onNotification = function(e) // This never happens :(
{
alert("Push came!");
angular.element(document.getElementById('pushCtrl')).scope().getMessage(e);
angular.element(document.getElementById('pushCtrl')).scope().$apply();
};
然后什么也没有发生。典型的应用行为是“好的!”并在推送后仅发送到设备。
另外,如果我插入 PushPlugin 注册功能,应用程序在尝试解析 regid 时崩溃:
$cordovaPush.register({"senderID": "xxxxxxxxxx","ecb": "onNotificationGCM"}).then(function(token) {
if(token="OK"){
$scope.net=true; //show a net icon in the top of the screen
}
}, function(err) {
$scope.token = err;
});
}
这有什么问题?我可以将数据推送到应用程序吗?
【问题讨论】:
标签: javascript android cordova parse-platform