Vibration in Monaca



  • Hello

    I have been struggling with monaca trying to get my phone vibrate but it doesnt seems to work.
    Even the HelloWorld example doesnt vibrate and I have checked all.

    The phone I am using is a Samsung S4 that actually vibrates with normal JavaScript code:

    navigator.vibrate(1000);
    

    but when I try it in a Monaca App, it doesn’t work.

    Someone knows what I am doing wrong? Thank you



  • @Racafe I just tested this and it worked on a Samsung Galaxy S6.

    <script>
            window.fn = {};
            
            window.fn.vibrate = function() {
                navigator.vibrate([1000]);
            };
        </script>
    
    <ons-page>
        <ons-button onclick="fn.vibrate()">Vibrate</ons-button>
    </ons-page>
    

    Maybe try using brackets around your time.



  • Your solution works!!! Thank you!!