I have this code.
import AudioToolbox.AudioServices
if restoreData.boolForKey("VibrationSwitchButton") == true {
vibra()
}
func vibra() {
if UIDevice.currentDevice().model == "iPhone" {
let systemSoundIDButton : SystemSoundID = 4095
AudioServicesPlayAlertSound(SystemSoundID(systemSoundIDButton))
// print("VIBRA")}
}
I have a UISwitch
that active and deactivate this path of code. The switch works correctly but if I activate the vibrate in the general option (sound), I can't deactivate from my setting and contrary too.
How can I generalize my configuration? if I have to vibrate on in general setting I can deactivate on my app.
Swift 2.0 and Xcode 7.1
Use AudioServicesPlaySystemSound
instead of AudioServicesPlayAlertSound
.
sample code:
if restoreData.boolForKey("VibrationSwitchButton") == true {
vibra()
} else {
soundOnly()
}
func soundOnly() {
if UIDevice.currentDevice().model == "iPhone" {
let systemSoundIDButton : SystemSoundID = 4095
AudioServicesPlaySystemSound(SystemSoundID(systemSoundIDButton))
// print("Sound Only")
}
}