简体   繁体   中英

programmatically silent/vibrate an iOS devise using swift2?

I'm a new developer and would like to know how to silent/vibrate an IOS device through code( swift2 ), I don't care if it requires a private API. Please help.

You'll need to import the System Sound Services

import AudioToolbox.AudioServices

Then you can play the vibration alert "sound"

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

More information can be found in the Apple docs: https://developer.apple.com/library/prerelease/ios/documentation/AudioToolbox/Reference/SystemSoundServicesReference/index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM