Monday, 26 November 2012

How to TEST an Application on a REAL Device

youtube link  --http://www.youtube.com/watch?v=lPwlhKgZHCM


OR


Provisioning is the way by which you can test on a device. Only iPhone developer program members get this privilege - which is reasonably priced at $99/year. All of the action starts at the Developer program portal.
Here's what you need to do for on-device testing:
  • Create a certificate
  • Create a specific or Wild-card App ID
  • Add one or more test devices
  • Create a provisioning profile
  • Install the app on the test device(s)
  • Go have a beer if it all worked!

Certificates

You'll probably need at least one development certificate and one distribution certificate. You'll need a development certificate if you want to test with the APNS (Apple Push Notification Service) sandbox, or if you want to debug on the device with Xcode. I've never needed more than one of each. The distribution certificate can be used for both Ad Hoc and App Store distributions. Each certificate can be mapped to one or more devices in a profile when provisioning.
Creating a new certificate:
  • Enter the program portal
  • Click on the "Certificates" link on the left panel
  • Select the "Development" or "Distribution" tab
  • Follow the steps under the "How To" tab to actually create a certificate:
    • Generating a Certificate Signing Request
    • Submitting a Certificate Signing Request for Approval
    • Approving Certificate Signing Requests
    • Downloading and Installing Development Certificates
    • Saving your Private Key and Transferring to other Systems
Note: make sure that you install the "WWDR Intermediate Certificate".

App IDs

Apple says: "App IDs are an integral part of the iPhone Development and Provisioning Process that allows an application to communicate with the Apple Push Notification service and/or an external hardware accessory." For every app that uses APNS, In App Purchase, or external hardware accessories, you will need a specific App ID. All other apps can use a Wild-card App ID.
Example App IDs:
  5LL056TAKK.com.foo.bar (specific)
  78AGBPA5X8.* (Wild-Card)
The 10 characters at the start of the ID is called the "Bundle Seed ID". For specific App IDs, the remainder (ex: com.foo.bar) must match the Bundle Identifier (CFBundleID) in the application's info.plist file. I recommend using a single Wild-card App ID for all of your applications that are not using APNS, In App Purchase, or external hardware accessories. You do notever need to enter the Bundle Seed ID into Xcode.
Creating a new App ID:
  • Enter the program portal
  • Click on the "App IDs" link on the left panel
  • Follow the steps under the "How To" tab to actually create an App ID:
    • Generating an App ID
    • Registering an App ID for Apple Push Notification service
    • Registering an App ID for In App Purchases

Devices

This is how you add a new device (iPhone, iPod Touch and maybe even the new iPad) to your account. Such devices can then be provisioned with a development or distribution profile to run apps that are not available in the App Store (this is called "Ad Hoc" distribution).
Adding new devices:
  • Enter the program portal
  • Click on the "Devices" link on the left panel
  • Click on "Add Devices" to enter each device's ID (40 hex characters). The device ID is available from iBeta (a free download from the app store) or from iTunes by clicking on the "Serial Number" label in the device's "Summary" tab. See here for more info.
Note: You can only have 100 devices per license-year. If you delete a device, the slot won't actually be available until the renewal date of your license. Once you add a device after your renewal date, all used slots get locked-in until the NEXT year.

Provisioning

You will probably create at least 3 provisioning profiles: one for development, one for Ad Hoc distribution, and the third for App Store distribution. Each profile must map to one App ID, one or more certificates, and one or more devices. I've never needed to specify more than one certificate in a profile.
Creating a profile:
  • Enter the program portal
  • Click on the "Provisioning" link on the left panel
  • Select the "Development" or "Distribution" tab
  • Click on "New Profile"
  • Pick a new profile name, certificate, App ID, and devices. If there are no devices in the list, you can always edit the profile later.
  • Click "Submit". If the status beside the new profile says "Pending", just wait a few seconds, then refresh the page.
  • Click "Download" and save the file to somewhere on your machine. It'll have a funny extension called .mobileprovision. For Ad Hoc distribution, you will need to email this file to anyone that gives you their device ID. Some email programs (Outlook Web Access comes to mind) will treat this file as a virus, so you might need to package it in a ZIP file.

On-device testing - finally!

