0

I have an Angularjs app and have use phonegap to build and run it in Android. I am using https://github.com/taivo/parse-push-plugin plugin for push notif handling. The app works and I also receive push notifications from parse, but on clicking the notification I do go to the app but plugin push events are not being triggered. Also none of the alerts below show up when the app is run.

My index.html file body has

<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);
        }  

    }
};
halfer
  • 19,824
  • 17
  • 99
  • 186
rohit
  • 83
  • 1
  • 2
  • 14
  • The issue seems to be that the device ready function is not getting triggered for some reason. I have no idea why. It was getting triggered before. – rohit Oct 06 '15 at 16:50
  • I resintalled the platform on cordova and added parse again. You need to place angular.bootstrap(document,['healthurb']); in the end of the device ready. It seems to work now. – rohit Oct 06 '15 at 17:38

0 Answers0