Monitoring -> Ranging in a Phonegap/Cordova project


I’m working on integrating ibeacon tracking into one of my company’s internal mobile applications. The intention is to place beacons around the office and use background monitoring from our app to notify a central server when a mobile enters a beacon’s zone.

I’ve configured all the beacons with the same proximityUUID/Major and given them different Minor codes.

The cordova app is written in javascript and uses the angular framework. I can successfully monitor for beacons like this:


This only gives me limited information about the beacon - the regionState object returned tells you what region you have entered but this isn’t much help as the region includes all the beacons with the same proximityUUID. I could setup a different region for each individual beacon but then I would have to setup monitoring for each beacon and this would limit me to 20.

I’m not sure what sort of logic I should implement in order to gather more information about the beacons when the monitoring detects one. Is it possible to use the callback in the code above to start ranging for beacons for long enough to get the minor id of the beacons? Will this work while the app is still in the background? Do I need to worry about disabling monitoring while the app is ranging? Do I need to stop ranging or will it be stopped automatically by the phone?

Any help, much appreciated.

To follow up my own thread. I’m trying this basic solution:

  1. Start monitoring for beacons when app launches. This carries on in background.
  2. If beacons are detected then start ranging for beacons.
  3. Assume that iOS will automatically pause the ranging process after a short period of time if the app is in the background.

hI @kieren,
Are you trying to say that Monitoring will work in background on a Phonegap/Cordova project?

Yes, monitoring works fine on Phonegap/Cordova. In the end I did this and it works pretty well:

  1. App starts and initiates monitoring
  2. If device enters into a beacon region then monitoring triggers action
  3. Start ranging, this gives more information about all beacons that are detectable. I sort these by distance to determine which beacon device is closest to.
  4. After 10 seconds turn off ranging.

As monitoring alerts are only triggered when the device enters/exits a region, it was also necessary to schedule ranging at fixed intervals, every few minutes. This would deals with the situation where beacons overlap each other and therefore the device does not exit/enter the overall region.

Thanks for posting back @kieren! Monitoring is working fine even when app is killed? Does it really trigger Enter & Exit Action even if the app is killed?

Most of my testing is on iOS and the monitoring continues after the app is killed. It’s as this article describes.

@kieren hi there, from the previous replies, i understand that your beacon app is developed using cordova. isit possible if you provide me links as to where you got the coding such that when the mobile app detects a beacon, an image will appear or an event will occur? thank you

I found this tutorial useful:

Particularly the section “Creating a native Estimote app”

1 Like

hi @kieren, I’ve tried out the link you provided me but the mobile application will only show the details of the beacon such as the uuid, major and minor values. the problem i am currently facing is to find codes such that when the mobile application detects a beacon, an image will appear or an event will occur.

For example: when the mobile application detect a particular beacon, the mobile app will automatically direct the user to a link, show an image or direct the user to another page filled details.

thank you so much for taking your time reading and replying to my email :))

I’m using AngularJS for this project. I created a simple beacons factory and then invoke beacon monitoring in my main controller (ie. it starts when the app launches)

  // Tell the phone to monitor for beacons in the background
    function(regionState) {
     // this is the callback invoked when entry/exit occurs
      console.log('Beacon found: ' + regionState.state);
      if (regionState.state === estimote.beacons.RegionStateInside) {    
        // start ranging beacons

        // set timeout to stop ranging beacons after 10 seconds
        $scope.timeoutPromise = $timeout(function(){ $scope.stopRangingBeacons(); }, BEACON_RANGING_TIMEOUT);

    function(errorMessage) {
        console.log('Monitoring beacons did fail: ' + errorMessage);

Monitoring starts on app launch and if an entry/exit event is detected then the callback is invoked. The callback is invoked even if the app is killed. In my case, I wanted more information from the beacons than is provided by the monitoring so I need to tell the app to start ranging for beacons. Beacon ranging invokes a different callback that has some logic to process the details of all beacons within range. I don’t want the app to continue to range beacons for ever, as this consumes battery, so I timeout the ranging process after 10 seconds.

1 Like

@kieren, hi there, so the codes you stated above can be used to help me on the question i mentioned on the previous replies isit? i am not strong in my programming hence i am unsure on how to code out.

I’d love to help you more but creating a cordova app that works with iBeacons requires more than basic javascript programming skills. All I can recommend is that you start simple - create a basic cordova app and attempt to get it to run on your phone. Then start trying to implement ranging for beacons using the tutorial I linked to earlier. Try to display the output from the ranging process on your app, so that you can see it working properly.

I also recommend using angularJS for this kind of project. It helps break your application up into small controllers and makes changing data on the front end much easier. I’d recommend looking for an online course in how to setup a basic angularJS app.

Combine these together and you have the frameworks you’ll need to build a good cordova application that can range/monitor ibeacons.

1 Like

Hello Kieren,

I was able to make an app using evothings software, but i don’t know how to succeed without it.
Could you please tell me how? (i can pay for it).

Also, i am looking for a developer, can you recommend someone?

My email is:

Thanks in advanced for your time.