Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increasing reports of compass not working on some android devices #64

Open
chrisgeorge0911 opened this issue May 22, 2021 · 10 comments
Open

Comments

@chrisgeorge0911
Copy link

Bug Report

Problem

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

What does actually happen?

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.

Information

Using plugin v2.01 - Cordova 9.0

Checklist

  • [ X] I searched for existing GitHub issues
  • [X ] I updated all Cordova tooling to most recent version
  • [X ] I included all the necessary information above
@alexbainbridge
Copy link

What did you do in the end @chrisgeorge0911 ? We are using this plugin and struggling to get compass on android on devices are are sure have the right sensors.

I think we may end up using this plugin for iOS (as is native, so no permission request issues) and W3C or similar (like Capacitor Motion) for Android.

@chrisgeorge0911
Copy link
Author

I haven't done anything yet... the numbers reporting the issue are still fairly small (I have more iOS customers than android at the moment)... but I fear it's only going to get worse. The problem I've found with W3C is that it's not oriented around North, so no good for a compass (or at least I could not get this to work).

@HarelM
Copy link

HarelM commented Oct 23, 2021

I've just got my first report from an android device:
Manufacture: OnePlus
Model: HD1913
Platform: Android
OS version: 11
I see an error in the log, but I get Error: [object Object], probably due to bad formatting of the error on my part.
I can't use W3C due to iOS "localhost" issue and all other kind of bugs and quirks.
If anyone finds the problem before I do please let me know, I'll see to what extent the user who's facing this issue will go.

@chrisgeorge0911
Copy link
Author

Another report of this
Nokia 8.3
Android 11

@mgurzixo
Copy link

FYI, I did a fork and modified the plugin for using magnetometer and accelerometer. Now it works everywhere.
It is available here.

I don´t know how to create a PR.

Enjoy!

@HarelM
Copy link

HarelM commented Aug 28, 2022

Opening a PR is very easy - all you need to do is click contribute --> open pull request:
Write some notes on what you did and what it solves and click create or submit, I don't remember.
but @mgurzixo how do you know that this solves this issue?
image

@mgurzixo
Copy link

@HarelM : I added an update explaining the patch. In fact, I rewrote src/android/CompassListener.java.

Thanks for the info about PRs. I will try to create one ;)

@alexbainbridge
Copy link

Thank you @mgurzixo for your work on this - just what we need so can remove some of our Android only hacks in our apps! I see you closed the PR - shouldn't it be left open for the maintainers to accept now you have submitted your updates?

@breautek
Copy link

I see you closed the PR - shouldn't it be left open for the maintainers to accept now you have submitted your updates

I've reopened the PR so that it doesn't get lost.

@lahirudx
Copy link

FYI, I did a fork and modified the plugin for using magnetometer and accelerometer. Now it works everywhere. It is available here.

I don´t know how to create a PR.

Enjoy!

Hi @mgurzixo,
I just added your plugin to my project. But it's not working in Androids. Works for iOS.

Tested on Galaxy Note 22, 23.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants