I have an ionic capacitor android app and I would like to record orientation and acceleration of the device, but after adding event listeners, they are not triggering.
Code:
import { Motion } from '@capacitor/motion';
export default class MotionService {
async startRecording() {
try {
await DeviceMotionEvent.requestPermission();
} catch (e) {
console.error(e);
}
Motion.addListener('accel', event => {
console.log('Device motion event:', event);
});
}}
package.json:
"dependencies": {
"@capacitor/android": "^3.1.1",
"@capacitor/app": "^1.0.2",
"@capacitor/core": "3.1.1",
"@capacitor/filesystem": "^1.0.2",
"@capacitor/haptics": "^1.0.2",
"@capacitor/keyboard": "^1.0.2",
"@capacitor/motion": "^1.0.2",
"@capacitor/status-bar": "^1.0.2",
"@ionic/vue": "^5.4.0",
"@ionic/vue-router": "^5.4.0",
"chart.js": "^3.4.1",
"core-js": "^3.6.5",
"vue": "^3.0.0-0",
"vue-router": "^4.0.0-0"
},
I am trying to test it by running: "ionic capacitor run android -l --host=MY_IP", emulator device is Pixel 3 API 30, then open chrome://inspect/#devices -> inspect to see console.logs and trying to change values in the option window of emulator:
But I don't see any logs. I would appreciate some help :)