I am currently working on developing a Chrome Cordova App, and while all the Chrome App APIs are functioning well, I am facing some challenges with more advanced features like capturing images or accessing accelerometer data.
Despite my app running smoothly, I have encountered an issue where navigator appears to be undefined.
Below is a snippet of the code in question which attempts to retrieve accelerometer data:
$scope.picture = function(){navigator.accelerometer.getCurrentAcceleration( function (acceleration) {
alert('Acceleration X: ' + acceleration.x + '\n' +
'Acceleration Y: ' + acceleration.y + '\n' +
'Acceleration Z: ' + acceleration.z + '\n' +
'Timestamp: ' + acceleration.timestamp + '\n');
},function () {}); }
});
Here's a glimpse of the pertinent logcat details:
D/CordovaLog(17498): chrome-extension://klfmkipmoapfodoemajgpobgjngbdejp/angular
.min.js: Line 86 : TypeError: Cannot call method 'getCurrentAcceleration' of und
efined
D/CordovaLog(17498): at h.$scope.picture (chrome-extension://klfmkipmoapfodo
emajgpobgjngbdejp/controllers.js:31:53)
D/CordovaLog(17498): at chrome-extension://klfmkipmoapfodoemajgpobgjngbdejp/
angular.min.js:166:92
D/CordovaLog(17498): at chrome-extension://klfmkipmoapfodoemajgpobgjngbdejp/
angular.min.js:183:83
...
I am aware that eventually, using a Shim will be necessary as navigator functionality only applies to mobile devices. For now, I am focused on resolving the issues for mobile use cases.