Device Orientation
Requires Cordova plugin:
cordova-plugin-device-orientation. For more info, please see the
Device Orientation docs.
Cordovaの問題で困っていますか?
本格的なプロジェクトを構築している場合、トラブルシューティングに時間を費やす余裕はありません。Ionicのエキスパートが、保守、サポート、統合に関する公式サポートを提供しています。
インストール
Ionic Native Enterprise はIonic Teamが完全にサポートしメンテナンスしているプラグインを利用できます。 詳しくみる か、 エンタープライズプラグインに興味があれば 連絡ください
サポートしているプラットフォーム
- Amazon Fire OS
- Android
- BlackBerry 10
- Browser
- Firefox OS
- iOS
- Tizen
- Ubuntu
- Windows
- Windows Phone
利用方法
React
Angular
// DeviceOrientationCompassHeading is an interface for compass
import { DeviceOrientation, DeviceOrientationCompassHeading } from '@ionic-native/device-orientation/ngx';
constructor(private deviceOrientation: DeviceOrientation) { }
...
// Get the device current compass heading
this.deviceOrientation.getCurrentHeading().then(
(data: DeviceOrientationCompassHeading) => console.log(data),
(error: any) => console.log(error)
);
// Watch the device compass heading change
var subscription = this.deviceOrientation.watchHeading().subscribe(
(data: DeviceOrientationCompassHeading) => console.log(data)
);
// Stop watching heading change
subscription.unsubscribe();

