UILocalNotification点击事件

pen*_*ang 4 iphone ios

我的代码是:

- (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];
}


}
Run Code Online (Sandbox Code Playgroud)

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

Kin*_*iss 5

处理本地通知有两种方案,

1.由于单击本地通知,启动了应用程序

-(BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    UILocalNotification *localNotif =

        [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    if (localNotif) {

       //load your controller

    }

    return YES;

}
Run Code Online (Sandbox Code Playgroud)

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

   -(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {

        //load your controller

    }
Run Code Online (Sandbox Code Playgroud)