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.
Related
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.
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.
I tried many ways to do that from the app and from the server but didn't get success.
Managing Delivered Notifications
When local and remote notifications are not handled directly by your app or the user, they are displayed in Notification Center so that they can be viewed later. Use the getDeliveredNotificationsWithCompletionHandler: method of the shared UNUserNotificationCenter object to get a list of notifications still being displayed in Notification Center. If you find any notifications that are now outdated and should not be displayed to the user, you can remove them using the removeDeliveredNotificationsWithIdentifiers: method.
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SupportingNotificationsinYourApp.html#//apple_ref/doc/uid/TP40008194-CH4-SW1
Send a silent push notification in which you have to get all the notifications of your app from notification canter and remove them according to your need.
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.
I am trying to write a notification tracking system for my app. My understanding is that a scheduled local notification is guaranteed to get delivered but that my app won't get a notice that it was delivered unless the user interacts with that notification in some way. Am I missing something? Is there some event or notification sent to the app simply to indicate that the notification appeared?
No, I don't think you have any way of knowing about the "notification not taken."
A Jailbroken device would be a different matter.
There are silent push notifications, and I haven't looked at the new notifications API in iOS 10, so I guess it's possible Apple added a silent local notification for iOS 10...
Actually there are 2 scenarios:
App in background: When a local notification is delivered by the system, app is not notified, only if user interacts with notification view app is awakened.
App in foreground: App is notified when a local notification is delivered by calling didReceiveLocalNotification method.
Local notifications are guaranteed to be delivered only is user allows this (app will ask user to allow to receive local notifications)