[英]iOS notification override Silent mode - iPhone Alarm Clock App
我正在制作一个闹钟应用程序
警报+音乐频道通过通知中心
如果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];
}
我们可以覆盖静音开关来播放声音。
在这种情况下,它取决于iOS在触发通知时如何设置播放声音。
你有没有在设备上检查过这个?
您应该查看AudioSession类别 。
AVAudioSessionCategoryPlayback应该可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.