Ionic + iOS + PushWoosh: receiving pushes but not catching them in app

Hey Everyone

this was probably asked a million times, but I couldn’t find an answer.
I am using ionic 2 with angular 2 (TypeScript) and Pushwoosh. Pushwoosh is set up properly and the device is registering and I am getting a token… all is good…
when I send a test woosh, I am, receiving the notification on the phone and the xCode shows a system trace when the woosh arrives., but the event listener is not fired on the typescript level… anyone knows where the problem might be?
here’s the code:

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import {PushwooshService} from './services/pushwoosh.service';
  template: ` <ion-header>
export class MyApp 
      constructor(platform: Platform , private _pushService:PushwooshService) 
               platform.ready().then(() => {

and the service:

import {Injectable} from "@angular/core";

import {Device} from 'ionic-native';
declare var cordova : any;


export class PushwooshService 

      console.log("PushwooshService init");

      if(!Device.device) {
          console.log("PushwooshService init: No device object available.  Skipping init.  (Probably not running in a deployed Cordova app.)");


      var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");
      console.log("initIOS" , document);

      //set push notification callback before we initialize the plugin
      document.addEventListener('push-notification', function (event:any) 
            //get the notification payload
            var notification = event.notification;
            console.log('received notification: ', notification);

            //clear the app badge

      //initialize the plugin
      pushNotification.onDeviceReady({pw_appid: PUSHWOOSH_APP_ID});

      //register for pushes
            function (status) 
              var deviceToken = status['deviceToken'];
              console.warn('registerDevice: ' + deviceToken);
            function (status) 
              console.warn('failed to register : ' + JSON.stringify(status));
              alert(JSON.stringify(['failed to register ', status]));

        //reset badges on app start

it’s the document.addEventListener(‘push-notification’, function (event:any) that is not being called.
any ideas where I might have gne wrong?

1 Like

I am facing the same issue. If you find a solution do let me know
Thanks :slight_smile:

1 Like

Facing the same problem, everything seems to work fine and I’m registered but I never get any messages… Did you find a solution for this?

1 Like

Also facing this issue. Can’t find anything else about it besides this thread.

After going through the PushWoosh API I finally found the solution! There are actually 2 events, one is a general Push Received message and the other one is triggered when the App is running in the foreground. You can catch both like this:

    // Called when App is in background and push was clicked
    document.addEventListener('push-notification', (event: any) => {


    // Called when App is in Foreground
    document.addEventListener('push-receive', (event: any) => {
        var userData = event.notification.userdata;

        if (event.notification.foreground) {
            // Do Stuff..