How to give notification on icon - iphone

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;

Related

Remove LocalNotification Badge Number from launcher icon

I am trying to add a feature in app in which whenever i made a note, it will Call a UILocalNotification after few days (Hardcoded). Now, on launcher Icons i can see a red badge with marker "1". How can I remove this badge?
Best Regards
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
Add that line in whatever code handles the user's interaction with the local notification. If you want the badge to be cleared when the local notification fires, you can't (because setting the notification's applicationIconBadgeNumber property to 0 would simply mean "don't change the existing badge.")

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 do I make my iPhone app display a top banner alert, such as the Mail app does?

I have searched for this, and I can't find any documentation about doing these banner / notification / alerts... but I would really like to implement it.
In case my description in words is not clear, here is a picture of what I would like to do:
1:
I tried using this code:
UILocalNotification *note = [[UILocalNotification alloc] init];
[note setAlertBody:[NSString stringWithFormat:#"%# scanned", result]];
[note setAlertAction:#"New Scanned Image"];
[[UIApplication sharedApplication] presentLocalNotificationNow:note];
And it worked fine, such that it displayed the notification in the notifications center, but there was no banner alert.
So what are the classes that I use for this?
Thanks!
You can't define what type of alert to be used for your app's notifications. It can be set only by user through Notification Center settings.
Note! Alerts appear only when you app is closed or it is in background. If your app is active (it is in foreground), it will get only a notification (see - (void)applicationDidReceiveMemoryWarning: for details).

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";