UILocalNotification 实现 本地 提醒
来源:互联网 发布:mac adobe reader8.0 编辑:程序博客网 时间:2024/06/05 16:16
http://www.devdiv.com/thread-69786-1-1.html
UILocalNotification *notification=[[UILocalNotification alloc] init];
if (notification!=nil)
{
NSDate *now=[NSDate new];
notification.fireDate = [now dateByAddingTimeInterval:period];
NSLog(@"%d",period);
notification.timeZone=[NSTimeZone defaultTimeZone];
//设置提醒声音为默认的声音
//notification.soundName=UILocalNotificationDefaultSoundName;
notification.soundName = @"ping.caf"; //设置显示声音
//notification.alertBody=@"TIME!"; notification.alertBody = [NSString stringWithFormat:@"@%时间到了!",nameStr];//显示的提示信息
NSDictionary* info = [NSDictionary dictionaryWithObject:uniqueCodeStr forKey:CODE];
notification.userInfo = info;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
设置的时间到了以后,会自动在桌面弹出一个提示框,点显示后,就可以启动软件。然后在
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif)
{
NSLog(@"Recieved Notification %@",localNotif);
NSDictionary* infoDic = localNotif.userInfo;
NSLog(@"userInfo description=%@",[infoDic description]);
NSString* codeStr = [infoDic objectForKey:CODE];
}
}里,对lanchOptions进行处理,找到它里面的信息,就可以拿到设置时的需要处理的东西,就可以继续操作了。
如果此时你的客户端 软件仍在打开,则会调用
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
{
}
一样的处理方法。
在程序中取消已经设定的通知的方法了:
NSString *myIDToCancel = @"some_id_to_cancel";
UILocalNotification *notificationToCancel=nil;
for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
if([aNotif.userInfo objectForKey:@"ID"] isEqualToString:myIDToCancel])
{
notificationToCancel=aNotif;
break;
}
}
[[UIApplication sharedApplication] cancelLocalNotification:notificationToCancel];
NSString *myIDToCancel = @"some_id_to_cancel";
UILocalNotification *notificationToCancel=nil;
for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
if([aNotif.userInfo objectForKey:@"ID"] isEqualToString:myIDToCancel])
{
notificationToCancel=aNotif;
break;
}
}
[[UIApplication sharedApplication] cancelLocalNotification:notificationToCancel];
- UILocalNotification 实现 本地 提醒
- UILocalNotification实现本地的闹钟提醒
- Ios开发中UILocalNotification实现本地通知实现提醒功能
- UILocalNotification实现本地的闹钟提醒的方法
- UILocalNotification实现本地的闹钟提醒的方法。
- UILocalNotification实现本地的闹钟提醒的方法
- UILocalNotification实现本地的闹钟提醒的方法
- [ios] UILocalNotification实现本地的闹钟提醒【转】
- UILocalNotification实现本地的闹钟提醒的方法
- UILocalNotification实现本地的闹钟提醒的方法
- UILocalNotification实现本地的闹钟提醒的方法
- iOS开发 UILocalNotification 本地通知实现提醒功能
- iOS开发 UILocalNotification 本地通知实现提醒功能
- 本地通知(UILocalNotification)的学习和使用(通过本地通知实现提醒功能)
- ios 本地通知(UILocalNotification)的学习和使用(通过本地通知实现提醒功能)
- IOS下本地消息提醒UILocalNotification
- UILocalNotification实现本地通知
- [电源、屏保、闹钟、日程、墙纸] UILocalNotification实现本地的闹钟提醒的方法。
- Classes of Wait Events
- Android待机的suspend_sys_sync_queue分析
- oracle创建索引 .
- socket python
- Mybatis学习总结
- UILocalNotification 实现 本地 提醒
- LLDB和GDB比较
- Windows平台字符透明编程大总结
- 关于uint与int
- T-SQL象数组一样处理字符串、分割字符串
- 网站中应用QQ一键登录,详细讲解和范例
- Android里Canvas的save和restore
- Linux: Fedora 10 - WebCam D - Link DSB - C320 330K (pixels) + skype 2.0
- NET多线程同步方法详解(一):自由锁(InterLocked)