【问题标题】:LocalNotification - UILocalNotificationDefaultSoundName on ios 7.1 Simulator does not workLocalNotification - ios 7.1 模拟器上的 UILocalNotificationDefaultSoundName 不起作用
【发布时间】:2014-07-24 14:48:00
【问题描述】:

基于本教程Simple iOS Alarm Clock Tutorial 我已经实现了一个闹钟应用程序。 通知很好,但没有声音。

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

我能做些什么来获得一个简单的闹钟声音? (信息:Youtube-Sound 作品@Simulator)

代码:

-(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 objective-c xcode ios-simulator uilocalnotification


    【解决方案1】:

    您的代码是正确的。只是因为模拟器的声音不太好。例如,也没有键盘点击声音。如果您为本地通知分配自定义声音,它会起作用。

    【讨论】:

      【解决方案2】:

      如果未选择您模拟器中的默认声音名称,那么它可能不会像您一样响铃使用UILocalNotificationDefaultSoundName,我在我的应用程序包中添加了一个声音文件,并用于在我的代码中将其作为声音名称播放,它以前每次都上班

      【讨论】:

        猜你喜欢
        • 2016-01-21
        • 1970-01-01
        • 2014-11-18
        • 2016-05-22
        • 1970-01-01
        • 1970-01-01
        • 2014-12-10
        • 1970-01-01
        • 2015-02-25
        相关资源
        最近更新 更多