cordova-plugin-geofence icon indicating copy to clipboard operation
cordova-plugin-geofence copied to clipboard

initialize() is resolving to failure before permitting or denying the permission popup

Open ghost opened this issue 8 years ago • 6 comments

using:

<plugin name="cordova-plugin-geofence" spec="0.6.0" />

iphone 6s, both simulator and hardware

Simply executing this in a console:

window.geofence.initialize().then(function () {
    console.log("Successful initialization");
}, function (error) {
    console.log("Error", error);
});

Causes what you see here: image

Interestingly, re-executing initialize later seems to work as expected (depending on if perms are allowed or denied). So, it only seems to have this issue the first time.

ghost avatar Apr 22 '16 04:04 ghost

I have the same problem. Did you find a workaround for this, @josh-m-sharpe?

sdvg avatar May 02 '16 12:05 sdvg

No. I'm using this though, and it mostly seems to work the first time a user encounters it. Obviously delayed.

var initialied = false;
function init(){
  window.geofence.initialize().then(function(){
    initialized = true
  })
}

init();  // pops the permission, but because of the bug can't wait, also 'initialized' is going to be false here

setTimeout(function(){
  init();  // if the user gave permission and if it was done in < 15s, then the var initialized will be set to true here
  setTimeout(function(){
    if(initialized){
      // ok, do stuff
    }
  }, 1000);  // arbitrary 1 second in case the hardware is slow or something.
}, 15000);  // probably long enough for the user to have cleared the dialog

ghost avatar May 02 '16 23:05 ghost

Where are we on this? I still am encountering the same issue

keithmattix avatar Jun 10 '16 20:06 keithmattix

I'm having the same issue. Has anybody found a fix?

craze3 avatar Sep 21 '16 22:09 craze3

Hey guys! I was facing the same issue, as I also using another location service, so probably in your .plist file you have 2 location permissions. The use when the app runs and the always permission. Just remove from .plist the "When app run" and just leave the always permission.

That worked for me!

marvi14 avatar Dec 11 '16 13:12 marvi14

@tsubik any change you could take a look at this? maybe there's an easy fix?

josh-m-sharpe avatar Jun 03 '17 21:06 josh-m-sharpe