I'm migrating from Parse to Firebase and facing a problem with our ios app.
The Firebase API does not send push notifications to the ios app.
This is what im sending to https://fcm.googleapis.com/fcm/send
{
"to: "<registration token>",
"priority": "high",
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
And the server is returning success
{
"multicast_id":6917019914327105115,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1468961966677585%f0f84693f9fd7ecd"}]
}
But the push is not delivered.
If I sent the push using the Firebase Dashboard, the pushes are delivered, even if I targeting directly with the Token.
I saw another developer complaining in another Stackoverflow question
Can't send push notifications using the server API
I tried their solution of adding the "priority": "high", it did not fixed the issue. But it gave me a clue: They are also using the dev/sandbox push certificate.
My suspicion is that the Dashboard can use the ios Development certificate, but the API can not. The problem only happen on the ios device, since the android app are getting the pushes through API.
Is anyone able to send pushes using the API and the development certificate?
I got contacted by Firebase support and was able to find out what is wrong
My push payload was missing a notification object
{
"to": "<registration token>",
"priority": "high",
"notification": {
"title": "Your Title",
"text": "Your Text"
}
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}
I hope that helps someone else
The object you send to https://fcm.googleapis.com/fcm/send with Firebase API should look like this :
{
"notification":{
"title":"Notification title", //Any value
"body":"Notification body", //Any value
"sound":"default", //If you want notification sound
"click_action":"<activity_name>", //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
}
Please if your problem has been solved don't forget to mark it as such.
Related
Can anyone help me why is my iOS device cannot receive any trigger whenever I test push notifications via fcm? compared to android, everything is working fine. here is a photo where I already enabled my Xcode configurations. This is the link where I followed the integrations and setup https://firebase.flutter.dev/docs/messaging/overview/
This is tricky...
Assuming you set up everything else correctly as per the Apple integration docs...
First, you cannot run on iOS Simulators:
FCM via APNs does not work on iOS Simulators. To receive messages &
notifications a real device is required.
source: https://firebase.flutter.dev/docs/messaging/apple-integration
Then, in my experience, iOS and Android use different format for the FCM load. Something like this should work
// CONSTRUCT NOTIFICATION PAYLOAD
message = {
"notification": {
"body": body,
},
// apple push notification service
"apns": {
"payload":
{
"aps": {
"alert": {
"body": body,
},
"sound": "default",
},
}
},
token: fcmToken,
};
see: https://firebase.flutter.dev/docs/messaging/usage/
see also: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig
I have developed a flutter application and integrated Firebase notification and firebase phone authentication.
I am able to do phone authentication both on development mode as well as after the app is published
I am able to receive notification when the app is development mode - but when I publish the app I dont receive the notification.
I should point out here that I am able to receive the notification if I send it from the firebase console (even after the app is published) - but I do not receive notification from my panel after the app is published (but the same is working absolutely fine otherwise)
I should also point out that this problem is only faced with iOS and not android.
What am I missing?
When you are sending notification to mobile phone using firebase push notification service then make sure the payload is set correctly in order to successfully deliver the notification to mobile phone.
The basic example of the payload for FCM is as follows.
{
"to": "<FCM TOKEN OF DEVICE>",
"data": {
"key1": "value1",
"key2": "value2"
},
"priority": "high",
"notification": {
"body": "This is body",
"title": "This is title",
"sound": "default"
},
"message": {
"notification": {
"title": "This is title",
"body": "This is body"
}
}
}
You can go through this article to know more about FCM service and its payload.
EDIT
Also you need to make sure that the correct certificate is uploaded on the firebase console.
You can export those certificate from the keychain.
I am trying to send the rich notification in my iOS App. I am using the FCM to send the notification. Below is the payload as mentioned here. I am using FCM Module(https://github.com/hansemannn/titanium-firebase-cloud-messaging). I am referring this sample project and successfully added UNNotificationServiceExtension in my Titanium project.
But the problem here is that, I am receiving normal Notification only, image is not visible in the notification panel.
{
"to": "e4DgI95lsPA:APA91bHFX9MUmJ....",
"content_available": true,
"mutable_content": true,
"click_action": "DOWNLOAD_CONTENT",
"data": {
"message": "Offer!",
"attachment-url": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
},
"notification": {
"body": "Enter your message",
"sound": "default"
}
}
Check the README of the linked github example:
Rich Notifications are part of the Titanium SDK 7.2.0 release
The current SDK version is 7.1.1.GA. So it will only work if you are using the nightly builds or a custom SDK
I have implemented firebase cloud messaging in my app and I wish to implement silent push notification.
I have done all the necessaries and send the following json post request to my app.
{
"to": "/topics/news",
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1"
},
"content_available": true,
"priority": "normal"
}
The app successfully receives the notification when it is in background, but the notification is still displayed as banner (I believe silent notification means there will not be any badge, banner displaying right?)
If you want your notifications to be silent, they have to contain only data payload, with no notification content. So, you should remove this:
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1"
}
Review message types for more details.
I'm using Google's Firebase Cloud Messaging to send push-notifications to my iOS and Android applications. The push-notifications sent through the Cloud Messaging console work just as intended, however when I send a push-notification through the API, the iOS application only receives it when in foreground. On Android, it is working correctly (both in foreground and background).
Reading the documentation, the iOS system would then transfer the "notification" object to the system tray, as intended, showing the "body" message. However, this is not working.
Here's the content of the JSON I'm sending:
{
"notification":
{
"body": "This a test notification"
},
"to":"eQ5tiy0cMZ8:APA91bE4CCjDXEJxEIRxKY18pXMMGUBqY1OKJFhVbR-pNhvQjJuhPcc7pXa..."
}
Did anyone have similar problems using Firebase Cloud Messaging recently? Thank you.
I managed to fix the problem thanks to this answer: https://stackoverflow.com/a/37550067/516338
Basically, although NOT in the documents, you have to set the "priority" field to "high" on iOS, like this:
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}