Hi everyone,

we are building an app with the Ionic 2 framework and would like to integrate the Pushwoosh Notifications. I've tried to follow the guide: http://docs.pushwoosh.com/docs/cordova-phonegap

The problem is that the following line of one code snippets fails by compiling: Cannot find name 'cordova'

var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");

I think the main issue is, that these code samples are not completly compatible with the Ionic 2 framework which also includes angular 2 and typescript. Is there any workaround for that problem?

asked 05 Apr '16, 17:55
RayComBomber's gravatar image



I've found the solution: If you run the app via ionic serve, the cordova.js is not loaded (correctly). But if you run it with e.g. ionic run browser it works :-)

permanent link
answered 12 Apr '16, 13:44
RayComBomber's gravatar image



That's actually quite strange. Could you please check whether you've carefully followed the guide?

Also, may I ask you to try our Sample Application:


permanent link
answered 06 Apr '16, 06:11
Nikolai's gravatar image


Hi Nicolai,

thanks for your quick answer!

I'm pretty sure that I followed the guide. By your sample application, after a npm install and a gulp build I get a Error: 404 status code downloading 32-bit node.lib for builing node.sass Nvertheless I can run the App in the browser via ionic serve, but in Chrome Debugger, I can see that cordova has no instance (same problem as described in my first post).

Back to my app: Through declare var cordova:any; I got rid of the compile error, but then I get a runntime error: cordova is not defined For better understanding I paste the entire code of my current app.ts

'use strict';

import {App, IonicApp, Platform} from 'ionic-angular'; import {LoginPage} from './pages/login/login'; import {HomePage} from './pages/home/home'; declare var cordova:any;

@App({ templateUrl: 'build/app.html', config: {} // http://ionicframework.com/docs/v2/api/config/Config/ }) export class IwiiAngularApp { private rootPage: any; private pages: Array<{ title: string, component: any }>; private app: IonicApp; private platform: Platform;

constructor(app: IonicApp, platform: Platform) { this.app = app; this.platform = platform; this.rootPage = LoginPage;


// set our app's pages
this.pages = [
  { title: 'Login', component: LoginPage },
  { title: 'Home', component: HomePage },


private initializeApp() { this.platform.ready().then(() => { // The platform is now ready. Note: if this callback fails to fire, follow // the Troubleshooting guide for a number of possible solutions: // // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. // // First, let's hide the keyboard accessory bar (only works natively) since // that's a better default: // // Keyboard.setAccessoryBarVisible(false); // // For example, we might change the StatusBar color. This one below is // good for dark backgrounds and light text: // StatusBar.setStyle(StatusBar.LIGHT_CONTENT) this.initPushwoosh(); }); }

public initPushwoosh() { var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");

  //set push notifications handler
  document.addEventListener('push-notification', function (event) {
    //var title = event.notification.title;
    //var userData = event.notification.userdata;
    var title = "Titel";
    var userData = "Userdata Text";
    if (typeof(userData) != "undefined") {
      console.warn('user data: ' + JSON.stringify(userData));


  //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", pw_appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({projectid: "XXXXXXXXXXX", pw_appid: "XXXXX-XXXXX"});

  //register for pushes
      function (status) {
        var pushToken = status;
        console.warn('push token: ' + pushToken);
      function (status) {
        console.warn(JSON.stringify(['failed to register ', status]));


permanent link
answered 06 Apr '16, 15:32
RayComBomber's gravatar image


I have implemented push notifications in ionic2 app. You can see a live demo and implementation steps here. Live demo and implementation steps

permanent link
answered 05 May '16, 19:06
Nishanth%20Kabra's gravatar image

Nishanth Kabra

edited 05 May '16, 19:11

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 05 Apr '16, 17:55

question was seen: 1,890 times

last updated: 05 May '16, 19:11