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?
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();
}
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).