1

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?

Community
  • 1
  • 1
Brian
  • 7,394
  • 3
  • 25
  • 46

2 Answers2

1

I am sure you solved this already, but I believe the only way to do this, is to detect how long it took for the Deny permission to be pressed. In reality, the check is ALWAYS done (even if a user previously said Never again)

Basically, if it gets pressed within a period shorter than is humanly possible (or probable), you will know it was automatically invoked by the system, since it still needs to do check every time. So you can basically differentiate between Deny being pressed immediately, or whether a user manually pushed (which would take a few ms longer).

Hope that helps?

JackDev
  • 4,891
  • 1
  • 39
  • 48
  • Yup I solved it, and just found myself being an idiot. Will post the obvious for completeness. – Brian Nov 04 '16 at 14:19
0

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

taskinoor
  • 45,586
  • 12
  • 116
  • 142
Brian
  • 7,394
  • 3
  • 25
  • 46