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

Change Motion API to use native heading/compass (i.e. "device orientation") #5327

Closed
arielhasidim opened this issue Dec 18, 2021 · 8 comments

Comments

@arielhasidim
Copy link

arielhasidim commented Dec 18, 2021

Feature Request

Description

As stated in the docs: "This plugin is currently implemented using Web APIs. Most browsers require permission before using this API". Unfortunately, since iOS 13+ the permission flow is very non-native and results in poor user experience. Native implementation will save the need for user interaction before asking for permission (one time only).

Hence, for better UX, Motion API should use native implemantation.

For more details and refrences see full discussion at cordova-plugin-device-orientation repo: "Should deprecation status be removed?"[Accepted] issue.

@thomasvidas
Copy link
Contributor

There is an open PR that fixes the permissions issue with the web implementation here: #5317

@arielhasidim
Copy link
Author

arielhasidim commented Dec 18, 2021

@thomasvidas Couldn't ask for more 😅
Sorry for missing this.

@thomasvidas
Copy link
Contributor

No worries! 😄

@jcesarmobile
Copy link
Member

In fact, we are considering using native code for the plugin as it seems that the web results are not as accurate as the native results
ionic-team/capacitor-plugins#718

@arielhasidim
Copy link
Author

In fact, we are considering using native code for the plugin as it seems that the web results are not as accurate as the native results
ionic-team/capacitor-plugins#718

I think the discussion in the mentioned issue on Cordova's plugin above is valuable here with the references + maybe the code itself can be used partially to create the native implementation (check my comment there). I use it for navigation feature in my app, and I prefer native implementation for better performance and permission flow which will result in better user experience overall.

@arielhasidim arielhasidim reopened this Dec 28, 2021
@arielhasidim
Copy link
Author

In the last week I experienced with Motion API and cordova-plugin-device-orientation as alternatives for getting compass-orientation, and sadly Motion-API is no good for me as alternative right now:

  • In the docs, though the subtitle states "The Motion API tracks accelerometer and device orientation (compass heading, etc.)", in the bottom is looks like you get only relative acceleration and rotation rate and no "compass" feature.
  • Even if Motion-API is implemented exactly like the Web-API, and actually has "compass feature", there are big differences with implementation for different browsers and iOS versions. Check this example
  • Asking for compass permission every launch upon user gesture is not an acceptable UX for me, and shouldn't be for every developer wishes to create native experience
  • cordova-plugin-device-orientation works great out of the box for me, I don't ask for premission over and over, I have really nice and simple method to listen for changes in compass reads with filtering by minimal change in degrees with very accurate resolution!

That's why I think Motion-API should implement native methods to get "devices compass", and even adopt the methods used in the old Cordova's plugin.

My project info:
"@capacitor/cli": "3.3.2",
"@capacitor/ios": "^3.3.2",
"@capacitor/angular": "^2.0.0",
"@angular/cli": "^13.1.1",
"@capacitor/motion": "^1.0.4", // not in use
"cordova-plugin-device-orientation": "^2.0.1",

BTW - Be aware that heading and compass used sometimes interchangeably to describe relative deviation from the magnetic north, while sometimes heading is used to to describe the vector of change in position relative to the north. I'm talking about implementing digital compass in my app and not the other kind of heading.

@jcesarmobile
Copy link
Member

As I said, we are considering using native implementation instead of web implementation and it's being tracked here, so please, don't reopen your issue, if you want to add additional information, add it there.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants