Capacitor Motion Plugin Example / Capacitor Plugin Future

Please describe the quesHi all,

I was wondering if anybody played with the the official Capacitor Motion Plugin (v2) yet?

URL: https://capacitorjs.com/docs/apis/motion

I was trying to get it to run, but cannot figure it out.

The recommended way of requesting permissions fails on the web:

 try {
  await DeviceMotionEvent.requestPermission()
 } catch (e) {
   console.log(e)
   return;
 }

TypeError: DeviceMotionEvent.requestPermission is not a function

If I just add the listener and return the event then I get all Acceleration Information to be null:

{
	{
		acceleration: DeviceMotionEventAcceleration
		x: null
		y: null
		z: null
		__proto__: DeviceMotionEventAcceleration
	}, {
		accelerationIncludingGravity: DeviceMotionEventAcceleration
		x: null
		y: null
		z: null
		__proto__: DeviceMotionEventAcceleration
	}
}

Not sure if this is because it is on the web (via ionic serve), but the plugin should work on web, android, iOS. Should I not get readings back from the sensors?

If I run my code native on Android, then the request permission also does not work, and I do not even get the event from the Motion plugin back.

Question:

  • Does anybody have any pointers/links to tutorials, github repos, etc. that have a working example of that plugin?
  • Has anybody worked with this plugin across PWA, android, iOS and can confirm that it actually works in v2/v3 beta?
  • Is there another capacitor kitchen sink repo, because the official one seems to be dead: https://github.com/ionic-team/capacitor-plugin-demo

General questions for the Ionic team:

  • With capacitor now in v3 beta, should we still start projects with v2?
  • What is going to happen to ionic native long term? Are you maintaining the long existing list of ionic native plugins or will efforts be shifted to grow capacitor? (Apologies if I have missed a blog article on that in the past.)

Any help would be very much welcome.

Thanks.

Hi all,

Just wondering if anybody has some ideas around this please. This forum unfortunately seems “pretty quite” - does anybody else have ideas for community support?

Thanks.

Hi all,

Apologies for bumping this up. I was hoping to get a response to these two very general questions at least, if possible?

  • Does anybody have any pointers/links to working tutorials, github repos, etc. that have a working example of that plugin?
  • Has anybody worked with this plugin across PWA, android, iOS and can confirm that it actually works in v2/v3 beta?

Also, I searched online, and all I could find is people having problems with the plugin, either not supported on iOS 13+ or not running at all, forcing them to switch back to cordova plugins: Ionic 5 + Angular + Capacitor + Motion not triggering listener on real Android devices - Stack Overflow

Thanks again.

You only have to request the permission on iOS 13+, so first check if DeviceMotionEvent.requestPermission is defined, and if not, don’t try to request the permission because it’s not needed and won’t work.

Thanks very much @jcesarmobile - much appreciated.

Have you worked with the plugin successfully. I eventually was able to use it on android and iOS native builds, but PWA did not work for me.

Thanks :+1: