The problem encountered in the project is that the sound is vibrating while the music is over and the vibration is over.
First, you need to introduce #import <AVFoundation/AVFoundation.h> header files,
Add a place where you need to play music:
Audioservicesaddsystemsoundcompletion (ksystemsoundid_vibrate, NULL, NULL, systemaudiocallback, NULL);
Audioservicesplaysystemsound (ksystemsoundid_vibrate);
Explanation: Theksystemsoundid_vibrate provides the system with the vibration ID.
Systemaudiocallback is the callback function, and the callback is done after each shake.
void Systemaudiocallback ()
{
Audioservicesplaysystemsound (ksystemsoundid_vibrate);
}
Note: The callback function always makes its call vibrate.
Then call it where it stops playing:
Audioservicesremovesystemsoundcompletion (ksystemsoundid_vibrate);
Removing vibrations.
Ok! Done!
IOS Call system Loop vibrate