简体   繁体   English

本地通知声音无效

[英]local notification sound is not working

In iPhone app, 在iPhone应用程序中,

I am setting the local notification. 我正在设置本地通知。

I am setting custom sound. 我正在设置自定义声音。

I could not 'hear' any sound when notification comes. 通知到来时我无法听到任何声音。 Not even default sound. 甚至没有默认声音。

Neither in my iPod touch nor in my device. 既不在我的iPod touch中,也不在我的设备中。

Any body can help me to find out the reasons ? 任何机构都可以帮我找出原因吗?

Thanks very much. 非常感谢。

here is code. 这是代码。

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];

Answer Got the Silly Point : Notification sound all only play when your app is in the background or closed. 回答得到傻点:通知声音只在你的应用程序处于后台或关闭时播放。 Sorry for this question. 对不起这个问题。 Any way thanks. 还是谢谢你。

I think this is use full to you....... 我觉得这对你来说很有用.......

    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;

the sound should be less than 30 seconds to be played as a notification sound 声音应该少于30秒作为通知声音播放

other thing: 其他的事情:

According to the Apple Developer Documentation, you need to use "aiff", "caf" or "wav" files. 根据Apple Developer Documentation,您需要使用“aiff”,“caf”或“wav”文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM