@greenie2600 wrote:
Title says it all. I’m successfully injecting
Gyroscope
into my page component, and I’m subscribing tothis.gyroscope.getCurrent()
andthis.gyroscope.watch()
without errors – but the subscriptions never detect any events.The emulator has a screen for adjusting the orientation of the virtual device, complete with a fancy 3D representation of the phone – so I would expect this to work.
My code:
import { Component } from '@angular/core'; import { Subscription } from 'rxjs/Subscription'; import { Gyroscope, GyroscopeOrientation } from '@ionic-native/gyroscope'; @Component({ templateUrl: 'hardware-integration-sensors.html' }) export class HardwareIntegrationSensorsPage { private gyroscope_subscription: Subscription; constructor( private gyroscope: Gyroscope ) {} ionViewWillEnter(): void { console.log('subscribing to gyroscope stuff'); this.gyroscope.getCurrent().then((orientation: GyroscopeOrientation) => { console.log('gyroscope.getCurrent() fired', orientation); // this never happens }); this.gyroscope_subscription = this.gyroscope.watch().subscribe((orientation: GyroscopeOrientation) => { console.log('gyroscope.watch() fired', orientation); // this never happens }); } ionViewWillLeave(): void { this.gyroscope_subscription.unsubscribe(); } }
Posts: 1
Participants: 1