UNUserNotificationCenter.current().getDeliveredNotifications only returns empty array - swift

I am trying to retrieve all delivered notifications still showing in the notification center but UNUserNotificationCenter getDeliveredNotifications(completionHandler:) just doesn't work. I can get all the pending notifications with UNUserNotificationCenter getPendingNotificationRequests(completionHandler:) but getDeliveredNotifications will simply always return a 0 count even though there are notifications on the notification center.

According to this: NUserNotificationCenter.current().getDeliveredNotifications only ever returns an empty array
Setting the badge number to 0 will clear your remote notifications.
Could that be the problem?

Related

How to show Datetime in the flutter local notification?

I'm using the flutter_local_notifications package to show the current date to a notification. I simply get the current date and use it for the notification title and the notification is forever unremovable but I don't know how to update the notification every day without opening the app.
You can set a repeating alarm and cancel the current notification and create a new one. You can cancel notification using the following code:
// cancel the notification with id value of zero
await flutterLocalNotificationsPlugin.cancel(0);

handleActionWithIdentifier : forRemoteNotification not called WatchKit

I have a notification that does not have any actions- just the default dismiss action that comes with all notifications. What method is called for the watch when a notification is tapped in the watch notification center? Not an action, but just the body of the notification.
I am looking at the Apple documentation and I'm assuming it is handleActionWithIdentifier : forRemoteNotification, but wherever I put this, it is not getting called when I tap on a notification from the notification center.
This SO question is similar, but no answers have been found that help me.
Am I correct in thinking that handleActionWithIdentifier will still work if no action was selected? According to the documentation: "If the identifier parameter contains an empty string, that means the user launched your WatchKit app from the notification interface without choosing a specific action."
Is my problem that handleActionWithIdentifier isn't called because I'm not handling an action? Or should I be using a different method?
All I need to be able to do is access the notification payload if my watch app is opened from a notification that has been sitting in the notification center. How can I do this?
Thanks in advance.

Can I control how long Chrome App notifications last?

We've got a Chrome app with working notifications, but the notification only lasts a few seconds and then goes away. Our end users are going to want that notification to stay until they dismiss it. Can that be done? We couldn't find anything in the API documentation regarding notification duration.
Update
Since Chrome 50, you can make a notification persist until dismissed with requireInteraction flag:
Indicates that the notification should remain visible on screen until the user activates or dismisses the notification. This defaults to false.
Old answer
You can't make a chrome.notifications notification last forever.
You can sort of control the duration with the priority parameter. From the relevant article (not the main documentation):
Notifications can be assigned a priority between -2 to 2. Priorities < 0 are only shown in the center; priorities > 0 are shown for increasing duration and more high priority notifications can be displayed in the system tray.
Note: if you call update changing the notification's priority, it will be re-shown as needed. You can, in principle, try to exploit that to stay visible.
If you do not need features provided by Rich Notifications, you can use web standard Notification API.
They look similar in Chrome, but do not integrate with the Message Center. As such, they do not disappear unless dismissed by user or programmatically.

Detect "Close" button in local notification

I am programming an app where the user sets a kind of daily alarm where the application shows certain information every day at the same time. I'm try to make this feature with local notifications. My problem is when the user press the close button of the local notification received, because there is no way to detect this event. I have been searching and seems no solution. I just post this question to be sure there is no solution about the "Close" event.
Thank you
did you try do add a repeating notification?
check this property: notif.repeatInterval
you can add a repeating notification, that fires every hour or day or ...

iphone badges management through push notifications

we need iphone to increase the badge numeric value on push notification arrival without initializing the application. f.e. a notification with a badge values of 1 arrives and is shown on the app icon. then another notification with badge value of 2 arrives. 2 replaces 1 on the badge, but we would like to make it 1+2=3. is a server side work around is the only way to deal with this issue?
thanks!
Yes, server side work around is the only way..
What value you will send from server will be set to the icon.
what ever value you are sending to app, that value will be displayed on top of App Icon, either the value may be 4 or 90 or 100.. if you want to do like 1+2=3, just increment the badge number dynamically i.e
Present badge number = Present badge number+2;
just pass "badge:+2" to APP , the number increased