I'm trying to get my iPhone to vibrate while I'm recording.
I've tried this:
UInt32 category = kAudioSessionCategory_PlayAndRecord; 
status |= AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);
UInt32 allowMixing = true;
status |= AudioSessionSetProperty (
      kAudioSessionProperty_OverrideCategoryMixWithOthers,  // 1
      sizeof (allowMixing),                                 // 2
      &allowMixing                                          // 3
       );
status |= AudioSessionSetProperty(
      kAudioSessionProperty_OtherMixableAudioShouldDuck, // 1
      sizeof (allowMixing),        // 2
      &allowMixing          // 3
       );
As suggested here. Then vibrate the device later on by calling
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
But it does not work. But it does not vibrate. It records fine, and if I call a vibrate moments before I stop recording it vibrates after stop it.
Apparently it's a bug, does anyone know of a work around?
AT LAST! As of iOS 13, there is a new property on AVAudioSession
        let _ = try? AVAudioSession.sharedInstance().setCategory(.playAndRecord)
        if #available(iOS 13.0, *) {
            let _ = try? AVAudioSession.sharedInstance().setAllowHapticsAndSystemSoundsDuringRecording(true)
        }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With