cordova-plugin-geofence
cordova-plugin-geofence copied to clipboard
initialize() is resolving to failure before permitting or denying the permission popup
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:
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.
I have the same problem. Did you find a workaround for this, @josh-m-sharpe?
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
Where are we on this? I still am encountering the same issue
I'm having the same issue. Has anybody found a fix?
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!
@tsubik any change you could take a look at this? maybe there's an easy fix?