Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda