hi
its seems i got into a big wall here really dont know what going on and i hope some would help me
am trying to use ionic native Device Orientation plugin to get magnatic heading for the device compass since am just trying to create a compass app
now i followed the steps in the doc
so i imported the cordova plugin then imported the ionic native
the i declard this in my app.module.ts
import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
import { DeviceOrientation, DeviceOrientationCompassHeading } from '@ionic-native/device-orientation';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
providers: [
DeviceOrientation,
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
and this is my home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Platform } from 'ionic-angular';
import { DeviceOrientation, DeviceOrientationCompassHeading } from '@ionic-native/device-orientation';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
magneticHeading: any;
constructor(public navCtrl: NavController,private deviceOrientation: DeviceOrientation,private platform: Platform) {
this.magneticHeading = 0;
platform.ready().then(() => {
deviceOrientation.getCurrentHeading().then(
(data1: DeviceOrientationCompassHeading) => this.magneticHeading=data1.magneticHeading,
(error: any) => console.log(error+"err")
);
const options={frequency:100};
const subscription = deviceOrientation.watchHeading(options).subscribe(
(data3: DeviceOrientationCompassHeading) => this.magneticHeading=data3
,(error: any) => console.log(error+"errtt"));
subscription.unsubscribe();
});
}
}
}
and always the result in my console is [object object ] err which means it was cought in the first step
deviceOrientation.getCurrentHeading().then(
(data1: DeviceOrientationCompassHeading) => this.magneticHeading=data1.magneticHeading,
(error: any) => console.log(error+“err”)
);
and these are my system info
Ionic Framework: 3.0.1
Ionic Native: ^3.5.0
Ionic App Scripts: 1.3.0
Angular Core: 4.0.0
Angular Compiler CLI: 4.0.0
Node: 7.2.1
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
if some one really nows where am wrong they will be a real life saver
regards