Hi I am using ionic 2 and require to send push notifications in a pubsub format(user posts content to a topic and subscriber to the on the other app gets a push notification ), have already implemented the cordova-plugin-fcm from https://github.com/fechanique/cordova-plugin-fcm
on the documentation page its mentioned to send push notification via this code
//POST: https://fcm.googleapis.com/fcm/send
//HEADER: Content-Type: application/json
//HEADER: Authorization: key=AIzaSy*******************
{
"notification":{
"title":"Notification title", //Any value
"body":"Notification body", //Any value
"sound":"default", //If you want notification sound
"click_action":"FCM_PLUGIN_ACTIVITY", //Must be present for Android
"icon":"fcm_push_icon" //White icon Android resource
},
"data":{
"param1":"value1", //Any data to be retrieved in the notification callback
"param2":"value2"
},
"to":"/topics/topicExample", //Topic or single device
"priority":"high", //If not set, notification won't be delivered on completely closed iOS app
"restricted_package_name":"" //Optional. Set for application filtering
}
Question : where to add this code in ionic 2 app, is it to be added in .ts file to the function once it finishes execution or where ?
the function code to post content is :-
code from : job.ts
self.dataService.submitJob(newJob, uid, category)
.then(function (snapshot) {
loader.dismiss()
.then(() => {
self.viewCtrl.dismiss({
newjob: newJob,
uid: uid,
category: category
});
}).then(() => {
let toast = self.toastCtrl.create({
message: 'Job Posted Succesfully',
duration: 3000,
position: 'top'
});
toast.present();
});
}, function (error) {
console.error(error);
loader.dismiss();
});
what i want to know is do i have to call the code to send push notification here ?