首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UILocalNotification声音

UILocalNotification声音
EN

Stack Overflow用户
提问于 2013-04-11 23:13:04
回答 3查看 659关注 0票数 0

当用户通过地理围栏进入一个区域时,我会触发一个本地通知。但是,当我按下主页按钮查看本地通知时,它确实会显示,但没有声音。我尝试禁用和启用“播放用户界面声音..”在mac设置中,关闭并重新打开xcode,清理项目,最后重新启动mac。什么都没用..我遗漏了什么?

代码语言:javascript
复制
- (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];
}
EN

回答 3

Stack Overflow用户

发布于 2013-12-03 14:53:05

在这里你可以传递你的声音文件名

代码语言:javascript
复制
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];
    }
票数 1
EN

Stack Overflow用户

发布于 2013-12-03 14:41:37

转到构建阶段并将您的.caf文件添加到Copy Bundle Resources。它帮助了我

票数 0
EN

Stack Overflow用户

发布于 2013-12-03 15:10:06

请确保您的应用程序在通知中心的声音是启用的,而不是使用上限扩展名,尝试使用wav扩展名,例如"beep.wav“或"Default.wav”...

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15952461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档