I have a simple meteor test app where I’m just trying to collect the accelerometer data from an android phone and display the values on the main page
Following the instructions for the device motion plugin (https://github.com/apache/cordova-plugin-device-motion) I have come up with the following:
<body>
<h1>GPS</h1>
{{> GPS}}
<h1>Accelerometer</h1>
{{> accelerometer}}
</body>
<template name="GPS">
<p>Latitude: {{latitude}}</p>
<p>Longitude: {{longitude}}</p>
</template>
<template name="accelerometer">
<p>X: {{getAcc}}</p>
<p>Y: {{getAcc}}</p>
<p>Z: {{getAcc}}</p>
</template>
and my js file:
if (Meteor.isClient) {
Template.GPS.helpers({
latitude: function () {
return Geolocation.latLng()['lat'];
},
longitude: function () {
return Geolocation.latLng()['lng'];
}
});
Template.accelerometer.helpers({
onSuccess: function(acceleration){
return "success";
},
onError: function(acceleration){
return "error";
},
getAcc: function(){
var options = { frequency: 1000 };
var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
return watchID;
}
})
}
Right now, I’m simply expecting the page to show “success” next to X, Y, and Z. In my mind getAcc
gets called, which in turns called onSuccess
which will return “success” to watchID
, which then gets printed to the page
The problem is neither “success” nor “error” display on the page and I’m not sure why. Did I implement the functions wrong?