Hi ,
I am implement push notification in ionic2 using push plugin. Notification works when app is open when app closes the notification is not showing in status bar or Notification bar.
This is my code
import { Component, ViewChild } from ‘@angular/core’;
import { Nav, Platform,AlertController } from ‘ionic-angular’;
import { StatusBar, Splashscreen,Push} from ‘ionic-native’;
constructor(public platform: Platform,public varanda:Varanda, public alertCtrl: AlertController) {
//this.initializeApp();
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
Splashscreen.hide();
var push = Push.init({
android: {
senderID: ‘xxxxxxxx’
},
ios: {
alert: ‘true’,
badge: true,
sound: ‘false’
},
windows: {}
});
push.on(‘registration’, (data) => {
console.log(data.registrationId);
//alert()
alert(data.registrationId);
let res={“token”:data.registrationId}
});
push.on(‘notification’, (data) => {
console.log(data);
});
push.on(‘error’, (e) => {
console.log(e.message);
});
});
// used for an example of ngFor and navigation
}
}