When i run push notification on android, i get.............this error.. below


#1

DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


#2

could you share the code, how you handle push notifications?

this warnings means, that some parts of you code errors and you does not handle this error.

e.g. if you are using ionic-native as native wrapper you are working with promises (e.g. PluginXy.function.then(() => )

if there occurs an error your success callback is not executed. You need an additional error callback (as second parameter) or a (.catch()) call at the end.


#3

actually i want to use firebase…my code is…

import { Component } from ‘@angular/core’;
import { Platform } from ‘ionic-angular’;
import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;

import { Push, PushObject, PushOptions } from ‘@ionic-native/push’;

import { HomePage } from ‘…/pages/home/home’;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
rootPage:any = HomePage;

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,
private push: Push) {
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();
this.pushSetup();
});
}

pushSetup(){
const options: PushOptions = {
android: {
senderID: ‘215496932811’
},
ios: {
alert: ‘true’,
badge: true,
sound: ‘false’
}
};

const pushObject: PushObject = this.push.init(options);

pushObject.on(‘notification’).subscribe((notification: any) => console.log(‘Received a notification’, notification));

pushObject.on(‘registration’).subscribe((registration: any) => console.log(‘Device registered’, registration));

pushObject.on(‘error’).subscribe(error => console.error(‘Error with Push plugin’, error));
}
}