deckameron / Ti.Android.Geofence

A Geofence solution for Appcelerator Titanium Android
Other
17 stars 5 forks source link

geofence.DWELL not triggering #3

Closed malakodas closed 5 years ago

malakodas commented 6 years ago

Hi,

it seems that geofence.DWELL is not triggering whatever i do. Here is relevant code:

for(var i in carouselCards) {
        if(carouselCards[i].cardWrapper.latitude !== null && carouselCards[i].cardWrapper.longitude !== null) {
        var newRegion = {
            "id": carouselCards[i].cardWrapper.id,
            "latitude": carouselCards[i].cardWrapper.latitude,
            "longitude": carouselCards[i].cardWrapper.longitude,
            "radius": 1000,
            "dwellTime" : (5000).toFixed(2),
            "transitions" : [
                              geofence.GEOFENCE_TRANSITION_DWELL
                ]
        }

        androidFences.push(newRegion);
    }
}

if(androidFences.length) {
    geofence.addGeofences({
        clearExistingFences: true,
        fences: androidFences
    });

        geofence.startMonitoring();
    geofence.addEventListener(geofence.DWELL, function(e){
                Titanium.API.info(JSON.stringify(e));
    });
}

Fences array is populated, monitoring started but i can't get dwell callback to work. Enter event works fine though.

Im using module version 1.0.2 and titanium sdk 7.4.0.GA. Also using Mock locations app to get desired behaviour.

Thanks

deckameron commented 6 years ago

Hi @malakodas Thank you for reporting these issues. I just came back from a vacation and I will investigate the issues an solve them asap.

[EDIT] The "dwellTime" is in milliseconds. Could you try changing "dwellTime" : (5000).toFixed(2), to "dwellTime" : "dwellTime" : 5 * 60 * 1000, :-) I believe this will solve the issue.

Google Documentation Defaults to 0. Setting a big responsiveness value, for example 5 minutes, can save power significantly. However, setting a very small responsiveness value, for example 5 seconds, doesn't necessarily mean you will get notified right after the user enters or exits a geofence: internally, the geofence might adjust the responsiveness value to save power when needed.