UILocalNotification点击事件

我的代码是:

- (void) socketIO:(SocketIO *)socket didReceiveEvent:(SocketIOPacket *)packet { NSLog(@"didReceiveEvent(),%@",packet.data ); SysNotification *sysNotification=[GlobalVariable parseSysNotificationWithString:packet.data]; UILocalNotification *alarm = [[UILocalNotification alloc] init]; if (alarm) { alarm.fireDate = [NSDate date]; alarm.timeZone = [NSTimeZone defaultTimeZone]; alarm.repeatInterval = 0; alarm.soundName = UILocalNotificationDefaultSoundName; alarm.alertBody = @"Test message..."; NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"]; alarm.userInfo = infoDic; [[UIApplication sharedApplication] presentLocalNotificationNow:alarm]; } } 

我想当我点击状态栏上的UILocalNotification,我可以来一些视图controller.how要做什么?谢谢

有两种情况可以处理本地通知,

1.由于点击本地通知而启动应用程序

 -(BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { //load your controller } return YES; } 

2.应用程序处于活动状态 ,然后将此代码添加到AppDelegate中

  -(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif { //load your controller }