1

I am using below code for play system sound in iOS, It is working perfect when iPhone is not in silent mode. But when i put iPhone in silent mode system sound is not play

NSError *activationErr  = nil;
NSError *_error  = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error];
[[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(systemSoundID);

Please help me out

Monish
  • 622
  • 9
  • 18
  • seems like you answered your own question! – JAB Oct 26 '16 at 06:20
  • Sorry sir, I am not getting you – Monish Oct 26 '16 at 06:21
  • Why would you expect a system sound to play while the phone is muted? – Avi Oct 26 '16 at 06:32
  • I have certain functionality required same. – Monish Oct 26 '16 at 06:35
  • Then use an API that can play sound while the device is muted. You'll need to switch the audio category. – Avi Oct 26 '16 at 06:58
  • I guess - this is restricted by iOS , it will restrict all the tones in silent mode. – Mrunal Oct 26 '16 at 07:05
  • @Mrunal : I have checked in one app. It will work perfect. So this is not restricted by iOS – Monish Oct 26 '16 at 07:18
  • Hope this helps: http://stackoverflow.com/questions/3740528/play-sound-on-iphone-even-in-silent-mode http://stackoverflow.com/questions/10322040/how-to-play-a-sound-using-avaudioplayer-when-in-silent-mode-in-iphone – Mrunal Oct 26 '16 at 08:48
  • @Mrunal : thanks bro, but i have tried this solution also. It is not working for me. i am debugging in iOS 10.0.2 – Monish Oct 26 '16 at 09:02

0 Answers0