var pushNotification = (<any>window).plugins.pushNotification;
//set push notifications handler
document.addEventListener('push-notification',
var message = (<any>event).notification.message;
var userData = (<any>event).notification.userdata;
alert("Push message opened: " + message);
console.info(JSON.stringify((<any>event).notification));
//dump custom data to the console if it exists
if (typeof(userData) != "undefined") {
console.warn('user data: ' + JSON.stringify(userData));
document.addEventListener('push-receive',
var message = (<any>event).notification.message;
var userData = (<any>event).notification.userdata;
alert("Push message received: " + message);
console.info(JSON.stringify((<any>event).notification));
//dump custom data to the console if it exists
if (typeof (userData) != "undefined") {
console.warn('user data: ' + JSON.stringify(userData));
//initialize Pushwoosh with projectid: "YOUR_FCM_SENDER_ID", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
pushNotification.onDeviceReady({
projectid: "YOUR_FCM_SENDER_ID",
appid: "PUSHWOOSH_APP_ID",
//register for push notifications
pushNotification.registerDevice(
alert("registered with token: " + status.pushToken);
alert("failed to register: " + status);
console.warn(JSON.stringify(['failed to register ', status]));