Open TdoubleG opened 5 years ago
It depends on where you send the message in; this code snippet should be able to show you the actual data attached to the push notification:
this.firebase.onNotificationOpen().subscribe((response) => {
this.handleNotification(response);
});
private async handleNotification(response) {
// Whatever field you added to the push notification should be in the root
console.log(JSON.stringify(response));
}
@felipeclopes thank for your answer.
I don't really get it what you mean with "depends on where you send the message in".
I have a notifications service with a function returning onNotificationOpen()
. I'm calling this function inside my app.component.ts
like this:
// Listen to incoming messages
this.pushService.listenToNotifications().subscribe( (res) => {
console.log(res);
});
and this is what my service looks like:
listenToNotifications() {
return this.firebaseNative.onNotificationOpen()
}
Same problem here!
Ionic:
ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic1 1.3.5
@ionic/v1-toolkit : 1.0.22
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, browser 5.0.4, ios 5.0.0
Cordova Plugins : cordova-plugin-ionic-webview 2.4.1, (and 24 other plugins)
System:
Android SDK Tools : 26.1.1 (/Users/xxx/Library/Android/sdk)
ios-deploy : 2.0.0
ios-sim : 7.0.0
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS Mojave
Xcode : Xcode 10.2 Build version 10E125
I have some troubles with the payload. What I want is that the payload show me the label that I sent from the firebase console. But this is what my payload looks like, even the message or title is not inside the payload
This is an example from an Android Device I thought there is a body or something else where I can see the notification message payload. I'm printing out the response of the
onNotificationOpen
observable.Does anybody knows the problem?