我正在开发一个闹钟应用程序
通过通知中心的警报+音乐频道
如果 iPhone 设置为静音模式,它不会激活
许多用户要求警报覆盖静音模式
这可能吗?
干杯!
(void)addLocalNotification:(myAlarmData *)ma WeekDay:(int)mweekday
{
UILocalNotification *noti = [[UILocalNotification alloc] init];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *now = [NSDate date];
NSDateComponents *dcom = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit |NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit) fromDate:now];
[dcom setWeekday:mweekday];
[dcom setHour:ma.mHour];
[dcom setMinute:ma.mMinute];
[dcom setSecond:0];
NSDate *fireDate = [gregorian dateFromComponents:dcom];
noti.fireDate = fireDate;
noti.timeZone = [NSTimeZone localTimeZone];
noti.alertBody = [NSString stringWithFormat:@"Wake up %@!", [GlobalData gSettings].name];
noti.soundName = [NSString stringWithFormat:@"%@.caf", ma.soundName];
noti.alertAction = @"OK";
noti.repeatInterval = NSWeekCalendarUnit;
noti.userInfo = [[[NSDictionary alloc] initWithObjectsAndKeys:
ma.mid, @"mid",
[NSString stringWithFormat:@"%d", mweekday], @"day",
ma.soundName, @"sound",
[NSString stringWithFormat:@"%d", ma.snooze], @"snooze",
ma.title, @"title",
@"Close", @"action",
@"real", @"more",
nil] autorelease];
[[UIApplication sharedApplication] scheduleLocalNotification:noti];
[noti release];
[gregorian release];
}