Skip to content Skip to sidebar Skip to footer

How To Do Turn Off Vibration In Ionic 2 App

I have tried using plugin @ionic-native/vibration and tried three ways navigator.vibrate(0); (window).vibration.vibrate(0); And import { Vibration } from '@i

Solution 1:

To my knowledge there's currently no way to completely turn off vibrations that would be sent by some other component than your App.

However, there might be a trick to disable some vibrations given certain circumstances, using vibrate(0) as you did. The documentation on vibrate reads

[...] Pass 0 to stop any vibration immediately.

So you can't completely shut down incoming vibrations, but you can cancel any current vibration. So if for example you want to cancel the vibration of a notification you send, you can call vibrate(0) just as it arrives.

It is a poor workaround as you'll probably need to call it multiple times to cancel the vibration (to be sure you call this after the vibration started), but I think it's the only solution approaching what you're trying to achieve using only Ionic.

Or you could also periodically and very often call vibrate(0) to cancel any incoming vibration but it would not recommand this because to be effective the delay would have to be super short, which is probably a bad idea for performance reasons. I'm merely saying this as an emergency solution.

Post a Comment for "How To Do Turn Off Vibration In Ionic 2 App"