Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

TiBeacon does not fire region events

$
0
0

I created a simple iOS app using TiBeacons (SDK 3.3.0, iOS 7.1.2, iPad Retina).

Ranges monitoring works properly. Since this takes more energy, I would like to run region monitoring, and then run ranges monitoring only when the iBeacon is within the region. Unfortunately region monitoring never fires enteredRegion/exitedRegion events.

This is my code. Any hint will be appreciated a lot.

var TiBeacons = require('org.beuckman.tibeacons');
 
var win = Ti.UI.createWindow({layout: 'vertical'});
 
var proximityLabel = Ti.UI.createLabel({top: 20, left: 20, color: '#fff'});
win.add(proximityLabel);
 
var rangeLabel = Ti.UI.createLabel({top: 20, left: 20, color: '#fff'});
win.add(rangeLabel);
 
function updateRanges(e) { 
    rangeLabel.text = 'accuracy: ' + e.beacons[0].accuracy;
}
 
function handleProximity(e) { 
    proximityLabel.text = 'proximity: ' + e.proximity;
}
 
TiBeacons.addEventListener('beaconRanges', updateRanges);
TiBeacons.addEventListener('beaconProximity', handleProximity);
 
TiBeacons.enableAutoRanging();
 
function enterRegion(e) { 
    alert('[enteredRegion] ' + JSON.stringify(e));
}
 
function exitRegion(e) { 
    alert('[exitedRegion] ' + JSON.stringify(e));
}
 
TiBeacons.addEventListener('enteredRegion', enterRegion);
TiBeacons.addEventListener('exitedRegion', exitRegion);
 
win.addEventListener('open', function(e) {
    /*
    // this works properly
    TiBeacons.startRangingForBeacons({ 
        uuid: 'ACFD065E-C3C0-11E3-9BBE-1A514932AC01', identifier: ‘Region 1’, 
    });
    */
 
    // // this never fires enteredRegion/exitedRegion events
    TiBeacons.startMonitoringForRegion({
        uuid: 'ACFD065E-C3C0-11E3-9BBE-1A514932AC01', identifier: ‘Region 1, 
    });
});
 
win.open();

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>