2014-06-10 82 views
0

我有一個問題與我的應用程序,當收到警報本地通知聲音不玩iPhone 4s(iOS 7)(手機被鎖定)但在工作iPod ios 6.1.6)iPhone 5(iOS 8)。我用下面的代碼..本地通知聲音沒有在iPhone 4S與iOS7中玩

// Schedule the notification 

UILocalNotification* localNotification = [[UILocalNotification alloc]init]; 
localNotification.fireDate = itemDate; 
NSLog(@"%@",index); 
if (appDelegate().check == 0) { 
    [self repetationType:index Notification:localNotification]; 
} 

//setting repetation type 
//UILocalNotificationDefaultSoundName 

[email protected]"Message Alert - Happy.wav"; 
NSString *str=[NSString stringWithString:NSLocalizedString(@"youhave", nil)]; 

localNotification.alertBody=[NSString stringWithFormat:@"%@ %@",str,reminName];//remindtext; 
NSLog(@"%@",localNotification.alertBody); 
localNotification.alertAction = NSLocalizedString(@"item", nil); 
localNotification.timeZone = [NSTimeZone defaultTimeZone]; 
// localNotification.applicationIconBadgeNumber=[[UIApplication sharedApplication]applicationIconBadgeNumber]+1; 
localNotification.applicationIconBadgeNumber=1; 

NSString *alarm=[[NSString alloc]initWithFormat:@"%@",reminName]; 
// NSDictionary *userDict=[NSDictionary dictionaryWithObjectsAndKeys:image,@"info",nil]; 
NSDictionary *userDict = [NSDictionary dictionaryWithObject:alarm forKey:@"info"]; 
NSLog(@"userDict=%@",userDict); 
localNotification.userInfo=userDict; 

[[UIApplication sharedApplication]scheduleLocalNotification:localNotification]; 

回答

0

我想你忘了在你的代碼

 [localNotification setSoundName:UILocalNotificationDefaultSoundName] 
+0

keyur我添加自定義sound..like localNotification.soundName = @ 「消息提示 - Happy.wav」; – Rahul

+0

@ user3725874確保聲音確實存在於您的應用程序包中,格式正確(線性PCM或IMA4-幾乎任何地方,說明如何爲iOS轉換聲音會告訴您如何做到這一點),並且在30秒內。 – kb920

+0

是的,我添加在應用程序的包中的文件,它是播放的iPod和iPhone 5,但不能在iphone 4s播放 – Rahul

0

加入這一行。如果您的通知在其他iOS設備運行良好,那麼它也應該工作在4S。

通知音不會因設備或操作系統版本而異。所以問題在於設備設置。

確保您啓用了通知聲音在設備設置

enter image description here