Vibrations and alert not working in iOS - 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.

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

iPads don't have a support physical vibration.
You can use these codes only in iPhones and newer versions of iPods.

Related

App Interruption - Siri Fails To Hear Human Voice

In my team's iOS app we have a bug when Siri is invoked while our app is running. Siri pops up and the waveform is shown very briefly and appears not to detect one's voice as the waveform remains very flat. Quickly thereafter it begins to list the things you can ask Siri.
We are using Xcode 6.3, tested on an iPad Mini with iOS 8.3 as well as an iPhone 5 with iOS 8.3.
The app never uses the microphone or queries any of the device audio inputs so I can't see this problem attributed to our app using the microphone directly. It does play looping ambient music and has sound effects.
Is there anything specific we should be calling an an interruption to ensure that Siri will work properly? Has anyone experienced similar issues?
This is most likely not related to your app. The iOS SDK doesn't provide a Siri API that could lead to this kind of events.
You may try to pause any ambient music/sounds effects whenever the app goes in background. (in AppDelegate.m)

Playing sound from Apple Watch through iPhone

I'm trying to incorporate sound effects into an Apple Watch application I've been working on (written in Objective-C), but I was disappointed by the fact that third party applications are not permitted to play sounds directly from the watch. As a workaround, I was looking to see if there was a way to play a specified sound through the paired device's speakers. I found one such thread here:
Play sound from Apple Watch speaker
however the link in the verified answer seems to be down at this time. In short, how can I play a sound effect triggered by the Apple Watch through its paired iPhone's speakers? Also, is it possible to make the device vibrate from the watch? Any help is greatly appreciated.
Unfortunately, AppleWatch doesn't allow developers to play or to record audio. You can play sound from iPhone speaker, as the simulator does. If you implement AVAudioPlayer on you WatchKit extension, you are going to listen in your Mac because the iPhone simulator is playing for you.
Taken from Apple Developer Forum:
Since the code simplegames showed is running on the iPhone simulator, not the watch simulator, and the button press on the watch simulator is causing the iPhone simulator code to activate the audio player, your mac is simulating sound from the iPhone.
No. It is not possible to play sounds with WatchKit on the Apple Watch.
I got the watch to play audio like this. It does however present the media player. Its not ideal but it works.
#import <Foundation/Foundation.h>
NSURL *yourURL = [myBundle URLForResource:#"yourAudioFile" withExtension:#"wav"];
NSDictionary *options = #{WKMediaPlayerControllerOptionsAutoplayKey : #YES};
[self presentMediaPlayerControllerWithURL:yourURL options:options completion:^(BOOL didPlayToEnd, NSTimeInterval endTime, NSError * __nullable error) {if (error)NSLog(#"Error: %#", [error description]);}];

IOS app - bluetooth audio enabling

I'm working on an IOS 6 app that's currently in development. The app has about 5-6 snippets of audio that play at various stages, currently when the device is paired with some bluetooth speakers (e.g. in a car) the audio does not play through the speakers.
Does anyone know what's involved with making this app work with paired bluetooth speakers? My initial assumption was that it wouldn't need anything extra done, it would just work. I had thought bluetooth paired speakers worked like as if you'd plugged in speakers directly into the device, all audio was routed through the speakers as long as they were paired.
This doesn't appear to be the case though.
I think you have to place an MPVolumeView somewhere in your interface, and enable the showsRouteButton property, then users can use that button to change the audio route to Bluetooth. You can also disable the showsVolumeSlider property if you don't need the volume slider.

Music plays when volume turn off

I have next issue:
I use AudioServicesPlaySystemSound to play short sound in my app. But something happens wrong: when I turn off volume on the device - sound still playing.
I found this issue on devices with iOS 6.0 and greater. On iOS 5 device all right.
Can anybody point me what I do wrong?
Thanks.

iOS Simulator Sound

Is there a way to tell the iOS simulator which audio device connected to your computer you want it to use?
The simulator seems to pick whatever audio device is last connected to your machine. I've got a USB audio device (fasttrack pro) I use for my main sound playback and then a USB headset I use for my skype calls. More often than not, the simulator's audio is played on the headset instead of my main speakers.
Ok, I found that both the input and output device much match in system sound settings. Often I have them set to different devices. If they don't match, the simulator seems to default to the last connected audio device selected among the input and output devices.
On a related note: if you're like me and don't like interface sounds and therefore uncheck the preference "Play user interface sound effects" (Sound > Sound Effects), you'll need to check it to get sound out of the simulator.
I doubt the simulator has a setting for that, but you can set the main output device in System Preferences > Sound.
Don't know if this will fix your issue, but it fixed mine.
I wanted the iOS simulator to output sound through a device I had connected and not the internal speakers. When I select the System Prefs Sound and selected my device as output, it would not work.
So, I selected the Sound Effects tab from the Prefs - Sound window and selected my device under Play Sound effects Through and presto it worked.
Don't know the in-outs of iphone sound, but apparently mine were being treated as sound effects.
Hope that helps, if not, I gave it a shot.
Open iOS Simulator, under Hardware toolbar you can control Audio Input, Audio Output, and volume as well!
I think it was added at Xcode 9.2, and that it's available only when running simulator with iOS 11 and above
func vibratePhone() {
if (UIDevice.current.model == "iPhone") {
AudioServicesPlaySystemSound(1352)
} else {
AudioServicesPlayAlertSound(1105)
}
}
1352 Is the system sound ID for Vibration and 1105 is for Tock.caf if the user's device is an iPad or an iPod Tock.caf will be played in place of vibration.
Working on an audio project on my studio and still didn't got it working on MOTU Hardware with everything pointing to the interface! All system sounds route properly except the iOS Sim!
Did this workaround:
iOS Sim/OS X -> SoundFlower virtual I/O -> (Any audio program like Logic/Live) -> MOTU HW
This might give you the freedom to route your audio as you please ;)

Resources