Quantcast
Viewing all articles
Browse latest Browse all 8068

Geofence module events work in the simulator only

I recently posted a question about triggering local notifications using Aaron Saunder's geofence module. After discussions with another Titanium user and some testing in the simulator, we got it to work.

My new issue: the module's events are triggered in the simulator and in the simulator ONLY.

Another, not as prioritiezed, issue I've experienced (in the simulator) is that if I stop the module using geofencing.stopGeoFencing() and then activate it again using geofencing.startGeoFencing(regions, function(event) { ... I will from thereon get duplicates when triggering the module's events.

Code:

var geofencing = require('ci.geofencing'); //the module is loaded
var regions = [];
 
regions.push({
    "title" : "Test",
    "latitude" : 55.599073,
    "longitude" : 12.99877,
    "radius" : 50
});
 
var win = Titanium.UI.createWindow({title : 'Hello', backgroundColor: '#fff'});
win.open();
 
geofencing.startGeoFencing(regions, function(event) {
    if ( event.type === "entered_region") {
        var geo_notification = Ti.App.iOS.scheduleLocalNotification({
            alertBody: "Region entered",
            date: new Date(new Date().getTime() + 3000)
        });
 
    alert('Entered region: ' + event.identifier);
    };
 
    if (event.type === "monitoring_region") {
        alert('startGeoFencing running');
    };
});
My test procedure:

A. I install and open the app, and approve the usage of Location services.

Result in simulator: Works as intended. monitoring_region is triggered and "startGeoFencing running" is alerted. Result on phone: Same as above. Works as intended.

B. I lock the phone and go to my "regions" location (in the simulator, I change "Custom location..." to regions.latitude and regions.longitude).

Result in simulator: Works as intended. My local notification saying "Region entered" is displayed and when entering the app an alert saying "Entered region: <name of region>" is also shown. Works as intended. Result on phone: Nothing. The event is not triggered. I've tried several different gps positions.

I have double checked that Location Services is activated and that the app is in the list. It might also be worth knowing that the gps symbol indicating geofencing is indeed shown in the status bar.


I know others have had success using this module so there should be a solution. If someone could give me a helping hand, I'd be so grateful.

Phone and simulator iOS: 6.1

Titanium SDK: 3.2.1


Viewing all articles
Browse latest Browse all 8068

Trending Articles