upnext / BeaconControl

Setup and manage large beacon deployments with BeaconControl open source platform
https://beaconcontrol.io
BSD 3-Clause "New" or "Revised" License
92 stars 63 forks source link

[Question] Hybrid app #31

Closed zkenstein closed 6 years ago

zkenstein commented 8 years ago

Is it compatible with the hybrid app Cordova?

Thanks

jkurdel commented 8 years ago

Hi @zkenstein

What do you mean by that?

zkenstein commented 8 years ago

Hi @jkurdel,

If I plan to use the backend with the hybrid app (Cordova or Ionic) is there any plan to release the plugin for this?

Thanks

botmonster commented 8 years ago

Hi @zkenstein, Currently we provide plugins for native apps - this may change in future. You can alway implement BLE plugin for Cordova/Ionic https://github.com/don/cordova-plugin-ble-central to be able to receive device ID and then use our REST API to control beacons with known ID's https://beaconcontrol.io/dev/backend-docs - which is not complicated solution.

mhd999 commented 7 years ago

Hi @botmonster @zkenstein i guess the plugin ble-central is meant to BLE communication when you can use https://github.com/petermetz/cordova-plugin-ibeacon made for iBeacon where you can monitor and range devices.

But am not sure which the API you need to call when you first get a beacon in a range I have read the docs but still can't figure it out can you please help @botmonster !

mhd999 commented 7 years ago

Hi! @zkenstein @botmonster Regarding to the second part of my previous comment about which API should hit to deliver the events it's/events api however, I still think there is no clear way to understand the how things are working unless you know about how the iBeacon protocol well.

And follow the SDK code, work flow digram might solve this issue.

brandecho commented 7 years ago

Hi @zkenstein @botmonster @mhd999 . Was anyone able to figure out the entire code that would monitor ibeacons within range of the UUID by making an ajax request to the "GET /s2s_api/v1/beacons" api, and based on the results (major, minor, promimity id, late, lng etc.), and then an "if" statements that would make another Ajax post request to the notifications api? It would be really helpful if someone could the code for such a Scenario. Thank you in advance.

brandecho commented 7 years ago

So far I found this resource that will help in ranging/monitoring Ibeacons that are hard coded into the client, which is not the ideal solution unless you use a third party service like Ionic Cloud's Deploy service or MicroSoft's CodePush to update files in Cordova "www" folder to update the .js file with the ibeacon information. Although not a complete solution to my previous question, still need to figure out the "if" statement once an ibeacon is in range to send an ajax post request to fire the action. https://evothings.com/quick-guide-to-writing-mobile-ibeacon-applications-in-javascript/

mhd999 commented 7 years ago

Hi @brandecho you may want to add which SDK/Plugin you're using.

Since this issue opened for Cordova based app, and if your using Ionic 1 then this code should do the work for you or you can use vanilla javaScript instead if you are not using Ionic 1 and Angular.

Plugin: https://github.com/petermetz/cordova-plugin-ibeacon

Fetch your beacons and ranging them:

$http({
  method: 'GET',
}).then(function(beacons){
   beacons.forEach(function(beacon, index) {
                        $window.cordova.plugins.locationManager.startRangingBeaconsInRegion(createBeaconRegion(beacon.id, beacon.uuid, beacon.major, beacon.minor, true));  
    })
}, function(response){/*LOG ERROR*/}

Monitor Enter/Exit event:

delegate.didEnterRegion = function (pluginResult) {
  $timeout(function () {        
         $window.cordova.plugins.locationManager.startRangingBeaconsInRegion(createBeaconRegion(pluginResult.region.identifier, pluginResult.region.uuid, pluginResult.region.major, pluginResult.region.minor, true))
  .fail(function(e) {/*LOG ERROR*/})
  .done(function(){delegate.didRangeBeaconsInRegion = function (pluginResult) {}})
  });
};