Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS SDK :: vibration & plays a beep sound.

I need to vibrate iOS device, devices that don’t support vibration, Will plays a beep sound.

For this I am using

Import AudioToolbox.framework
#import <AudioToolbox/AudioToolbox.h>

AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

It vibrate on iPhone device, but No sound on iPad and iPod. While refrences say that it will play sound. What I am doing wrong ?

Making the iPhone vibrate

http://blog.mugunthkumar.com/coding/iphone-tutorial-better-way-to-check-capabilities-of-ios-devices/

like image 964
Mangesh Avatar asked Jul 08 '14 10:07

Mangesh


People also ask

How do I make IOS vibrate?

Go to Settings > Sounds & Haptics or Settings > Sounds. Select an option (like Ringtone or New Mail) under Sounds and Haptic Patterns or Sounds and Vibration Patterns. Tap Vibration, then tap Create New Vibration.

Does IOS have keyboard vibration?

Turn iPhone keyboard vibration on or off Open the Settings app. Go to Sounds & Haptics > Keyboard Feedback. Turn Haptic on or off.

Can iPhone vibration be adjusted?

If you have a sensitivity or intolerance to vibrations, you can customize iPhone to suit your needs. Set vibration options for specific alerts: Go to Settings > Sounds & Haptics. See Change iPhone sounds and vibrations. Turn off all vibrations: Go to Settings > Accessibility > Touch, then turn off Vibration.


1 Answers

Try setting the AudioSession:

#import <AudioToolbox/AudioToolbox.h>

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;         
[audioSession setCategory: AVAudioSessionCategoryPlayback  error:&err];
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);         
//or: AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
like image 199
lukaswelte Avatar answered Sep 16 '22 19:09

lukaswelte