How to handle notification response of `UNUserNotificationCenter` when "Clear all" is done to remove all delivered notifications? - swift

I have a class which adopts UNUserNotificationCenterDelegate and its userNotificationCenter(_:didReceive:withCompletionHandler:) to manage notification responses, clear badge number etc.
This all work fine when user interacts with a single notification (clear it, use its actions or tap it to open the app) but if I have multiple delivered notifications and iOS "groups" them in a collapsed groups/section, there is an option to "Clear all". If the user taps on that the userNotificationCenter(_:didReceive:withCompletionHandler:) is never called and I cannot handle this action of "multiple notification cleared".
Is there a there any way to get a callback that "Clear all" was done on the delivered app notifications?

Related

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.

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 ...

UILocalNotification actions and snoozing

I'm working on a custom app for a client and am still relatively new to iOS development. The app involves setting reminders and I'm using UILocalNotifications. Now from my research the action on the notification will always run the app but I'm really hoping someone can correct me on that. Also from what I've read you are limited to the 'View' or 'Close' options. Ideally I'd love to have 3 buttons on the notification and not have to open the app to perform an action.
I'd like a 'dismiss' option, 'snooze' option, and an 'ok' option that dismisses the notification but runs some code in the background.
I came across a notification related question where somebody suggested opening the app with a modal view and presenting the options from there. Possible, just not as clean, I guess.
Any other ideas or is this what I have to do to achieve my desired functionality? If that's the case is there a way to close the app after I've selected one of my options from the modal view?
Thanks in advance.
That is not possible, as the notification is not created by your app but by the system, so you can't customize the appearance of the notification. (also in iOS 5, the user can choose to display the notifications as banners instead of alerts, which would hide any other button than the view and close button, if that were to be possible).
Secondly there is no way to close your app, as iOS is a user centric system, where the user takes the decision on whether to open or close app, and not the app itself.

MFMailComposeViewController and cancelling "save" action sheet?

i am using MFMailComposeViewController inside my iphone app. I notice that if i enter any text in the body and then press the cancel button, i am prompted with an action sheet with an option to save/don't save the unsent message. I have two questions:
can I programmatically prevent the "save/don't save action sheet from appearing? MFMailComposeViewControllerDelegate doesn't appear to have anything along those lines
if i do save, where is the mail saved to? i looked in my mail accounts and didn't see anything saved in any of the "draft" folders.
No, you can't avoid the action sheet appearing. It's been added in iOS 4.x to, precisely, avoid tapping on the "Cancel" button inadvertently when writing a long email, which I think it's a good idea.
It is saved in "Drafts" folder of the account used to compose the e-mail (normally, your "default account" as it is registered in the Settings of your device). I've just tried using a couple of apps and it works.

show alert in home screen

I would like to make a alertView that can show in any where and don't care there is a View or Window.It just like the safe-model alert can show on the desktop which also can accept user input.
The UIAlertView and UIActiveSheet are build upon a UIView or Window.So I didn't need these kinds.I also know the application called backgrouder has such a alert,but I don't know how to implement it.
You can't. The only way to get your message displayed on the home screen like an SMS is to PUSH this message to the user. Pre condition is that your user has accepted push notifications from your application, and that you're using the Apple Push Notification Service to push info to your users.