【问题标题】:local notification sound is not working本地通知声音不起作用
【发布时间】:2012-08-29 06:40:14
【问题描述】:

在 iPhone 应用中,

我正在设置本地通知。

我正在设置自定义声音。

收到通知时我无法“听到”任何声音。 甚至没有默认声音。

在我的 iPod touch 和我的设备中都没有。

任何机构可以帮助我找出原因?

非常感谢。

这里是代码。

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

localNotification.fireDate=[dateFormat dateFromString:alarm_date];

localNotification.alertBody = @"Alarm.";

localNotification.soundName = [filePath lastPathComponent];

//localNotification.soundName =soundname; 
//UILocalNotificationDefaultSoundName;

localNotification.applicationIconBadgeNumber = 1;

localNotification.alertAction=@"Show";


[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

[localNotification release];

回答 得到了愚蠢的点:通知声音都只在你的应用程序在后台或关闭时播放。 对不起这个问题。 无论如何谢谢。

【问题讨论】:

  • 愚蠢的问题,但您是否关闭了 iOS 设备侧面的静音开关?
  • 我检查了我的设备声音播放良好。
  • 好吧,只是想确认一下。您是否检查过您的应用程序通知是否大声播放声音?您可以在设置应用程序的通知部分检查这一点。

标签: iphone objective-c ios xcode cocoa-touch


【解决方案1】:

作为通知声音播放的声音应少于 30 秒

其他:

根据 Apple Developer Documentation,您需要使用“aiff”、“caf”或“wav”文件。

【讨论】:

    【解决方案2】:

    我觉得这对你来说已经够用了......

        UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    
        localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
    
        localNotification.timeZone = [NSTimeZone defaultTimeZone];
        localNotification.alertBody = @"You have long time to care your......";
        localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber]+1;
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.repeatInterval = kCFCalendarUnitMinute;
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
        [localNotification release];
        localNotification = nil;
    

    【讨论】:

    • 感谢您帮助我,我正在尝试。
    猜你喜欢
    • 2021-10-31
    • 1970-01-01
    • 2020-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多