当用户通过地理围栏进入一个区域时,我会触发一个本地通知。但是,当我按下主页按钮查看本地通知时,它确实会显示,但没有声音。我尝试禁用和启用“播放用户界面声音..”在mac设置中,关闭并重新打开xcode,清理项目,最后重新启动mac。什么都没用..我遗漏了什么?
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"Entered Region - %@", region.identifier);
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setAlertBody:@"You are about to enter.."];
[localNotification setSoundName:@"Voicemail.caf"];
UIApplication *application = [UIApplication sharedApplication];
[application presentLocalNotificationNow:localNotification];
}发布于 2013-12-03 14:53:05
在这里你可以传递你的声音文件名
UILocalNotification *notifThreshold = [[UILocalNotification alloc]init];
if(notifThreshold)
{
notifThreshold.alertBody = statusMsg;
notifThreshold.alertAction= @"Open";
notifThreshold.userInfo = userInfo;
notifThreshold.soundName = UILocalNotificationDefaultSoundName;
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (state == UIApplicationStateBackground)
{
notifThreshold.applicationIconBadgeNumber = [[UIApplication sharedApplication]
applicationIconBadgeNumber]+1;
}
[[UIApplication sharedApplication] presentLocalNotificationNow:notifThreshold];
}发布于 2013-12-03 14:41:37
转到构建阶段并将您的.caf文件添加到Copy Bundle Resources。它帮助了我
发布于 2013-12-03 15:10:06
请确保您的应用程序在通知中心的声音是启用的,而不是使用上限扩展名,尝试使用wav扩展名,例如"beep.wav“或"Default.wav”...
https://stackoverflow.com/questions/15952461
复制相似问题