Event for Push Notification dismissal - ios

I am using the "badge": "+1" attribute in my Arrow Push message to create badge numbers for my app icon in Appcelerator.
When I detect the notification to be clicked from the notification bar, I decrease the badge value by 1, so it reflects the number of currently active notifications. Unfortunately I am unable to find an event for when the user deletes the notifications from the Notification Center without selecting them. This way the badge number can become async to the number of visible notifications.
Is there anything I am missing out on here? Is there perhaps another method to tie the number to the count of active push notifications?

Related

Is it possible to update badge number on app icon without openining app on push notification in iOS?

iOS 8 or 9
When I get push notification in my iOS app I want to update the badge number (count in red) shown on the app icon without opening the app.
Currently it gets updated only and only once the app is opened.
Is that possible?
You need to set a value for the badge key in your push notification payload. Payload Notification
The payload contains information about how you want to notify the user, such as using an alert, badge or sound. It can also contain custom data that you define.
To remove the badge, set the value of this property to 0.

Push Notification Changing Badge of AppIcon

I am working on an app that can receive Push-Notifications.
When a notification is received, I need to change the number of the icon's badge and increment it.
Those notifications are stored in a UITableView in my app.
When a row is pressed, this means that the notification has been read so I want to decrement the badge.
I am new to push notifications and badges and I really couldn't find any efficient way to do it
any solutions ?
Thank you.
You can't automatically increment a badge from a notification. Your notification payload must contain the badge property that will be set to the exact value you want for your badge.
To set the badge value from within your app, you can use:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:someInteger];
If you want to increment the badge by one every time you receive a notification, you need to keep track of your user's badge server-side.
For example, if you send 3 notifications to an user, you will have a badge column in your database for this user with 3 as a value. If the user opens his app and taps one of the notifications, your app will have to set the badge icon to 2 and send a request to your server to decrease the database value to 2.
TL;DR: There is no such thing as a badge:+1 or badge:autoincrement in a notification's payload. You have to keep track of the badge's value server-side.

Stack one push notification in notification center

In case the user is busy and didn't check his notifications in the notification centre. I don't want my notifications to get stacked. that may lead to removing the app. by user.
Therefore, when a notification receive I want to clear all previous notifications my app. sent and keep only the new one.
Is that possible?
Note: I want to remove them before they got clicked. If one got
clicked I can remove them easily in didReceiveRemoteNotification.

IOS push notification delete

I use a phone gap plugin and xcode 5.
Lets see the example of the problem:
The application is in background or closed.
I send the notification.
User sees the notification pop up, without clicking on it.
I send another notification.
If user open notification bar it will see two notification actually i want
to delete the previous some how and present to user only the second notification.
The eqvivalent in java is NotificationManage.cancelAll();
For now each/all notification i send are shown when user open notifications bar.
Any help appreciated.
You have (the app has) no control over that.
The user controls how many notifications they see in notification center. Notifications can be removed by the user and will be removed when acted upon (the app is opened from the notification).
You can do this by [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
in the method didReceiveRemoteNotification. In this way notification center will be cleared.

Is it possible to remove an application icon badge yet for notifications to remain in the notification center?

My app is queuing local notifications (and can also receive APNs) and the app's icon badge is getting set as a consequence.
When the app launches I want to clear the icon badge but I want the notifications to remain in the notification center history lists. But it seems this isn't possible? Setting the badge count to 0 has the effect of removing all notifications from the notification center.
Is there any way I can leave them there so it is the user's responsibility to remove them, yet at the same time clear the app's badge?
No, unless something has recently changed, the notifications in Notification Center are tied to the applications icon badge.
This code reads like it should clear only the badge, however, it is commonly used to clear the notifications in Notification Center:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
However, when the code is used, the Notification Center notifications are cleared as well. Notification Center reads what to display based on what is displayed on the icon.
Sources:
My own experience
This previous question

Resources