IOS 闹钟不响应,请看代码:
- (void)btnclock_click:(UIButton *)button { UILocalNotification *notification=[[UILocalNotification alloc] init];
if (notification!=nil) {
notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:20];
//10秒后通知
notification.repeatInterval=kCFCalendarUnitMinute;
//循环次数,kCFCalendarUnitWeekday一周一次
notification.applicationIconBadgeNumber=4;
//应用的红色数字
notification.soundName= UILocalNotificationDefaultSoundName;//声音
notification.alertBody=@"通知内容";
//提示信息 弹出提示框
notification.alertAction = @"打开";
//提示框按钮
//notification.hasAction = NO;
//是否显示额外的按钮,为no时alertAction消失
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
notification.userInfo = infoDict;
//添加额外的信息
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
}
响应闹钟:AppDelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { application.applicationIconBadgeNumber = 0;
if (notification) {
NSLog(@"didFinishLaunchingWithOptions");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
死活不响应,请各位大神帮忙解答下,不甚感激!