我有一个Angularjs应用程序,并使用phonegap在Android中构建和运行它。我使用https://github.com/taivo/parse-push-plugin插件进行推送通知处理。该应用程序工作,我也收到来自解析的推送通知,但点击通知我会转到应用程序但插件推送事件没有被触发。此外,当应用程序运行时,以下警报都不会显示。
我的index.html文件正文
<script type="text/javascript" src="js/index.js"></script>
<script src="js/vendor.e67c13c8.js"></script> <script src="js/scripts.7a0fcba7.js"></script>
<script src="js/scriptsp.585b84b2.js"></script>
<script type="text/javascript">
app.initialize();
</script>
<script type="text/javascript" src="cordova.js"></script>
index.js
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
alert('here 1');
angular.bootstrap(document,['healthurb']);
alert('here');
ParsePushPlugin.getInstallationId(function(id) {
alert(id);
}, function(e) {
alert('error');
});
alert('before' + window.ParsePushPlugin);
alert(ParsePushPlugin);
if(ParsePushPlugin || window.ParsePushPlugin){
alert('inside');
ParsePushPlugin.on('receivePN', function(pn){
alert('yo i got this push notification:' + JSON.stringify(pn));
});
ParsePushPlugin.on('openPN', function(pn){
window.location.hash = '#/about';
alert('yo i got this push notification open:' + JSON.stringify(pn));
});
//
//you can also listen to your own custom subevents
//
ParsePushPlugin.on('receivePN:chat', chatEventHandler);
ParsePushPlugin.on('receivePN:serverMaintenance', serverMaintenanceHandler);
}
}
};