user124577
user124577

Reputation: 209

Vibrations and alert not working in iOS

so I'm running on my iPad Mini and my code looks like

-(void)viewDidLoad{
[super viewDidLoad]
AudioServicesPlaySystemSound(1005);
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 
}

and I imported

#import <AudioToolbox/AudioToolbox.h>
#import <AudioToolbox/AudioServices.h>

in my ViewController.h. Only the first sound plays, even though according to the documentation the second one should also beep. How can I fix this?

EDIT: To people looking at this, in older devices this would beep I think - the documentation says:

"Depending on the particular iOS device, this function plays a short sound and may invoke vibration. Calling this function does the following on various iOS devices:

iPhone—plays the specified sound. If the user has configured the Settings application for vibration on ring, also invokes vibration. However, the device does not vibrate if your app’s audio session is configured with the AVAudioSessionCategoryPlayAndRecord or AVAudioSessionCategoryRecord audio session category. This ensures that vibration doesn’t interfere with audio recording. For an explanation of audio session categories, see Categories Express Audio Roles.

iPod touch, original—plays a short alert melody.

iPod touch, 2nd generation and newer—plays the specified sound."

but I think that functionality has been removed.

Upvotes: 1

Views: 1517

Answers (2)

darshan
darshan

Reputation: 1115

iPads don't have a support physical vibration.

You can use these codes only in iPhones and newer versions of iPods.

Upvotes: 0

shpasta
shpasta

Reputation: 1933

There is no vibration on iPad. From documentation:

@constant       kSystemSoundID_Vibrate
Use this constant with the play sound APIs to vibrate the device
                    - iOS only 
                    - on a device with no vibration capability (like iPod Touch) 
                       this will do nothing

So AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); will do nothing on the iPad

Upvotes: 1

Related Questions