apache / cordova-plugin-device-orientation Goto Github PK
View Code? Open in Web Editor NEWApache Cordova Device Orientation Plugin
Home Page: https://cordova.apache.org/
License: Apache License 2.0
Apache Cordova Device Orientation Plugin
Home Page: https://cordova.apache.org/
License: Apache License 2.0
When subscribing to a watchHeading
function, I get a CompassError {code: 3}
response. It works on older Android phones. I haven't tested iOS. If I browsed the code correctly. The error code is neither one of CompassError.COMPASS_INTERNAL_ERR CompassError.COMPASS_NOT_SUPPORTED
.
It should work.
I get an undocumented CompassError
.
It doesn't work on Android 10.
import { DeviceOrientation } from '@ionic-native/device-orientation/ngx';
constructor(
private deviceOrientation: DeviceOrientation
) { }
this.compass = this.deviceOrientation.watchHeading({frequency: 500}).subscribe(data => {
// logic
});
I used Angular 11, Ionic framework 5 and Capacitor.
ionic info
output:
Ionic:
Ionic CLI : 6.13.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.6.4
@angular-devkit/build-angular : 0.1102.8
@angular-devkit/schematics : 9.1.0
@angular/cli : 11.2.8
@ionic/angular-toolkit : 2.3.3
Capacitor:
Capacitor CLI : 2.4.7
@capacitor/core : 2.4.7
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : not available
Cordova Plugins : not available
Utility:
cordova-res (update available: 0.15.3) : 0.15.2
native-run (update available: 1.3.0) : 1.2.2
System:
Android SDK Tools : 26.1.1 (/Users/datigo/Library/Android/sdk)
ios-deploy : 1.10.0
ios-sim : ios-sim/9.0.0 darwin-x64 node-v12.18.3
NodeJS : v12.18.3 (/usr/local/Cellar/node@12/12.18.3/bin/node)
npm : 6.14.6
OS : macOS Catalina
Xcode : Xcode 12.4 Build version 12D4e
Cordova has depreciated the device-orientation plugin AND W3C does not intend to maintain the DeviceOrientation Event Specification?
With the W3C Device Orientation API now being supported on iOS, Android and Windows devices, this plugin is not needed any more.
Cordova links the above to a 2016 W3C standard which pops up
This version is outdated!
Redirecting to...
W3C
Beware. This specification is no longer in active maintenance and the Geolocation Working Group does not intend to maintain it further.
Hi, i've been using this plugin to get the absolute north point.
There is some problem with it. When using navigator.compass.getCurrentHeading(console.log);
If the phone is in portrait mode there is no problem...the value goes from 0 to 359.99
But when the phone is in landscape mode the values are totally wrong and not stable at all,
varying almost +/-20 degrees... Soo, how to get the right value?
Orientation | Degrees | Degrees |
----------------------------------
Portrait | 0 | 45 |
Landscape | 20 | 80 |
UpsideDown | 160 | 220 |
Landscape | 190 | 350 |
Since iOS 13, the WKWebView requires user permission when fetching DeviceOrientationEvent. When DeviceOrientationEvent.requestPermission() is called, a modal is shown that asks permission for "localhost". After app restart, the modal is shown again. Thinking of a mobile app, this is probably not the best user experience. With the device orientation plugin, this problems could be worked around, couldn't it?
Somewhat frustratingly, the device orientation event only gives orientation relative to the direction the device was pointing at the time of instantiation on IOS.
So at the moment I fail to see how this plugin can be deprecated until the full absolute compass heading functionality is available across all platforms.
Or have I got it wrong?
I know this plugin is now deprecated, but the last version of it was 2.0.1 - though it looks like someone was still doing a dev version 2.0.2.
My question is when it was deprecated, what were the version levels of cordova-ios and cordova-android (or cordova-cli) that this plugin was no longer needed?
My app is running significantly behind all the latest and greatest revs - so I need to determine that as of (example) [email protected] and [email protected] this plugin is not needed.
As well, if the plugin is no longer needed, where is the documentation on how to call the new integrated functions (previously used by this plugin) for device orientation functionality?
Hello,
I've read the blog and how we will proceed with W3C device orientation , but my question is how to calculate the values provided from cordova-plugin-device-orientation, for example there is a logic that i've had in my app related to the "headingAccuracy" which is not provided from the W3C device orientation, so how am i going to obtain the related props?
Different value in iOS and Android. iOS is correct
Same value for both
this.deviceOrientation.watchHeading().subscribe((res: DeviceOrientationCompassHeading) => {
console.log(res);
});
In iOS the value is
{
"headingAccuracy": 15.887619972229004,
"magneticHeading": 15.256682395935059,
"timestamp": 1653415919642.137,
"trueHeading": 15.116232872009277
}
and in Android
{
"magneticHeading": 165.015625,
"trueHeading": 165.015625,
"headingAccuracy": 0,
"timestamp": 1653416203062
}
Both handphone are flat on table side by side
Ionic Capacitor 3
Angular 13
Android 10
iOS 15.3.1
When calling getCurrentHeading on some ionic apps on Android devices freeze out in the field.
getCurrentHeading gets the heading at all times.
getCurrentHeading doesn't return a value any more. On some devices this is even causing a crash.
the issue is described here as well.
danielsogl/awesome-cordova-plugins#3537
--> PR will be added and linked to this issue as well.
this.deviceOrientation.getCurrentHeading().then((orientation: DeviceOrientationCompassHeading) =>
LogUtil.debug('device orientation: ', orientation));
.catch((error) => LogUtil.debug('Cannot get device orientation: ', error));
many different Android devices
"@angular-devkit/build-angular": "^16.1.4",
"@angular-devkit/core": "^16.1.4",
"@angular-devkit/schematics": "^16.1.4",
"@angular-eslint/builder": "^16.1.0",
"@angular/cli": "^16.1.4",
"@angular/compiler": "^16.1.5",
"@angular/compiler-cli": "^16.1.6",
"@angular/language-service": "^16.1.6",
"@capacitor/cli": "^5.2.2",
"@eama/egis-symbologies": "file:plugins/egis-symbologies",
"@ionic/cli": "^7.1.1",
"cordova-plugin-device-orientation": "^2.0.1",
I've had an app released for a few years using this plugin to provide magnetic heading data in order to orient a compass. Increasingly in the last year I've had customers report that the compass isn't working on a selection of android phones, all of which have magnetometer sensors.
Devices are:
Motorola Razr 5g
Sony Xperia 5 ii
Motorola G6
navigator.compass is returning false, implying that the compass sensor is not recognised.
Investigated switching to W3C orientation, but it does not give magnetic heading so is not fit for purpose. This plugin has been great for me.
Using plugin v2.01 - Cordova 9.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.