nlgn
nlgn

Reputation: 388

Ionic, Cannot re-enable the geolocation permission after click NEVER in the permission dialog

I am developing an Ionic application on an Android phone with version 6.0.1, and I am encountering an issue about the geolocation permission.

  1. The app successfully asked user for geolocation permission, but when user clicks NEVER in the dialog, the app fails to ask again.
  2. After the user clicking NEVER, the geolocation premission for our app in the Android App permissions is still enabled. (toggling that doesn't help)
  3. Only reinstalling the app, the app ask for the permission again.

enter image description here

Solution:

  1. The dialog is asking enabling the location rather than asking for permission.
  2. The dialog is opened by the plugin https://github.com/mapsplugin/cordova-plugin-googlemaps, while the never button doesn't link to the android settings.
  3. I solve the problem by using another plugin to handle turnning on the location service, which doesnt has a Never option.

Upvotes: 0

Views: 3649

Answers (1)

DaveAlden
DaveAlden

Reputation: 30356

The app successfully asked user for geolocation permission, but when user clicks NEVER in the dialog, the app fails to ask again.

This is the intended behaviour on Android 6.0: once a user has permanently denied permission by checking the "Never ask again" box, the app is not allowed to programatically prompt the user with a dialog.

The only option is to instruct the user how to manually allow the permissions via the Settings page. To assist with this you can use switchToSettings()from cordova-diagnostic-plugin to switch the user to your app's settings page.

After the user clicking NEVER, the geolocation premission for our app in the Android App permissions is still enabled. (toggling that doesn't help)

This should not be the case: manually allowing the permission via the app settings page will allow the app to use that functionality. You can confirm this for yourself using the Android permissions example app for cordova-diagnostic-plugin. However, it depends how the plugin you are using to handle the permission requests responds to the "never ask again" situation. It maybe that you need to use cordova-diagnostic-plugin to manually check the permission status and switch to the app settings page if it's DENIED_ALWAYS.

Upvotes: 4

Related Questions