how to add image to iOS firebase remote notification - ios

the scenario that I am trying to achieve is that when the iOS app is closed, the remote firebase notification with an image should popup,the image can be in place of the app logo or a bigger image can open on user tap.
I am successfully getting the notification but I dont know how to add an image into it.I am guessing I"ll have to override the UNUserNotificationCenterfunctionalities and add something to the payload like
{
"priority":"high",
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "my desired image"
},
"to": "ebBUO1R..."
}
I'd be glad if anyone can point me towards the right direction or any help(preferably in swift).
Regards

Related

Flutter iOS Rich Push Notification Image not display

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

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.

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.

WatchKit Notification payload example

As you may know, on the PushNotificationPayload.aps file, actions can be set on the "WatchKit Simulator Actions" node.
Can someone provide me a real push notification payload that includes actions?
Thanks!
We use a test payload that looks something like this:
{
"aps": {
"alert": {
"title": "My Alert Title",
"body": "The body message",
},
"category": "myCategoryName"
},
"WatchKit Simulator Actions": [
{
"title": "Like it!",
"identifier": "MY_LIKE_ACTION"
}
],
"myCategoryDictionary": {
"image" : "http://.....",
"subject" : "The subject of the alert message",
"content": "Detailed content info can go here"
},
"customKey": "Use this file to define a testing payload for your notifications. The aps dictionary specifies the category, alert text and title. The WatchKit Simulator Actions array can provide info for one or more action buttons in addition to the standard Dismiss button. Any other top level keys are custom payload. If you have multiple such JSON files in your project, you'll be able to select them when choosing to debug the notification interface of your Watch App."
}

Apple Watch notification error "Unhandled Category"

I'm working with Apple Watch Notifications.
I defined my own category "myAppcategory" and passed the same to notification payload.
But, still i'm receiving below warning in XCode.
Warning: Notification category "(null)" not found. Define this category or a default category in your storyboard.
And result in watch simulator is below
Can any one help me to fix this issue?
I recently had the same issue. For me it was an invalid push notification payload. If you're using a .apns file (for example the sample one provided for notification controllers) to test make sure it's formatted correctly.
This issue is most probably is caused after a mistaken edit that broke the formatting on the PushNotificationPayload.apns file. To resolve this issue fix the formatting in your .apns file.
The most problematic part is when you add data to alert. Make sure you add comma after each entry, except last one.
"alert": {
"body": "Test message",
"title": "Optional title",
"name": "MyName"
},
Like this.
Try to remove application from iphone simulator. I had the same error and I've resolved it in this way
Also, watch for the comma in the button list
"WatchKit Simulator Actions": [
{
"title": "Stop/Save Activity",
"identifier": "stopsave"
}, // <===== THIS ONE HERE
{
"title": "Cancel Activity",
"identifier": "cancel"
}
],
You should add category value in your payload and define it in your storyboard.
"aps": {
"alert": "Test message",
"sound": "Optional title",
"category":"myCategory"
}
reference: https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/CustomzingthePushNotificationInterface.html

Resources