我正在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;
// …
Run Code Online (Sandbox Code Playgroud)