Accelerometer Package


#1

What’s the package for using Accelerometer in Meteor application?


#2

For Cordova this one seems the most recent? https://github.com/apache/cordova-plugin-device-motion What exactly have you tried? There is no Meteor package yet available but Meteor can just use the Corova packages or you can create a wrapper for it.


#3

Thanks lucfranken, i have added it using meteor add cordova:cordova-plugin-device-motion@1.1.1 but i am still unable to use device accelerometer, i want to count the user steps using the device accelerometer.

Any help will be appreciated.

Thank you.


#4

What are your results from debugging? Do the objects get initiated?


#5

No, when i am running the code given below i get the following error

 Uncaught TypeError: Cannot read property 'getCurrentAcceleration' of undefined

code

Meteor.startup(function(){
	navigator.accelerometer.getCurrentAcceleration(
      onSuccess, onError);
});

     
function onSuccess(acceleration) {
	
  var accElement = 
    document.getElementById('count');
    
  accElement.innerHTML  =  
    'Acceleration X: ' + acceleration.x + '<br />' +
    'Acceleration Y: ' + acceleration.y + '<br />' +
    'Acceleration Z: ' + acceleration.z + '<br />' +
    'Timestamp: '      + acceleration.timestamp;
}
function onError(error) {
  // Handle any errors we may face
  alert('error');
}

#6

Resolved :smile: you can use meteor shake:shake package for accelerometer.