How to set badge when using UNUserNotification for local notifications on IOS10 - ios10

I am using UNUserNotification to push repeated local notifications to the user. I am trying to set badge number on the app to indicate the missed notifications.
I searched through this forum and found
iPhone: Incrementing the application badge through a local notification
This says that it is not possible for recurring local notification. That post is couple of years old and they were using UILocal notification.
is this still true for UNUserNotification? Is there no way to set badge count?

Set the badge property of a UNMutableNotificationContent object.
let notificationContent = UNMutableNotificationContent()
notificationContent.badge = 3
From the UNMutableNotificationContent documentation:
badge
The number to display as the app’s icon badge.

Related

Badge number not updating in UrbanAirShip

I am new to iOS.
I am using urban Airship for push notification.
Now when I send notification for the first time I got badge 1.
But when I again send the notification it still reamins to +1 though
I send notification with +1 badge.
I use
[[UAPush shared] setAutobadgeEnabled:YES];
[[UAPush shared] resetBadge];
in didFinishLaunchingWithOptions method.
Thanks
Push notifications always set the badge number to the value sent. There is no incrementing. If you send no value, then the badge mains unchanged on what it was previously. If you send 0, then the badge is removed.
Looking at the documentation I find that you have to supply the correct value for the badge parameter: supported are auto,increment and decrement. Those take the recent value from UA's database and modify it according to the keyword.
This is something you need to do in the push notification JSON dictionary.
PS: you should check out our app Airship Commander when it gets approved by Apple. This has a stepper control to leave, erase or set the badge number: http://www.cocoanetics.com/2012/12/airship-commander-1-0/

changing the icon badge number when local notification fires

I need to increase the icon badge number everytime a local notification gets fired to inform the user that there is one more question he needs to answer. When the user answers a question of any sent notification the icon badge number is beeing reduced by 1. I only have one-time notifications, no recurring.
Since the app is not running when the notification fires I do not have any idea how to increase the icon badge number at that time. While there is no problem to decrease the number when the user answers a question - since this is done within the app.
Is there any possibility - maybe similar to registerForRemoteNotificationTypes for push notifications?
Many thanks!
The UILocalNotification class has a property applicationIconBadgeNumber of type NSInteger, which you can set, when scheduling the local notification.

APNS and iOS 5 Notification Center

I'm using iOS 5 and Push Notifications (with notification bar).
I have received 5 notifications that are available in the notification center. When I tap on any of them, the app launches and I am presented with the payload dictionary in application:didFinishLaunchingWithOptions. After this point, all other notifications related to the app disappear from the notification center.
I want to know if I can achieve any of the following
I can let the unread (untapped) notifications be available in the notification list (for later viewing).
I can get the payload(s) of all unread notifications in application:didFinishLaunchingWithOptions when I tap any one unread notification.
For notifications to remain in Notification Center after your app has been launched from one of them, their payload needs to include a badge number, and your app needs to refrain from setting its badge counter to 0 until it wants to clear all of its notifications from the Notification Center.
There is no way to access the notification payload of APNS messages other than the one your app was launched from. The general best practice if you need that data—particularly considering that APNS delivery is not guaranteed—is to retrieve it separately from your own web service.

how can i set alertbody text on runningtime when local notification is fired in ios4 develop?

i'm developing an iphone app.
i'm gonna use local notification. what i want is to set text of alertbody dynamically.
basically, alertbody is set statically when the local notification is scheduled.
but, in my app, the text should be downloaded when the notification is fired.
can i do this?
anyone help me..
thanks in advance.
You can't schedule a notification to have a custom message that is generated when the notification is fired.
If your app is running in the background you could fire an immediate local notification instead. See Listing 2-2 of this page on Apple's Local and Push Notification Programming Guide

How can i change badge number of my iphone app increasingly with push notification?

I have an app. I build the push notification system, and i can set the badge number also when i pushed a notification, but if i want to send another push notification, i cannot increase the badge number of application. Can i do that ?
This is not possible, you have to keep track of the badge number on the server side.