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
Related
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'm using this plugin with cordova: cordova-plugin-fcm to get notifications working.
It works good on Android.
Problem is with iOS, when the app is in foreground the notifications arrives. But when the app is closed or in background, the notification doesn't show in notification bar, but when I open the application I can see the notification arriving and the popup I generate, gets opened.
But I really need to notification to show in lock screen and in the notification bar.
This is what I'm sending to Firebase API:
/ POST to https://fcm.googleapis.com/fcm/send
And in the body I'm sending this:
{
"to" : <USER_TOKEN>,
"alert":"Test",
"notification": {
"alert":"Test test",
"title": "Notification test",
"text": "Testing notification text"
},
"priority": 10,
"content_available": true
}
I've also tried with "priority": "high" and get the same results.
The notification arrives, but it only shows when I open the app. I don't even get it in the notification bar or lock screen.
Also I tried adding the "aps" property in the body, with all the information inside.. doesn't work.
I hope someone can throw some light into this..
PS: iOS v10.1.1
PS2: Works good on all android devices.
I've already read some answers from the community but doesn't seem to work:
Firebase API is not sending push notifications when using the API
iOS not receiving Firebase Push Notification sent through the API
Thanks for your time.
have you Upload your Development APNs certificate on console.firebase.google.com,
Upload your APNs certificate to Firebase. If you don't already have an APNs certificate, see Provisioning APNs SSL Certificates.
Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab.
Select the Upload Certificate button for your development certificate, your production certificate, or both. At least one is required.
For each certificate, select the .p12 file, and provide the password, if any. Make sure the bundle ID for this certificate matches the bundle ID of your app. Select Save.
you can refer link https://firebase.google.com/docs/cloud-messaging/ios/client
I had the same problem,
First of all, you need to use "body" instead of "text";
For priority you should always use "high" or "normal", for pushnotifications the default value should be high.
If you forget to use the "title" and "body" key in the notification object of your Json string, iOS wont add the notification to the notificatios list apparently.
If you want some custom values, then add a data object with custom values. like this:
"data":{
"data1":"value1",
"data2":"value2"
}
So try something like this:
{
"to" : <USER_TOKEN>, //or /topics/<topicname> or /topics/all"
"notification": {
"title": "Notification test",
"body": "Testing notification text"
},
"priority": high,
"sound":"default", //not using this one wont make your iOS device use sound
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
}
Combined with data object:
{
"to" : <USER_TOKEN>, //or /topics/<topicname> or /topics/all"
"notification": {
"title": "Notification test",
"body": "Testing notification text"
},
"data":{
"data1":"value1",
"data2":"value2"
},
"priority": high,
"sound":"default", //not using this one wont make your iOS device use sound
"click_action":"FCM_PLUGIN_ACTIVITY",
"icon":"fcm_push_icon"
}
I hope this helps, it did for me
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.
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"
}
}