title: Cordova PushNotification onNotificationGCM is not called
body: <p>I am doing pushnotification for both Android/IOS.</p>
  
  <p>I have used a cordova push-plugin <a href="https://github.com/phonegap-build/PushPlugin" rel="nofollow noreferrer">https://github.com/phonegap-build/PushPlugin</a>, it seems to work great.</p>
  
  <p>Info : I'm on a AngularJS project.</p>
  
  <p>In my NotificationHelper factory i have this init method:</p>
  
  <pre><code>helper.init = function() {
  
      // Instanciate push plugin notification
      var pushNotification = window.plugins.pushNotification;
  
      var errorHandler = function(error) {
          logger.debug('errorHandler = ' + error);
      };
  
      if ($rootScope.isAndroid()) {
          var senderId = CONFIG.NOTIFICATION_ANDROID_SENDER_ID;
          pushNotification.register(function(result) {
              logger.debug('successHandler = ' + result);
          }, errorHandler, {
              'senderID' : senderId,
              'ecb' : 'onNotificationGCM'
          });
      }
  };
  </code></pre>
  
  <p>I also defined those methods on mains.js :</p>
  
  <pre><code>var onNotificationGCM = function(event) {
     // call back to web service in Angular.
     var elem = angular.element(document.querySelector('[ng-app]'));
     var injector = elem.injector();
     var service = injector.get('NotificationHelper');
     service.onNotificationGCM(event);
  };
  </code></pre>
  
  <p>It's a trick to call angularJS factory from main javascript.</p>
  
  <p>'onNotificationGCM' call the 'NotificationHelper.onNotificationGCM' method :</p>
  
  <pre><code>helper.onNotificationGCM = function(e) {
      switch (e.event) {
      case 'message':
          // Notification happened while app was in the foreground
          if (e.foreground) {
              logger.debug('[notification] [message] Foreground : ' + JSON.stringify(e));
          } else { // Notification touched in the notification tray
              logger.debug('[notification] [message] Background : ' + JSON.stringify(e));
              if (e.coldstart) {
                  // App was not running and user clicked on notification
              } else {
                  // App was running and user clicked on notification
              }
          }
          decriptPayloadNotification(e.payload);
          break;
      case 'registered':
          logger.debug('[notification] [registered] : ' + JSON.stringify(e));
          if (e.regid.length &gt; 0) {
              registerUser(e.regid, 'gcm');
          }
          break;
  
      case 'error':
          logger.debug('[notification] [error] : ' + JSON.stringify(e));
          break;
  
      default:
          logger.debug('[notification] [default] : Unknown, an event was received and we do not know what it is : ' + JSON.stringify(e));
          break;
      }
  };
  </code></pre>
  
  <p>During the first use, everything work good :</p>
  
  <ul>
  <li>'Registered' event is received</li>
  <li>Notifications are received</li>
  <li>When i'm on foreground I receive 'message' event :</li>
  </ul>
  
  <blockquote>
    <p>NotificationHelper: [notification] [message] Foreground : {"event":"message","from":"847593779913","message":"Agenêts 23/03 10h\r\n","collapse_key":"do_not_collapse","foreground":true,"payload":{"lt":"school","lv":"E1154","notId":"35429","title":"Agenêts le 23/03/2015","message":"Agenêts 23/03 10h\r\n"}}</p>
  </blockquote>
  
  <ul>
  <li>When i'm on background, if i receive notif and touche it on notification tray, I receive 'message' event :</li>
  </ul>
  
  <blockquote>
    <p>NotificationHelper: [notification] [message] Background : {"event":"message","from":"847593779913","message":"la piscine sera fermée 1 journée pour raison technique","coldstart":false,"collapse_key":"do_not_collapse","foreground":false,"payload":{"lt":"swimming pool","lv":"E114","notId":"29869","title":"23/04/2015 fermeture de la piscine","message":"la piscine sera fermée 1 journée pour raison technique"}}</p>
  </blockquote>
  
  <p><strong>BUT</strong>, if i kill my app, everything stop to work.</p>
  
  <p>If i restart app, i will not receive anymore 'message'event and 'onNotificationGCM' will not be called.</p>
  
  <p>I founded some articles speaking about this problem, but without success :</p>
  
  <p><a href="https://stackoverflow.com/questions/16689092/phonegap-pushnotification-to-open-a-specific-app-page">Stackoverflow : Phonegap PushNotification to open a specific app page</a></p>
  
  <p>Does anyone has an idea about this problem ?</p>