How to make iPhone vibrate using Swift?

Short example: import UIKit import AudioToolbox class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) } } load onto your phone and it will vibrate. You can put it in a function or IBAction as you wish. Code Update: AudioServicesPlayAlertSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate)) { } As apple code docs written: This function will be deprecated in a … Read more

Are there APIs for custom vibrations in iOS?

After serval hours’ digging in the Contact App, I have figured out how it works. ABNewPersonViewControlle invoke some class in ToneLibrary framework to do this. The call stack looks like this: 0 CoreFoundation 0x3359a1d4 CFGetTypeID + 0 1 CoreFoundation 0x33596396 __CFPropertyListIsValidAux + 46 2 CoreFoundation 0x33517090 CFPropertyListCreateData + 124 3 AudioToolbox 0x38ac255a AudioServicesPlaySystemSoundWithVibration + 158 … Read more

Making the iPhone vibrate

From “iPhone Tutorial: Better way to check capabilities of iOS devices“: There are two seemingly similar functions that take a parameter kSystemSoundID_Vibrate: 1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); Both of the functions vibrate the iPhone. But, when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function, on … Read more

How to make an Android device vibrate? with different frequency?

Try: import android.os.Vibrator; … Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); } else { //deprecated in API 26 v.vibrate(500); } Note: Don’t forget to include permission in AndroidManifest.xml file: <uses-permission android:name=”android.permission.VIBRATE”/>