write a function that causes the phone to vibrate immediately in swift

Here's an example of a function that causes the phone to vibrate immediately in Swift:

main.swift
import UIKit
import AudioToolbox

func vibratePhone() {
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
115 chars
7 lines

To use this function, you can simply call vibratePhone() wherever you want to trigger the vibration.

Note that this function uses the AudioToolbox framework to play the system vibration sound.

gistlibby LogSnag