Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
detect shake event on iphone

I'm trying to detect a shake event on iPhone. shake.js library is not working, would appreciate any help or other solutions. I've also tried this but no luck.

function ClickRequestDeviceMotionEvent () {
window.DeviceMotionEvent.requestPermission()
.then(response => {
  if (response === 'granted') {
    window.addEventListener('devicemotion',
      () => { 
          //alert('DeviceMotion permissions granted.'); 
          
          var o = 0.6; // 0
          var myShakeEvent = new Shake ({
            threshold: 10, // 15. optional shake strength threshold
            timeout: 1000 // optional, determines the frequency of event generation
          });
          
          myShakeEvent.start(); // mobile, no ipad

          window.addEventListener('shake', shakeEventDidOccur, false);
          
          function shakeEventDidOccur() { // function to call when shake occurs
            alert('shake!');
          } 
      },
      (e) => { throw e }
  )} else {
    alert('DeviceMotion permissions not granted.')
  }
})
.catch(e => {
  alert(e)
})

}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

By the looks of it, this isn't possible anymore.

Shake.js was discontinued so is not supported.

Also, Safari does not support the Accelerometer, Gyroscope or the DeviceMotionEvent web API's, so this data is just not available for your code to react to.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!