I got around to updating cordova-plugin-request-location-accuracy - v2.0.0 now enables a direct location request to be made which triggers the native iOS dialog to directly open the Privacy page in the Settings app where the switch for Location Services is located.
It was possible earlier, but you canāt submit your app now in AppStore without getting your app rejected during review. Please check here
It is not programmatically possible to switch Location Services ON or to directly open the Location Services page in the Settings app.
Your best choice would be to open just āsettingsā when required, using the diagnostics plugin and use the method switchToSettings() as described here
Please note that you can use the same diagnostics plugin to open location services settings in Android and Windows 10 UWP using switchToLocationSettings() but not in iOS.
thank you for your reply.
yes, i am able to open location setting in android using diagnostics plugin. but not working in ios. is it not possible to open location services in ios? i am currently using ionic5.
I am not sure but as answered above by dpa99c1, you may use this plugin to show a native iOS system dialog that will ask to open it for you. It seems the plugin can be implemented by ionic native plugin location accuracy.
Also, please make note that as mentioned in the documentation, there is a scenario in which this plugin fails :
If, upon successfully showing the native dialog, the user presses āCancelā instead of āSettingsā, any subsequent requests via this plugin will not show the dialog again. Ever! This is because iOS assumes that if the user pressed āCancelā, they donāt want your app to use their location, so iOS prevents you from asking them again to switch on Location Services.
Thereās no way to tell which button the user pressed in the native dialog or whether āCancelā was pressed and the dialog is not being shown.
So you have to handle the exceptions in your app considering this scenario. If the user presses āCancelā which leads to canRequest() function of this plugin to return false, then you donāt have any choice to open any system dialog, and will then have to return to the same state as you were before implementing this plugin.
thanks. i have already tried this location accuracy plugin. and yes in ios, it is not showing dialog once cancel button is clicked. i think i have only one way for ios. i have to switch to setting page only as we are not able to redirect to location setting page.