Press ESC to close

Swift Vibration

In some projects, you can enjoy the vibrations of the phone. With vibration, we can get the attention of the user, we can report something important. It may be that you lost the game while playing the game, or a message came from somewhere. We can use vibration to give news. In Swift we will have to write a framework and one line of code to shake the phone.

We are on the project we launched. We will add a framework to the Link Binary With Libraries section under Build Phases under Project properties. We will add the framework: AudioToolbox.framework.

After adding the framework, we need to go to my .swift file and import the Framewok we have added to this file. Once you have signed up, you can vibrate the phone with the code block below.

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

If you have any questions, you can reach us by email or comment.

Leave a Reply

Your email address will not be published. Required fields are marked *