Brian Brian - 1 month ago 20
Android Question

Prevent "Never ask again" from firing Ionic/Cordova's pause/resume

I am using Cordova 5.1.1 and cordova-plugin-geolocation@2.2.0 for geolocation, which uses - cordova-plugin-compat for its Android 6+ permission needs.

When the permission popup is open, Cordova reasonably fires a "pause" document event, as expected, signalling the view having left from the app to the popup (cordova.js):

case 'pause':
// Volume events
case 'volumedownbutton':
case 'volumeupbutton':
cordova.fireDocumentEvent(action); // action being "pause"

case 'resume':
....


And when the user taps either "Deny" or "Allow", Cordova fires a "resume" document event, and ionic's
$ionicPlatform.on('resume', ...)
callback is run, also as expected.

However, after the user taps "Never ask again", all subsequent calls to request fine/coarse geolocation permissions fail without showing the permission popup, but still fire the "pause"/"resume" document events, which is unexpected.

Never ask again

The plugin does not have a check for showing permission rationale. Is there anything I can do to prevent pause/resume from being fired from JS if the user has already requested the app to never ask for permissions again?

Answer

The solution, upon inspection, is not to do anything in the $resume callback that obtains geolocation permissions.