默认情况下,本地通知声音应该打开

时间:2014-04-30 06:02:02

标签: ios iphone uilocalnotification

我正在开发一个使用UILocalNotifications的iphone应用程序。发生通知时,会显示通知横幅,但没有声音。即来自NotificationCenter的禁用(关闭)声音。如何在默认情况下启用(开启)通知声音而不进行设置。谢谢你提前

我正在使用

UILocalNotification *notification = [[UILocalNotification alloc]init];
[notification setAlertBody:alertBody];
[notification setFireDate:thedate2];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication]scheduleLocalNotification:notification];

2 个答案:

答案 0 :(得分:0)

绝对不可能以编程方式覆盖全局通知中心设置。

如果是这样,它会导致应用程序忽视人们偏好的混乱。

想象一下,你在面试或会议中有些愚蠢的应用会产生一种荒谬的声音 - 即使你的通知是静音的,那会有多烦人?

答案 1 :(得分:0)

试试这个:

    UILocalNotification *localNotification1 = [[UILocalNotification alloc] init];
    localNotification1.fireDate = thedate2;
    localNotification1.alertBody = alertBody;
    localNotification1.repeatInterval = NSWeekCalendarUnit;
    localNotification1.soundName = @"sound.caf";
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification1];

使用.caf格式的声音。我想这会对你有所帮助。 :)