IOS system sound does not play

I am trying to implement system sound playback in my application running on iOS 10.3.1. The problem I am experiencing is that when I am in viewDidLoad, when the application is being debugged, the sound is played. When an application runs fine, it always vibrates.

AudioServicesPlayAlertSoundWithCompletion(1107, nil); 

When I want to use the same system sound in a specific place in the application, the corresponding place that should play the sound, it does nothing, does not sound, and does not vibrate in debug mode or in a normal run.

I do not see any errors or warnings when starting the application. EDIT * Added code in which I use it:

 - (void)viewDidLoad { [super viewDidLoad]; AudioServicesPlayAlertSoundWithCompletion(1107, nil); //AudioServicesPlayAlertSoundWithCompletion(1100, nil); (same) } 

It always vibrates, it doesn't matter if the call is on or the phone is connected to the X-code or not.

This is imported from me, if it means something:

 #import <AVFoundation/AVFoundation.h> #import <CoreLocation/CoreLocation.h> #import "CoreLocationController.h" #import <AudioToolbox/AudioServices.h> 

Anyone can help?

+7
ios xcode
source share
2 answers

You can find interesting material in the AVFAudio Framework headers.

Categories

Headings

You should check out this post, I think it can help you.

How to play Alert Sound

 1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 

Both features vibrate the iPhone. But, when you use the first function on devices that do not support vibration, it plays a sound. The second function, on the other hand, does nothing on unsupported devices. Therefore, if you are going to constantly vibrate the device, as they say in common sense, use function 2.

+3
source share

There are two volume buttons (volume and volume). Next to the volume up button there is a toggle button (toggle button), which is actually a mute button.

0
source share

All Articles