banner badges iPhone - iphone

Is there a way to have the banners/badges for my app only update to 1? For example, if I have three notifications/updates for my app, instead of showing the launch icon on the homepage with the number 3, could I just show the number 1?
I guess in essence, I'm asking can I set the max of a badge for the app I am developing for the iPhone?

You set the application badge yourself, so you can determine the algorithm for the number you display. So if you want to just set the badge to 1 if there are any messages, but no badge otherwise, just use something like this:
- (void)applicationWillResignActive:(UIApplication *)application {
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:(numberOfMessages > 0) ? 1 : 0];
}

Related

how to remove number of badge one by one while scrolling

I want to remove the badge number from my iPhone application icon when a user scrolls. I'm using iCarousel class' carouselDidScroll method. Unfortunately, the code I'm using (below) doesn't work, and the badge number remains visible. Any ideas?
- (void)carouselDidScroll:(iCarousel *)carousel
{
int badge=[[UIApplication sharedApplication] applicationIconBadgeNumber];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge--];
}
Because the postfix decrement operator decrements its operand, but it yields its previous (not yet decremented) value. Why not use badge - 1 or --badge instead?

how to remove badge notification symbol from app icon in iPhone

I am facing a problem with removing the badge number which always shows a red "1" on app icon notification symbol where there is no notification pending.
How can I solve it?
Use the below in applicationDidBecomeActive, some any methods in app life cycle..
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
When it is set to zero it should not show any badges.

Reducing badge number with Push notifications

Hi in my application when i receive push notification from server my application badge get incremented by one.and when i open app and close it did not get reduce.so my question is how to reduce badge icon on application icon when user see the notification
You can set it to any value you like. Setting it to 0 removes the badge.
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
I had this same issue, so I thought, "Why not just GET the badge number?" Then, you can do whatever you wish with it.
If you are in your AppDelegate.m file, you could use this in your application: didFinishLaunchingWithOptions: method:
int badgeNumber = [application applicationIconBadgeNumber] -1;
[application setApplicationIconBadgeNumber:badgeNumber];
This will reduce the icon badge number by one. However, be mindful that your user may have multiple notifications from your application that are still not yet viewed. Thus, you should probably set this inside of a particular method that will handle the pushes. Or, depending how your app is set up, just set the badge icon number to 0.
Hope this helps.

How to give notification on icon

How can I add some kind of notification on an application icon displayed on the springboard?
Like it can be seen on messenger icons showing a number with red color on it once new messages are received.
[UIApplication sharedApplication].applicationIconBadgeNumber = 1;

iPhone unread counts on tabbar

Which is the best way to implement on Cocoa Touch the unread counts on a icon on a TabBar?
I want to mimic the SMS or Mail application behavior, showing the unread message count to the user of my application, with a red dot containing a number.
The property you're looking for is called the badge. You set it by doing something like:
self.tabBarItem.badgeValue = #"1";
Have you looked at: setApplicationBadgeNumber?
[[UIApplication sharedApplication] setApplicationBadgeNumber:int];
For current view I use:
self.navigationController.tabBarItem.badgeValue = #"5";