Now that you have a provisioning profile, what do you do with it? For Ad Hoc testers, you'll email them that file, which they will drag into iTunes before installing the application binary as described here. But first, you'll need to modify your Xcode project (if you haven't already) to use the profile.
  • Install the new profile into Xcode. You do this by dragging the file onto the Xcode icon in the application dock. It should create a file in~/Library/MobileDevice/Provisioning Profiles.
  • In Xcode, you need to decide which build configuraion(s) you want to use for device testing (for both Ad Hoc and App Store distributions). When you create a new project, you get "Debug" and "Release" configurations. I usually create two new configurations, "Distribution" and "App Store", for Ad Hoc and App Store distributions respectively. I reuse the Debug configuration for on-device Development testing. This gives me the following build combinations:
    • Simulator | Debug
    • Simulator | Release
    • Device | Debug
    • Device | Distribution
    • Device | App Store
  • In Xcode, add the new profile to the desired configuration(s) using Project | Edit Project Settings | Build tab | Code Signing category. The gory details of how to create new build configurations and assign profiles to them can be found here:
    • Enter the program portal
    • Click on the "Distribution" link on the left panel
    • Under the "Prepare App" tab, read the "Building your Application with Xcode for Distribution" instructions
  • Clean all targets and build! With any luck, you'll end up with a .app "file" (it's actually a directory, but looks like a file) in the build directory. You can easily find this directory by expanding the Products folder in Xcode's left pane, right-clicking on the .app "file" and selecting "Reveal in Finder".
For Ad Hoc distribution:
  • Right click on the .app "file" and select Compress to create a ZIP file - recipients must unzip that file before dragging the extracted .app "file" into iTunes after they have installed the provisioning profile that contains their device
For local device testing:
  • Connect the iPhone to your Mac using the standard USB cable
  • Do "Build and Run" to compile the project and install it on your device. This works for both Development and Distribution profiles. Newer versions of Xcode are smart enough to prompt you to install the right profile on the device if it's missing.
  • If you keep the phone connected while you run your app, you can view the console output using the Xcode Organizer (Window | Organizer)

Tips

Here are some random tips that might make your life easier. Maybe.
  • If you add new devices to an existing provisioning profile, you do not need to rebuild the binary with the new profile. You can simply send the new profile to the new devices' owners and they can use any previously-built binary that was paired with an older version of that profile.
  • Coming soon - creating IPA files
  • Coming soon - deciphering pesky iTunes/Xcode error messages
  • Coming soon - what's get-task-allow all about?

Saturday, 24 November 2012

How to Test your App on areal Device

In our previous article on getting started with iPhone development, you learnt how to use the iPhone SDK provided by Apple to develop your first iPhone application. For testing purposes, you used the iPhone Simulator, provided as part of the iPhone SDK. While the iPhone Simulator is a very handy tool that allows you to test your iPhone applications without needing a real device, nothing beats testing on a real device. This is especially true when you are ready to roll out your applications to the world - you must ensure that it works correctly on real devices. In addition, if your application requires accesses to hardware features on an iPhone/iPod Touch, such as the accelerometer and GPS, you need to test it on a real device - the iPhone Simulator is simply not adequate.
A repeated criticism from iPhone app developers comes from the difficulty they find in deploying their application to a real iPhone or iPod Touch. Apple, for better or worse, has designed a process involving many hoops that must be jumped through, and this has prompted developers to grumble, and others to explore alternative, non-official open tool chains, which do not require app signing. In this article, I will walk you through the steps you need to take in order to test your iPhone apps on a real device, be it iPhone, or iPod Touch, the offical Apple way.

Sign up for the iPhone Developer Program

The first step towards testing your applications on a real device is to sign up for the iPhone Developer Program athttp://developer.apple.com/iphone/program/. There are two programs available - Standard and Enterprise. For most developers wanting to release applications on the App Store, they can simply sign up for the Standard program, which costs US$99. Check out http://developer.apple.com/iphone/program/apply.html to know more about the differences between the Standard and Enterprise programs.

Start your Xcode

