Updating notification badge after dissmissing notification from Notification Center - objective-c

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.

Related

iOS 11 new notification center removes all delivered notifications after user make any action with one of them

I have an issue on iOS 11. All delivered notification automatically removing from notification tray after I select any action for one of them. This happens before my code start handling action. In iOS 10 everything is ok, all delivered notifications stay in delivered and disappear only notification where I proceed some action.
My app schedule reminders with custom action, 2 buttons Activate and Stop. User can receive many of them in one day, but its very important to keep already delivered notifications, because most of them is uniq and make different actions.
If it is iOS 11 new notification center behavior or known issue, where I can read about this? Thanks a lot for help.
Minimum deployment target in my app is iOS10 and I use new UNNotificationRequest for scheduling local notifications.

Saving all push notifications data got for an app when app is in terminate or inactive state

I'm new to iOS development and currently i'm working on push notifications.I have a requirement where I will get push notifications for different functionalities in an app. When app is in terminate or inactive state all notifications will display in system notifications panel. When I tapped on particular notification remaining notifications data is lost. Is there any thing like we can store all push notifications data and when launching we can execute one by one.
No, not on iOS.
Apps like facebook do this by keeping the state of the push notification on there server. Thus allowing a client to fetch the alerts and show their read state.

iOS: badge counter vs. Notification center

I am a bit (a lot) confused about the Notification Center and the app badge counter. I have designed an iOS to-do app which uses local notifications to alert users of a scheduled reminder (which they set in the app) . The app also uses the icon batch counter to display the # of tasks due "today".
At the time of a set reminder notifications correctly show up in Notification Center. However, once the app has been opened the notifications are cleared from Notification Center. The idea is that the notifications remain available in Notification Center until the user clears them.
I have discussed this with my developer and he states that notifications can only be saved in NC when we do not use the icon batch counter. This seems very illogical to me since the icon batch counter shows the # of tasks due "today" and the notifications shown in Notification Center are alerts set by the user.
Hope you guys can help here.... Thanks!
application can set its own badge (counter) independent of the notification scheduled. so u can surely set whatever counter you want to show the today's task by:
NSUInteger tasksCount = 10;
[UIApplication sharedApplication].applicationIconBadgeNumber = tasksCount;
talking about the notifications to show in NF bar, it is configurable by user in Device's Native: Settings-> Notifications-> so you cannot force the user to show all notifications in NF bar (lets say 50 for the day) if user has configured for only 5.
Coming back to your concern, when the app is launched, Notifications from NF bar are not automatically wiped off. you have to write the CODE to remove them from inside the app.
[[UIApplication sharedApplication] cancelAllLocalNotifications];
OR
[[UIApplication sharedApplication] cancelLocalNotification:<notification object>];

Detect when a user clears notification from the notification center

My app needs to know if a user deletes/clears the apps notifications from the notification center using the clear button.
Is there either away to detect when the user removes the notification from the notification center or grab an array of notification on the notification center?
You (ie App) cannot interact with NotificationCenter, NotificationCenter interacts with the user. A user can choose not to receive any push-notifications.
http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html

Apple Push Notifications - Remove Badge But Not Notification Text

We have a requirement in our iOS5/6 app to remove the badge number from our app icon, but leave the notification text in the notification center. Setting the badge number to 0 clears out the notification text as well.
Our potential solution is to set the badge number to -1, which seems to do exactly what we are looking for. Does anyone else have any experience with doing this?
When you open the app and set the application badge to 0, all the notifications of the notification center are cleared.
This works as expected in iOS 5 and 6.0. We are able to remove the badge icon, but not the notification text by setting the badge number to -1.