iPhone unread counts on tabbar - iphone

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

Related

banner badges 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];
}

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).

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;

How to develop a SMS client for iOS?

my original title was How to customize TTMessageController for SMS transmission?. I changed this now because I look for any possible solution and not only those with TTMessageController.
Well, I am working on an simple application in xcode4. The user should be able to send SMS from different SMS gateways.
The background logic is quite simple because everything is managed by executing some http requests on an rest api.
The hard thing for me now is to setup the UI and that is where I need help because I am new to iOS development. This is how I want it to be:
http://img222.imageshack.us/img222/3159/bhrfe.png
There should be a recipient picker to either do autosearch on contacts or to directly pick a contact from the contact list. Beside I want only one recipient. And there should be a text area.
I also want to have a label somewhere at the bottom to show the current char number.
Since I did not find those UI elements in xcode4 library I searched for something similar and I found the TTMessageController which gives me the view you see in the picture.
However plus button does not work and I am not sure how to extend all this to do what I want.
I appreciate any idea on this.
For the + Button you can use the address book UI:
// This Code is taken from Apple's sample code QuickContacts
#import <AddressBookUI/AddressBookUI.h>
-(void)showPeoplePickerController {
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
picker.displayedProperties = displayedItems;
// Show the picker
[self presentModalViewController:picker animated:YES];
[picker release];
}
The <ABPeoplePickerNavigationControllerDelegate> delegate include this methods:
– peoplePickerNavigationController:shouldContinueAfterSelectingPerson:
– peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:
– peoplePickerNavigationControllerDidCancel:
After selecting a person you can save his/her number in an array and in the text field (e.g. comma separated)
.
For the question if it will be approved here is the guideline:
https://developer.apple.com/appstore/resources/approval/guidelines.html
22.6 Apps that enable anonymous or prank phone calls or SMS/MMS messaging will be rejected
You can't use TTMessageController to send sms. The only possible way to send sms is to use MFMessageComposeViewController. Here's a tutorial on how to use it: http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/