In order to test your iPhone applications on your device, you need to obtain an iPhone Development Certificate from the iPhone Developer Program Portal. This needs to be done once for every device you wish to test your apps on. The following sections walk you through the various steps, from obtaining your certificate, to deploying your applications onto the device.
First, obtain the 40-character identifier that uniquely identitfies your iPhone/iPod Touch. To do so, connect your device to your Mac and start Xcode. Select the Window > Organizer menu item to launch the Organizer application. Figure 1 shows the Organizer application showing the identifier of my iPhone. Copy this identifier and save it somewhere. You will need it later on.

Figure 1 Obtaining the identifier for your iPhone/iPod Touch

Generating a Certificate Signing Request

Before you can request a development certificate from Apple, you need to generate a Certificate Signing Request. This step must be performed once for every device you wish to test on. To generate the request, you can use the Keychain Access application located in the Applications/Utilities/ folder (see Figure 2).

Figure 2 Launching the Keychain Access application
In the Keychain Access application, select the Keychain Access > Certificate Assistant menu and select Request a Certificate From a Certificate Authority (see Figure 3).

Figure 3 Requesting a certificate
In the Certificate Assistant window (see Figure 4), enter your email address, check the Saved to disk radio button and check the Let me specify key pair information checkbox. Click Continue.

Figure 4 Providing certificate information
Choose a key size of 2048 bits and use the RSA algorithm (see Figure 5). Click Continue.

Figure 5 Specifying key pair information
You will be asked to save the request to a file. Use the default name suggested and click Save (see Figure 6).

Figure 6 Saving the certificate request to a file

Logging in to the iPhone Developer Program Portal

Once you have generated the certificate signing request, you need to login to Apple's iPhone Dev Center (see Figure 7). Click on the iPhone Developer Program Portal link on the right of the page. Remember, you need to pay US$99 in order to access this page.

Figure 7 Logging in to the iPhone Dev Center
In the iPhone Developer Program Portal page, click the Launch Assistant button (see Figure 8) to walk you through the process of provisioning your iPhone and generating the development certificate.

Figure 8 Launching the provisioning assistant
You should see the welcome page as shown in Figure 9. Click Continue.

Figure 9 The welcome page of the provisioning assistant
First, you will be asked to create an App ID (see Figure 10). An App ID is a series of characters used to uniquely identify an application (or applications) on your iPhone. You only need to create an App ID once per application, i.e. you do not need a new App ID for new versions of your app. Enter a friendly name to describe this App ID (to be generated by Apple). Click Continue.

Figure 10 Creating an App ID
The next screen allows you to provide a description of your iPhone/iPod Touch. You need to provide the device ID that you have obtained earlier (see Figure 11). Click Continue.

Figure 11 Assigning a device for the provisioning
You are now ready to submit the certificate signing request to Apple (see Figure 12). The instructions on the screen show you the steps that you have performed earlier. Click Continue.

Figure 12 Generating a certificate signing request
In this screen, click the Choose File button (see Figure 13) to select the certificate signing request file that you have created earlier. Once the file has been selected, click Continue.

Figure 13 Submitting a certificate signing request
Provide a description for your provisioning profile (see Figure 14). A Provisioning profile will be generated so that you can download it at a later stage and install it on your device. Click Generate.

Figure 14 Naming your provisioning profile
A Provisioning profile will now be generated (see Figure 15). Once it is generated, click Continue.

Figure 15 Generating a provisioning profile
You are now ready to download the generated Provisioning profile onto your Mac (see Figure 16). Click Continue.

Figure 16 Downloading and installing your provisioning profile
Drag and drop the downloaded Provisioning profile (in the Downloads folder) onto Xcode (located in the Dock). This will install the Provisioning profile onto your connected iPhone/iPod Touch. Click Continue (see Figure 17).

Figure 17 Instructions to verify the installation
You can verify that the Provisioning profile is installed correctly on your device by going to the Organizer application and viewing the Provisioning section (see Figure 18) to see if the profile has been added.

Figure 18 Verifying the provisioning profile on the Organizer
Back in the iPhone Developer Program Portal, you are now ready to download and install the development certificate onto your iPhone/iPod Touch. Click the Download Now button (see Figure 19) to download the development certificate to your Mac. Click Continue.

Figure 19 Downloading and installing the development certificate
In the Downloads folder of your Mac, double-click on the developer_identify.cer file that you have just downloaded to install it into a keychain on your Mac. When prompted (see Figure 20), click OK.

