Toast notification have a "close button" in the upper right corner.
Is there any way to either hide this button or to react to the user clicking it?
The use case is this: I want to reschedule a notification for the next day whenever a user reacts to the notification, even when closing it. In other words: the user cannot dismiss the notification forever.
The notification is scheduled from a background task which might not be running anymore when the notification is dismissed.
You can't hide it, or trigger an action when the 'x' icon clicked..
But, for your scenario, I'd suggest you to schedule the notification every day (or what ever your needs) and make it interactive notification (add a 'take action' button).. then if the user just dismissed it or closed it by whatever.. your Background Task is already running and your notifications are scheduled.. and the last option is to click on the take action, and then you can un schedule the notifications or stop the background task => your business logic :)
Related
I have two buttons on push notification.
If user fast clicking on them, the services (onHandleIntent) starts twice.
How to prevent it.
Intent.FLAG_ACTIVITY_SINGLE_TOP doesn't help.
in the current top screen , I press a button which should pop the screen,
but BEFORE the press event is post to JS thread,
another screen is pushed to the nav stack,
so the pop operation is performed on the new coming screen,
it's wrong!!
but wait, why the press event in a below screen could produce if there's another one above it?
that's maybe the thread problem.
in JS thread the nav stack(a js object) has modified, but the real UIView change would wait until the call message reaching the UI thread. between this gap, the below screen had been pressed!
so, how could I ensure the pop should exactly pop itself??
btw, I have post the problem in theirs issuse
My app uses Local Notifications. There are situations when more than one notification is scheduled and at some point displayed. When notifications are displayed badge number is updated automatically. When user clicks on one of the notifications I manually decrease badge number and cancel the notification.
The problem starts when user manually dismisses notification from Notification Center. The badge number is not updated. There are situations when there are no notifications displayed in Notification Center and badge shows a number. User is not able to clear the badge.
Setting the badge number to 0 (instead of decreasing it) after clicking on one of the notifications is not an option because it causes all notifications to disappear from Notification Center.
Is there a good way to resolve this issue?
Is there a good way to resolve this issue?
No.
Your app isn't notified when a user dismisses the local notification. Only push notifications can set the badge number when your app isn't running.
The badge is intended to represent the internal state of some data in your app that you control. There is no way to make it always match the number of items in the user's notification center. This is also why you get no notification if the user cancels your local notification.
According to OS X Mountain Lion Release Notes:
"The user has ultimate control over what notifications are displayed, and the style (banner, alert, etc). There is no mechanism to override the user preferences."
Even though all I want to do is "downgrade" from alert style to banner style... Fine. But can I at least find out whether a notification is of alert or banner style inside the didActivateNotification method?
When the alert is a banner (which is what I want), clicking its contents is the only possible action, and this both triggers didActivateNotification method with notification.activationType value of NSUserNotificationActivationTypeContentsClicked and closes the notification banner. I want my app to respond to this action by opening an internet URL.
When the user chooses alert-style notifications, clicking the alert contents also generates didActivateNotification with the same value of notification.activationType, but it stays on screen instead of going away (it only goes away when the Action button is pressed, and notification.activationType has a different value then). I don't want my app to trigger an action repeatedly for the same alert notification, in case the user clicks the content area of an alert notification.
An alternative solution would be to force the alert notification bubble to dismiss when the user clicks its contents. Is this possible?
You can remove the notification with the following:
[[NSUserNotificationCenter defaultUserNotificationCenter] removeDeliveredNotification:notification];
Wondering if there is a notification available if a UIAlertView pops up?
Background: my app asks the user for a PIN after a period of inactivity but I would like to prevent it if an alert is on screen.
I don't want to go through my code and find all alerts and disable the PIN checker, instead a notification would be awesome. Any hope with NSNotification?
Just found the answer. It is hidden in here:
Can I get message when I show UIAlertView
If you listen to the "UIWindowDidBecomeVisibleNotification" notification, it will also fire for your own alerts, not only for system alerts.
For your own alerts, the application does not resign activiation however.