Flutter iOS Rich Push Notification Image not display - ios

Flutter Push Notification
I implemented Push Notification and notification has image link in Flutter.
In Android, The image display in Notification center automatically with notification details.
In iOS, The image does not display in Notification center but only notification details display in Notification center.
please see format of Push notification. Curl through, Php developer is sending notification. I am getting notification successfully but image not display automatically at iOS side and, in Android image is display automatically
I already add "mutable-content": true and,
already tried to add "mutable-content": true in notification block but not getting success
{
"to": "device token",
"mutable-content": true,
"notification": {
"title": "Note 3",
"body": "11:41",
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"image": "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"
},
"data": {
"notification_type": "Nice Thoughts",
"post_details": {
"message": "hello",
"color": "#e0e0e0",
"url": "www.recurpost.com",
"img_url": "https://homepages.cae.wisc.edu/~ece533/images/airplane.png",
"video_url": "",
"name": "abc xyz"
}
},
"priority": "high"
}

You need to create a notification service extension as described here

Related

Flutter - How to update notification badge when sending notification in terminated state?

In a chat app, I am sending messages between two users. I'm using firebase to send notifications and they work fine in foreground and background states, even in terminated states i'm still receiving the notification.
However the notification count badge on iOS devices is not updating when i send it while the app has been terminated. I get the notification – but the badge count does not increase, because none of the code seems to get executed in .onBackgroundMessage().
I am sending this payload:
{
"notification": {
"title": "New message",
"body": "Notification sent from POSTMAN",
"sound": "custom_sound.mp3",
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"icon": "app_icon"
},
"to": "abcd...",
"content_available": true,
"priority": "high"
}
And after googling i came across the solution for this to just add "badge": 2 inside the "notification" field. The value of badge can be any number and that number actually gets updated on the target device when the notification is sent.
{
"notification": {
"title": "New message",
"body": "Notification sent from POSTMAN",
"sound": "custom_sound.mp3",
"badge": 2,
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"icon": "app_icon"
},
"to": "abcd...",
"content_available": true,
"priority": "high"
}
However here's the problem: how am i supposed to know what number to pass in the badge field?
Lets say A sends a message to B with badge count of 1.
B receives that notification and increases badge count to 1 automatically.
After this, lets say C wants to send a message to B, how is C supposed to know what is the current notification badge count of B, so that it can add just +1 to it, and increase the total badge count to 2?

Getting silent notification values when app starts

I am trying to implement cache meachanism for FCM on IOS. I am using Xamarin Forms with CrossGeeks FirebasePushNotificationPlugin
Push notification service works fine. I am using payload pattern as below
{
"data": {
"message" : "my_custom_value",
"other_key" : true,
"body":"test"
},
"notification": {
"body" : "hello",
"title": "firebase",
"sound": "default",
"content_available" : true
},
"priority": "high",
"condition": "'general' in topics"
}
Above pattern appears delivered notification as alert on IOS main screen.
I have written a Dependency Service for getting undeleted or unopened accumulated notifications when app starts. Dependency Service include below codes
await UNUserNotificationCenter.Current.GetDeliveredNotificationsAsync();
When I use above payload, I can get accumulated notifications. But when I use payload pattern as below, I can not.
{
"data": {
"message" : "my_custom_value",
"other_key" : true,
"body":"test"
},
"notification": {
"content_available" : true
},
"priority": "high",
"condition": "'general' in topics"
}
Actually I would like to send 2 payload types for every notification for my cache mechanism because of prevent the user's delete action. After that, I would like to show cached notifications without any lost in my app's notification page.
Shortly my question about "I am not getting silent payload values from UNUserNotificationCenter this approach is possible or not?"
Or can I prevent the user's notification delete action from IOS main screen when my app is terminated.
Note: My minimum OS version is 10.0 in info.plist
Thank you in advance.

React native Firebase iOS Production not working by sending noti to FCM single device

I'm doing a React native project with notification, using APNs Authentication Key
. It works perfectly fine on android and iOS dev.
But when I export ipa as adHoc run on device, the app stop receiving notification when I send noti to a single device using FCM. It only works if I send to all iOS devices.
Try to send notification via postman for sent specific user. I think this issue will be the wrong user_key.
POST: https://fcm.googleapis.com/fcm/send
headers:
Authorization:Key='YOUR_SERVER_KEY'
Content-Type: application/json
BODY: raw Data
{
"to": "User_key",
"priority": "high",
"data": {
"title": "Hello world",
"body": "Hello...",
"image": "https://vortex.accuweather.com/adc2010/images/icons-numbered/01-l.png",
"media_type": "image",
"message": "message message message messagemessage message",
"attachment": "https://vortex.accuweather.com/adc2010/images/icons-numbered/01-l.png"
},
"notification": {
"android_channel_id": "news",
"sound": "default",
"title": "Hello world",
"body": "Hello...",
"image": "https://vortex.accuweather.com/adc2010/images/icons-numbered/01-l.png"
}
}

FCM push notifications opens when returning to app instead of showing in the status bar in iOS

How can I make the notifications to show in the status bar instead of queuing up and received in the app when brought to the foreground?
I have set up the FCM-account with the APNs, enabled push notification, background fetch and remote notifications.
I've done the equivalent on android where it works as expected.
My message looks like this:
{
"notification": {
"body": "this is a body",
"title": "this is a title",
"content_available": true
},
"priority": "high",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"id": "1",
"status": "done"
},
"to": "TOKEN"
}'
What am I missing?
The notifications appear only when the app is not in foreground. If you want to display them when in foreground, you should implement your custom UI for this.

Notification Service Extension does not handle data messages when using Firebase Data Message

The app is on both iOS and Android, for this notification to work on both platforms, I removed notification field from notification json payload. But now iOS does not handle this notification when in background.
This one works on iOS but it has notification field which I do not want.
{
"registration_ids": [
"...",
"..."
],
"priority": "high",
"notification": {
"body": "Notification Body.",
"title": "Notification Title"
},
"data": {
"userId": "11111",
"badge": 10
}
}
This one works in android but not working on iOS when in background:
{
"registration_ids": [
"...",
"..."
],
"mutable_content": true,
"content_available": true,
"data": {
"click_action": "AndroidIntent"
"message": "Notification Body",
"myDataField": "11",
"location": "3",
"imageurl": "http://image.com/13fd.png"
}
}
The bottom one does not even enter my Notification Service Extension. How do I make sure my Notification Service Extension is called without adding a notification field on my json?
I have the same thoughts. I was thinking of receiving data from firebase and push local notification with customized title and body with notification service extention. This idea worked fine in foreground by implementing didReceiveRemoteNotification userInfo: in appDelegate to receive userInfo.
But it didn't work in background mode by enabling content_available. you send notification using APN Servers not Fcm Servers relating to firebase docs. I suggest to have a look in content_available and mutable_content
Remove content_available since this is the property to handle silent notifications.

Resources