Push Notification (https://ionicframework.com/docs/native/push/)
1)Install plugin
a)ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID=XXXXXXXXX(SENDER_ID from FireBase console)
b)npm install --save @ionic-native/push
2)Intialize Push
a)const options: PushOptions = {android: {senderID: 'XXXXXXXXX'},ios: {alert: 'true',badge: true,sound: 'false'},windows: {}};
b)const pushObject: PushObject = this.push.init(options);
3)Show push notification
pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));
4)Get registration Id.
pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));
5)Send Push Notification.
a)Data
json={"notification": {"title": "Notification title","body": "Notification body","sound": "default","click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"},"data": {"hello": "This is a Firebase Cloud Message!",},"to": registration.registrationId}
b)post values
var params = json;
var headers = new Headers({'Content-Type': 'application/json','Authorization': 'key=SERVERKEY'});
this.http.post('https://fcm.googleapis.com/fcm/send',params, {headers: headers}).map(res => res.json(),Error=>alert('error'))