Reputation: 1821
I've implemented FireBaseX in my Ionic 4 app to send remote notifications.
this.platform.ready().then(() => {
let platforms = this.platform.platforms();
if(platforms.includes('ios') || platforms.includes('android') || platforms.includes('mobile')){
this.firebase.getToken().then(token => {
console.log(`FIREBASE TOKEN ${token}`);
if(platforms.includes('ios')) this.firebase.grantPermission();
});
this.firebase.onMessageReceived().subscribe(data => {
console.log('FIREBASE MESSAGE', data);
});
}
});
So when I open the app in iOS, it asks for permissions correctly.
Then I send test message and the console.log() appears correctly.
2020-02-05 17:35:38.282123-0300 Parkaz[86464:2354851] didReceiveMessage: {
"collapse_key" = "com.myapp.app";
from = 678323471xxxx;
notification = {
body = teste;
e = 1;
tag = "campaign_collapse_key_5659280550157990837";
title = teste;
};
}
However, if the app is not opened, nothing happens. The notification banner doesn't appear, no badge, no sound... nothing...
Am I doing something wrong?
Upvotes: 0
Views: 291
Reputation: 1821
Solved by adding apple APNS certificates into firebase settings panel.
Upvotes: 0
Reputation: 178
You can test your notification using a postman.
POST : https://fcm.googleapis.com/fcm/send
Headers
Content-Type:application/json
Authorization:key=AIzaXXXXXXXXXX
Body
Android
{
"notification": {
"title": "Your Notification Title",
"body": "This is Message",
},
"to" : FIREBASE TOKEN,
"data": {
"content-available": 1,
"foreground": false,
"clickAction": "/chat"
}
}
iOS
{
"to" : FIREBASE TOKEN,
"data": {
"title": "Your Notification Title",
"body": "This is Message",
"content-available": 1,
"foreground": false,
}
}
Upvotes: 5