Motion permission

Hello,

I’m using a capacitor plugin “Motion” and I wonder if this is possible to ask the permission to the user when he clicks on a specific button even if he reject the permission before.

Actually, I don’t see the permission option in the apple settings of the application (such as the location or the camera permission) so if the user reject the permission, he has to relaunch the app the enable the motion permission.

Is there a way to re-ask in the same session of the app or to force the app (using the capabilities or something else) to always enable this permission?

Thanks for your help,
Loïc

In the docs there is a method called requestPermission with an example: Motion Capacitor Plugin API | Capacitor Documentation

Hello @Hills90210,

Thanks for your reply :slight_smile:

Yes, there is this method but if the user rejects the permission, the method returns the status and don’t ask the permission to the user again.

(Also, the way it is indicated in the documentation doesn’t work as expected. More information here).

Kind regards,
Loïc

So what you would need to do is use the capacitor-native-settings plugin to open the native app settings:

  const hasPermission = await DeviceMotionEvent.requestPermission();
  if(hasPermission) {
    // do this
  } else {
    // use alert to notify the user of permission denied
    // if user clicked ok, run method
    this.service.openNativeSettings();
  }
async openNativeSettings() {
    await NativeSettings.open({
      optionAndroid:  AndroidSettings.Application,
      optionIOS:  IOSSettings.App,
    });
  }

Hello @Hills90210,

Thanks again for your help :slight_smile:

Yes, this is what I do for the other permissions such as Camera or Location but, for the motion, I don’t see any permission configuration in the setting of the app.

FYI : After trying and testing tools, I have switched to the plugin DeviceOrientation of Cordova (that is compatible with Capacitor) because this plugin seems to work without showing a permission prompt to the user and also, it returns the compass orientation for IOS (such as the Motion Plugin) and Android.

I suppose the Motion plugin will evolve over time and be more compatible and complete (by returning for example the heading orientation for Android).

Regards,
Loïc

1 Like