Problem with DeviceOrientation on IOS


#1

Hi,
I’ve got a problem that I don’t understand with ionic.

I wrote a small program like that:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { DeviceOrientation, DeviceOrientationCompassHeading } from '@ionic-native/device-orientation';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  heading:Number;
  constructor(public navCtrl: NavController, private deviceOrientation: DeviceOrientation) {
    // this.heading=100;
    // setInterval(function(){
    //   this.heading = this.heading+1;
    // }.bind(this), 1000)
    this.heading = 100;
    // Get the device current compass heading
    this.deviceOrientation.getCurrentHeading().then(
      (data: DeviceOrientationCompassHeading) => this.heading = data.trueHeading,
      (error: any) => console.log(error)
    );

    // Watch the device compass heading change
    var subscription = this.deviceOrientation.watchHeading().subscribe(
      (data: DeviceOrientationCompassHeading) => this.heading=data.trueHeading,
    );
  }

  

}

This app is working perfectly on Android but ios it gives me a blank page !

Does someone have a solution to this problem ?


#2

Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Safari dev tools: https://ionic.zone/debug/remote-debug-your-app#ios Look at the console and network tabs for errors.


#4

I tried and I see no error in the console…


#5

Problem is solved and I don’t know what i did