I am trying to send push notifications from PostMan or from a CURL PHP script to my Android device and I am not receiving a message. If I send a notification from the Firebase Console, the notifications will work, I received a 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 MY MESSAGE:

AND HERE ANSWER:

As you can see, I got success: 1 → this means that a notification has been sent, but has not been received on my Android device.
Does anyone have the same problem? As I said, from the firebase console I get a notification. In extended thanks for any comments.
source
share