cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
265 stars 318 forks source link

geofencing transition detection only triggers once iOS 9.3.2 #150

Open jesperneelen opened 8 years ago

jesperneelen commented 8 years ago

I use Meteor in my project together with Angular. I'm trying to integrate the geofence plugin in iOS. When I install the plugin and execute the code below, the geofence will be triggered only once. After that, no console.logs or alert are thrown. I've searched on the internet and found nothing concerning this particular issue.

window.geofence.initialize().then(function () {
            console.log("Successful initialization");
            window.geofence.getWatched().then(function (geofencesJson) {
                var geofences = JSON.parse(geofencesJson);
                console.log(geofences);
            });
        }, function (error) {
            console.log("Error", error);
        });
    window.geofence.removeAll();
    window.geofence.addOrUpdate({
        id:             '10af5fab-39de-43df-b7a1-546cbbafc18c',
        latitude:       51.142798, 
        longitude:      4.442956, 
        radius:         10, 
        transitionType: 3, 
        notification: {         
            id:             1,
            title:          'HELLO',
            text:           'Give test juice?',
            openAppOnClick: true,
            data:           { _id:'sFkS9EJkHGJo9mYTP'}
        }
    }).then(function () {
        console.log('Geofence successfully added');
    }, function (reason) {
        console.log('Adding geofence failed', reason);
    });

    window.geofence.onTransitionReceived = function (geofences) {
        alert('go');
        geofences.forEach(function (geo) {
            alert('Geofence transition detected ' + geo);
        });
    };`

The initialize function will be called successfully, the addOrUpdate function will run accordingly ... Only there is something wrong the onTransitionReceived function I suppose.

Is it iOS related this issue? Is it the plugin? Is it Meteor that's causing this issue?

ThaBrad commented 8 years ago

@jesperneelen I don't think it's your problem. Having tons of problem too with this quite broken library.

Will probably do it "myself" now: https://www.raymondcamden.com/2015/05/18/tracking-and-notifying-geolocation-status-with-ionic/

(there is also a trick to speed up x2 that bit with a different distance calculation: http://stackoverflow.com/a/21623206/1176551)

t2wu commented 6 years ago

My window.geofence.onTransitionReceived gets called only once when I'm simulating in and out on Xcode, even though locationManger:didEnterRegion and locationmanger:didExitRegion did called repeatedly. (Thought I sort of did a hack, because iBeacon plugin and Geofence plugin is in conflict, so I have to post a notification from iBeacon so Geofence receives it).

Is there any fix to this?