gpt4 book ai didi

ios - LocalNotification-iOS 7.1模拟器上的UILocalNotificationDefaultSoundName不起作用

转载 作者:行者123 更新时间:2023-12-01 18:58:15 26 4
gpt4 key购买 nike

基于此教程Simple iOS Alarm Clock Tutorial,我实现了AlarmClock App。
该通知运行良好,但没有声音。

为了解决这个问题,我尝试过:
Fix-1,并且未选中/选中我的MacOS声音设置。

如何获得简单的AlarmClock-Sound?
(信息:Youtube-Sound在模拟器上工作)

码:

-(void)scheduleLocalNotificationWithDate:(NSDate *)fireDate
{

[[UIApplication sharedApplication] cancelAllLocalNotifications];

UILocalNotification *notification = [UILocalNotification new];
notification.fireDate = fireDate;
notification.soundName = UILocalNotificationDefaultSoundName;
notification.alertBody = @"Wake-up... !!!";
notification.alertAction = @"OK";

//[notification setApplicationIconBadgeNumber:-1];
notification.applicationIconBadgeNumber = 1; // increment

[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

最佳答案

您的代码是正确的。仅仅是因为模拟器的声音无法正常工作。例如,也没有键盘单击声音。如果您将自定义声音分配给本地通知,则可以使用。

关于ios - LocalNotification-iOS 7.1模拟器上的UILocalNotificationDefaultSoundName不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24936990/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com