UILocalNotification点击事件 [英] UILocalNotification click event
本文介绍了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时,我可以来到某个视图控制器.该怎么办?谢谢
i want to when i click the UILocalNotification at the status bar,i can come to some view controller.how to do?thank you
推荐答案
有两种方案可以处理本地通知,
There are two scenarios to handle Local Notification,
1.由于单击了本地通知而启动了应用程序
-(BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
//load your controller
}
return YES;
}
2.应用程序处于活动状态,然后将此代码添加到AppDelegate
2. Application is active , then add this code in the AppDelegate
-(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
//load your controller
}
这篇关于UILocalNotification点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文