Figure 20 Adding a certificate to the keychain
Back in the iPhone Developer Program Portal, you can now verify that the certificate has been installed properly in the Keychain Access application (see Figure 21). Click Continue.

Figure 21 Instructions for verifying the installation of the certificate
In the Keychain Access application, select the login keychain and look for the certificate named "iPhone Developer:" (see Figure 22). If you can see it there, your certificate is installed correctly.

Figure 22 Verifying the installation of the certificate
You are now almost ready to deploy your iPhone application onto your iPhone/iPod Touch. Click Continue (see Figure 23).

Figure 23 Instructions for installing your applications with Xcode
Click Done to dismiss the dialog (see Figure 24).

Figure 24 Finishing the installation
In Xcode, under the Active SDK item (if this item is not already on the toolbar, go to View > Customize Toolbar and add it to the toolbar), select the OS version number of the device that is currently connected to your Mac. In my case, my iPhone is running the older iPhone OS 2.0, hence I selected "iPhone Device (2.0)" (see Figure 25).

Figure 25 Selecting the active SDK
With your application project open in Xcode, press Command-R to run the application. You will now be prompted for permission to access the certificate saved in your keychain. Click Allow (or Always Allow) to go ahead with the signing (see Figure 26).

Figure 26 Signing your application with the certificate
Your application will now be deployed to the device. You can see its progress in the Summary tab of the Organizer application (see Figure 27).

Figure 27 Checking the Organizer for installation progress
Once the application is deployed onto your device, it will be running automatically. You can capture screenshots of your device by going to the Screenshot tab of the Organizer application, and pressing the capture button (see Figure 28).

Figure 28 Capturing screenshots using Organizer

Summary

In this article, you have seen the various steps required to deploy your application to your iPhone or iPod Touch. While the number of steps looked intimidating, it is actually quite straightforward. The iPhone Developer program allows you to provision up to 100 devices for testing purposes. Once a device is provisioned, you can then use the development certificate to deploy your applications onto it.

Wednesday, 21 November 2012

Local notification immediately while running in the background


- (void)applicationDidEnterBackground:(UIApplication *)application { 

NSLog(@"Application entered background state."); // bgTask is instance variable 

NSAssert(self->bgTask == UIInvalidBackgroundTask, nil);

bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{ dispatch_async(dispatch_get_main_queue(), ^{

[application endBackgroundTask:self->bgTask]; 

self->bgTask = UIInvalidBackgroundTask;

});
}];

[application endBackgroundTask:self->bgTask]; self->bgTask = UIInvalidBackgroundTask;

