Grouping Notification in Notification Tray - ios

In my app, I'm having Push Notification. When more than one notification received in my app means I need to show 2 Notification Received (Grouping) but actually It Displaying Both notifications separately.

Related

FCM in background in swift

My question is basically if I can detect when a push notification arrives when the app is in the background, the notification itself .. if it arrives, it shows me, but I need to detect the notification data when it arrives in the background without having to touch the notification..
You can't if it's a push with a message payload. They're always shown to the user, and you don't get any callbacks unless the user taps it, or the app was in the foreground when it was received.
I would approach this by sending a silent notification, and then when the app receives it, scheduling a local notification to show the message to the user.
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app
https://developer.apple.com/documentation/usernotifications/scheduling_a_notification_locally_from_your_app

receive push notification when a certain date expirespush notification

I have an app that has the Firebase Realtime Database as database.
In the app there are different products that expire after a certain time.
The database contains the expiry date and the exact time. How do I get the user to receive a push notification if the product is only available for 10 minutes, even if the app is completely closed?
Do I have to save the data on my device and send a local push notification from there?
Currently the user only receives a push notification when a new product is added.
A "local push notification" isn't really a thing. There are local notifications and push notifications. Push notifications are sent (pushed) from your server, through Apple's APNS (Apple Push Notification Server) and to your app's user.
You can schedule local notifications locally for some future time. There's really no difference to the user. It displays a message in the notification center which the user can tap to wake up your app, even if it wasn't running when the notification "goes off."
It sounds like you want to schedule a local notification.
If the trigger comes from your server then you could trigger a push notification. Those are also displayed to the user in the notification center whether your app is running or not.

Getting notification badge number based on delivered notification swift

I have an application which receives Push Notification and these notifications are delivered properly to the device. However when these notifications are delivered badge does not count. I have read online that one sends badge number with the payload which I understand but does not work for my case. Notifications are delivered based on different instances and I want to be a able to increase the badge number based on the available notifications the user has not opened his device to view.
With payload, there is no way to know if a user viewed the notification already and zero it. I am trying to avoid setting a badge in the payload to maybe 7 whereas the unopened notification on the device is one.
Since push notification are handled by iOS and not by ios app you can't change the application badge on receiving a push notification.
Though you can send the badge number in the payload of the push notification as you already send, so you have to do the calculation on server side.
Go through Local and Push Notification Programming Guide and especially the The Notification Payload.

Can UNUserNotificationCenter.getDeliveredNotifications() be used to retrieve user-directed push notifications

If a server sends a push notification to the user, but the user does not tap on that notification, can the app still determine that there was a push delivered to the handset and obtain the push payload using UNUserNotificationCenter.getDeliveredNotifications(), or is this method only for retrieving local notifications?
From the doc:
notifications
An array of UNNotification objects representing the
local and remote notifications of your app that have been delivered
and are still visible in Notification Center. If none of your app’s
notifications are visible in Notification Center, the array is empty.
So, yes it will return also push notifications not opened yet and visible in Notification Center.

Suppress/Hide push notifications in iOS when the app is running

I receive push notifications on certain events from a notification server we have.
I do want these notification alerts to appear when the app is not active in the background/foreground
I don't want the notification alert to appear when the app is active in the background (foreground not a problem since the notification doesn't show anyway). I want to show my own local notification, only.
Is there any way to do this from code? Basically I want to hide the remote push notification and instead show a local notification when my app is active.
P.S - The notification server sending silent notifications is not an option - the server does not know when our app is running/not running. There is no communication between the app and this server.
You can notify your application first and then show a local notification with that. To perform this you can simply send content-available notification from server. This makes your app notified and then you can decide on showing local notification or not.

Resources