NSString *strMusic = @"../Documents/heartbeats.m4a"; //声音文件不要超过30秒
NSString *strImage = @"../Documents/imm.png";
//如果用下面注释的方式访问Documents的声音和图片,不能实现想要的效果,必须用上面的方式
//NSArray *arrPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//NSString *strDoc = [arrPath objectAtIndex:0];
//NSString *strImage = [strDoc stringByAppendingPathComponent:@"imm.png"];//NSString *strMusic = [strDoc stringByAppendingPathComponent:@"heartbeats.m4a"];
UILocalNotification *notification=[[UILocalNotification alloc] init];
notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:10];
notification.timeZone=[NSTimeZone defaultTimeZone];
notification.repeatInterval = NSSecondCalendarUnit;
notification.alertAction = [NSString stringWithFormat:@" 显示闹钟"];
notification.alertBody= [NSString stringWithFormat:@"我的闹钟"];
notification.soundName = strMusic;
notification.alertLaunchImage = strImage;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
在模拟器和iphone4(5.1系统)测试通过,不知道低版本是否支持!还有不知道能否通过苹果审核?