gpt4 book ai didi

ios - UILocalNotification声音

转载 作者:行者123 更新时间:2023-11-29 04:00:15 24 4
gpt4 key购买 nike

当用户通过地理围栏进入某个区域时,我会触发本地通知。但是,当我按主页按钮查看正在运行的本地通知时,它确实会显示,但没有声音。我尝试在 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];
}

最佳答案

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

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

关于ios - UILocalNotification声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15952461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com