6

How can I manually trigger a single click-like vibration like the ones that happen when using peek&pop, or application shortcuts?

vrwim
  • 13,020
  • 13
  • 63
  • 118
  • http://stackoverflow.com/questions/4724980/making-the-iphone-vibrate – Lefteris Oct 29 '15 at 22:29
  • 1
    @Lefteris that question is about vibration in general, I am talking about the short vibration (it feels like a click) when peek and pop activate. – vrwim Oct 29 '15 at 22:42

2 Answers2

24

This method is easy to implement and it works really well (I tried it myself)

import AudioToolbox

AudioServicesPlaySystemSound(1519) // Peek feedback
AudioServicesPlaySystemSound(1520) // Pop feedback
AudioServicesPlaySystemSound(1521) // Three pulses feedback

I hope this helps! :)

Matt Panzer
  • 1,141
  • 10
  • 7
  • This doesn't work on iOS 7.1.2, but similar something vaguely similar can be achieved with vibration codes 1011 and 1311 as per [this wiki](http://iphonedevwiki.net/index.php/AudioServices). – meepzh Jun 23 '16 at 20:27
1

It seems that these guys have found a way to do it for iOS 9 for phones with Taptic Engine (including the iPhone 6S). http://unifiedsense.com/development/using-taptic-engine-on-ios.html I'm not sure if it applies to iOS 8 or any other phones. They've essentially retrieved the Taptic Engine interface from UIDevice and called actuateFeedback with an integer corresponding to Peek or Pop.

Unfortunately these apps would likely be rejected by the App Store, if that's your intention.

meepzh
  • 707
  • 1
  • 7
  • 15