Custom vibration in iOS 8 - Swift

余生长醉 提交于 2020-02-23 09:37:07

问题


I'm writing a sprite kit-based app in swift and need to make a short haptic feedback using vibration

so first I imported AudioToolbox and used this

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

and it worked well but it vibrates for too long and there's no way to control this duration.

Then after some searching I read Kevin Cao's answer here:

Are there APIs for custom vibrations in iOS?

but unfortunately AudioServicesPlaySystemSoundWithVibration private function was only usable in iOS 6.

so is there any other possible way?


回答1:


You need AudioServicesPlaySystemSoundWithVibration API. But unfortunately it's private and you can not publish your app :(

Check this blog post and this answer



来源:https://stackoverflow.com/questions/30268232/custom-vibration-in-ios-8-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!