dispatch_async(dispatch_get_main_queue(), ^{ while ([application backgroundTimeRemaining] > 1.0) {
init];

friend]; nil);
NSString *friend = [self checkForIncomingChat]; if (friend) {
UILocalNotification *localNotif = [[UILocalNotification alloc]
if (localNotif) { localNotif.alertBody = [NSString stringWithFormat:
NSLocalizedString(@"%@ has a message for you.", nil), localNotif.alertAction = NSLocalizedString(@"Read Message",
localNotif.soundName = @"alarmsound.caf"; localNotif.applicationIconBadgeNumber = 1; [application presentLocalNotificationNow:localNotif];

Local Notification in iPhone


Creating, configuring, and scheduling a local notification


- (void)scheduleNotificationWithItem:(ToDoItem *)item interval:(int)minutesBefore {

NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];

NSDateComponents *dateComps = [[NSDateComponents alloc] init];

[dateComps setDay:item.day]; [dateComps setMonth:item.month];

[dateComps setYear:item.year]; [dateComps setHour:item.hour];

[dateComps setMinute:item.minute]; NSDate *itemDate = [calendar dateFromComponents:dateComps]; [dateComps release];

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

if (localNotif == nil)
return; 

localNotif.fireDate = [itemDate addTimeInterval:-(minutesBefore*60)];

localNotif.timeZone = [NSTimeZone defaultTimeZone];

localNotif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"%@ in %i minutes.", nil),
item.eventName, minutesBefore]; localNotif.alertAction = NSLocalizedString(@"View Details", nil);


localNotif.soundName = UILocalNotificationDefaultSoundName; 

localNotif.applicationIconBadgeNumber = 1;

NSDictionary *infoDict = [NSDictionary dictionaryWithObject:item.eventName forKey:ToDoItemKey];

localNotif.userInfo = infoDict;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

 [localNotif release];
}


Tuesday, 20 November 2012

Local notification Tutorial


Way back when, when everyone was still complaining about Apple’s lack of support for (3rd party) multitasking, there was a simple solution put in place. This solution was known as push notifications.
Push notifications solved many of the issues associated with backgroundprocessing. For example, when quitting the AIM application, the server could keep you logged in and send you a push notification when a new message arrived. You could then tap on a View button that would launch the app.
This solution is great and all, but it still requires that you have an active internet connection. As of iOS4, Apple has introduced a new type of notification that can be scheduled to fire within the device itself. It requires no complicated server programming, or additional configuration with iTunes. I am talking about Local Notifications.
Local notifications can be scheduled on the user’s iDevice to fire at any given time; you can even set them to be recurring. Today, we will explore these notifications and I will provide you with a simple example of how to schedule, view, and handle local notifications. Here is a quick screenshot of the project that we are going to create (note I am using the iPhone 4 simulator).
The project will allow a user to schedule a location notification to fire off at a given date. Using the text field, they are also able to specify some text for the notification. The table view below displays a list of all of the currently scheduled location notifications within the application.
So, by now (if you are an avid iCodeBlog reader), you are already a killeriPhone dev and I can rush through the stuff that is not related to the notifications. I will try to provide links to tutorials about sections that I rush through as well.

1. Create a View-Based Application

We will be using this as our starting point. Check out this tutorial if you are unfamiliar with doing this. Name the project Notifier.

2. Create All Properties and Dummy IBActions

This is usually a good first step when tackling an application like this. Let’s get everything set up in the .h and .m files so we only have to visit Interface Builder Once. Here is what our NotifierViewController.h file looks like.
@interface NotifierViewController : UIViewController<UITableViewDelegate,UITableViewDataSource> {
	IBOutlet UITableView *tableview;
	IBOutlet UIDatePicker *datePicker;
	IBOutlet UITextField *eventText;
}
 
@property (nonatomic, retain) IBOutlet UITableView *tableview;
@property (nonatomic, retain) IBOutlet UIDatePicker *datePicker;
@property (nonatomic, retain) IBOutlet UITextField *eventText;
 
- (IBAction) scheduleAlarm:(id) sender;
 
@end
Seems clear enough. We have 3 UI elements that we care about and one action. One thing to note is, your class should implement the UITableViewDelegate and UITableViewDataSource protocols. This is because we will be displaying a tableview containing all of the scheduled alarms.
Now, do all of the necessary steps in your .m file. This includes memory management for the IBOutlets and creating a dummy method for the scheduleAlarm IBAction. Your .m file should look something like this. Note: I have omitted import statements because my syntax highlighter wasn’t digging them.
@implementation NotifierViewController
 
@synthesize datePicker,tableview, eventText;
 
- (IBAction) scheduleAlarm:(id) sender {
 
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
 
- (void)viewDidUnload {
	datePicker = nil;
	tableview = nil;
	eventText = nil;
}
 
- (void)dealloc {
    [super dealloc];
}
 
@end
Now it’s time to build our interface. Open Interface builder and construct an interface like this.
If you want my super sweet green button image, here it is:
After creating the interface, make sure you hook up all of the UIcomponents to their corresponding IBOutlets and hook up the touchUpInside: method of the button the your scheduleAlarm: IBAction. For more info on hooking up IBOutlets, check out this tutorial.

3. Implement UITableViewDelegate and UITableViewDataSource Delegate methods to List Currently Scheduled Local Notifications

It may seem weird to implement the code to display the notifications before the code that creates them, however I like this approach better. This way, once we schedule the notifications, they automagically appear in our table. Add the following code to your .m file.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // We only have one section
    return 1;
}
 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of notifications
    return [[[UIApplication sharedApplication] scheduledLocalNotifications] count];
}
 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
    static NSString *CellIdentifier = @"Cell";
 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
 
    // Get list of local notifications
    NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
    UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row];
 
    // Display notification info
    [cell.textLabel setText:notif.alertBody];
    [cell.detailTextLabel setText:[notif.fireDate description]];
 
    return cell;
}
OK, finally some “real” code. Most of this code should seem pretty straight forward. If not, check out this tutorial on UITableViews.
So, the new code here is dealing with retrieving a list of scheduled notifications. Calling the scheduledLocalNotifications method of UIApplication will return an NSArray of all notifications scheduled by the current app. We just index into this array and grab each notification.
Finally, we are displaying the alertBody (text that displays when the notification fires) and the fireDate (date and time when the notification will display) in the tableview cell.

4. Scheduling Notifications

And now for the moment you’ve been waiting for… OK, probably not, but definitely the most exciting (least boring) part of this tutorial. Let’s implement that scheduleAlarm: IBAction that you framed out earlier. Update your .m file to contain the following code.
- (IBAction) scheduleAlarm:(id) sender {
    [eventText resignFirstResponder];
 
    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
 
    // Get the current date
    NSDate *pickerDate = [self.datePicker date];
 
    // Break the date up into components
    NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit )
												   fromDate:pickerDate];
    NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit )
												   fromDate:pickerDate];
    // Set up the fire time
    NSDateComponents *dateComps = [[NSDateComponents alloc] init];
    [dateComps setDay:[dateComponents day]];
    [dateComps setMonth:[dateComponents month]];
    [dateComps setYear:[dateComponents year]];
    [dateComps setHour:[timeComponents hour]];
	// Notification will fire in one minute
    [dateComps setMinute:[timeComponents minute]];
	[dateComps setSecond:[timeComponents second]];
    NSDate *itemDate = [calendar dateFromComponents:dateComps];
    [dateComps release];
 
    UILocalNotification *localNotif = [[UILocalNotification alloc] init];
    if (localNotif == nil)
        return;
    localNotif.fireDate = itemDate;
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
 
	// Notification details
    localNotif.alertBody = [eventText text];
	// Set the action button
    localNotif.alertAction = @"View";
 
    localNotif.soundName = UILocalNotificationDefaultSoundName;
    localNotif.applicationIconBadgeNumber = 1;
 
	// Specify custom data for the notification
    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
    localNotif.userInfo = infoDict;
 
	// Schedule the notification
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
    [localNotif release];
 
	[self.tableview reloadData];
}
So, most of the explanation is in the comments. I’ll talk you through some of the less obvious stuff. The first tricky area is dealing with the NSCalendar. We just use the NSCalendar object to break up the date into components. Note: This demo does not require that we break the date up into components. You could have just as easily fed the date from the date picker into the notification fireDate. The reason that I’m showing you how to break it down is, you may have some sort of custom date logic to work with and this makes things much easier in the future.
Another important bit of code is where we set the alertBody or the notification. In this example we set it to the text that the user entered into the text field. You can set this to whatever you like.
The other thing I want to mention is the infoDict in the code. This dictionary is your chance to associate some additional information with the alert. For example, if you are using this alert in a game like We Rule to notify you when a crop is ready. You might want to set a key and value that contains the id of the crop that has completed. For now, we just set some arbitrary values and you can ignore them if you like.
After actually scheduling the notification, we just reload the tableview to get it to display immediately.

5. Handling Notifications After They Fire

The last piece of this puzzle is determining what to do when a notification fires. Fortunately, this step is very easy and handled inside of the appDelegate. When a notification fires, there are one of two situations. 1. The app is running and 2. The app is not running (or running in the “background”) .
Open up your app delegate .m file and add the following code.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 
    // Override point for customization after application launch.
 
    // Add the view controller's view to the window and display.
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
 
    application.applicationIconBadgeNumber = 0;
 
    // Handle launching from a notification
    UILocalNotification *localNotif =
    [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    if (localNotif) {
        NSLog(@"Recieved Notification %@",localNotif);
    }
 
    return YES;
}
 
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
    // Handle the notificaton when the app is running
    NSLog(@"Recieved Notification %@",notif);
}
The first thing we see here is the application badge number is getting set to 0. Whenever a notification fires, it will increase the badge count on the application. Next, we handle the case when the application launches from a notification. This happens when the user presses the view button on the notification. For now, we just NSLog the data, but you should handle the notification how you see fit for your app.
Finally, we implement the didReceiveLocalNotification method. This method is required if you want to handle notifications at all in your app. You will see this method fire when the app is running and you receive a local notification. When the app is running, you will not see the UIAlertView show up with the notification data.


Link--http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/