I have been trying to send push notifications from PostMan or from CURL PHP script, to my Android device, and I’m not receiving the message. If I send the notification from the Firebase Console, notifications it works, I received the push notification.
Here is my code on app.component.ts :
import { Component, ViewChild } from '@angular/core';
import { Nav, Platform, AlertController } from 'ionic-angular';
import { HomePage } from '../pages/home/home';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {FCM, NotificationData} from "@ionic-native/fcm";
@Component({
templateUrl: 'app.html',
providers: [Services]
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage:any;
pages: Array<{title: string, component: any, icono: any}>;
constructor(public platform: Platform, public alertCtrl:
AlertController, public statusBar: StatusBar, public splashScreen:
SplashScreen, private fcm: FCM ) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
this.fcm.getToken()
.then((token:string)=>{
console.log("The token to use is: ",token);
})
.catch(error=>{
console.error(error);
});
this.fcm.onTokenRefresh().subscribe(
(token:string)=>console.log("Nuevo token",token),
error=>console.error(error)
);
this.fcm.onNotification().subscribe(
(data:NotificationData)=>{
if(data.wasTapped){
console.log("Received in background",JSON.stringify(data));
}else{
console.log("Received in foreground",JSON.stringify(data))
}
},error=>{
console.error("Error in notification",error)
}
);
});
Here is my PostMan POST : HEADER :

HERE IS MY MESSAGE :
AND HERE IS THE RESPONSE:
As you can See I received a success: 1 -> it means the notification was sent, but in my Android device is never received.
Does anyone has the same issue? As I told before, from firebase console I’m receiving the notification. In advanced thank you for any comments.