Jay*_*tra 16 iphone audio ios uilocalnotification ios7
我正在UILocalNotification
申请中使用.
在应用程序中有两种声音有条件地播放 - 我已经为它们应用了适当的条件.
但是当我安装应用程序并在iOS 7
设备上运行它时,它会触发本地通知,但声音不会在应用程序中播放.
下面给出了代码来设置通知:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
if (localNotification == nil)
return;
localNotification.fireDate = [pickerView date];
localNotification.timeZone = [NSTimeZone defaultTimeZone];
if (alarm_number == 1) {
localNotification.alertBody = [NSString stringWithFormat:@"First Alarm"];
}
else
{
localNotification.alertBody = [NSString stringWithFormat:@"Second Alarm"];
}
localNotification.alertAction =@"Ok";
NSString *message = [[NSString alloc]initWithString:@""];
if(alarm_number == 1)
{
localNotification.soundName=@"Alarm_1.mp3";
message = @"First Alarm Scheduled";
}
else
{
localNotification.soundName=@"Alarm_2.mp3";
message = @"Second Alarm Scheduled";
}
localNotification.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSString *alarmString;
if (alarm_number==1) {
alarmString = [NSString stringWithFormat:@"First Alarm"];
}
else
{
alarmString = [NSString stringWithFormat:@"Second Alarm"];
}
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:alarmString forKey:@"AlarmFor"];
localNotification.userInfo = infoDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
Run Code Online (Sandbox Code Playgroud)
我检查过的是我的应用程序的设置/通知中心应用程序中的声音设置.
请查看第1张到第3张图片以查看我查看过的内容.
(1)通知中心
(2)申请
(3)声音在这里关闭
因此,为了启用此功能,我已在应用程序的目标功能中检查了Inter App Audio,它已关闭,如下图所示.
应用间音频的功能
然后我将其更改为On,它看起来如下图所示.
然而,它仍然没有在iOS 7设备中播放任何声音.
有没有人知道它为什么不起作用?这将是一个很大的帮助.
谢谢.
归档时间: |
|
查看次数: |
12402 次 |
最近记录: |