Giter Site home page Giter Site logo

fotopretty / ng-cordova-beacon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nraboy/ng-cordova-beacon

0.0 2.0 0.0 121 KB

AngularJS wrapper for the Apache Cordova iBeacon plugin

Home Page: https://blog.nraboy.com/2015/09/support-ibeacons-in-your-ionic-framework-mobile-app/

License: MIT License

JavaScript 100.00%

ng-cordova-beacon's Introduction

ng-cordova-beacon

Wrap the cordova-plugin-ibeacon by Peter Metz in AngularJS code so it can be used more easily in AngularJS mobile applications.

Using ngCordovaBeacon In Your Project

The core Apache Cordova plugin is required to use this wrapper:

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

Example Usage

.controller("ExampleController", function($scope, $rootScope, $ionicPlatform, $cordovaBeacon) {

    $scope.beacons = {};

    $ionicPlatform.ready(function() {

        $cordovaBeacon.requestWhenInUseAuthorization();

        $rootScope.$on("$cordovaBeacon:didRangeBeaconsInRegion", function(event, pluginResult) {
            var uniqueBeaconKey;
            for(var i = 0; i < pluginResult.beacons.length; i++) {
                uniqueBeaconKey = pluginResult.beacons[i].uuid + ":" + pluginResult.beacons[i].major + ":" + pluginResult.beacons[i].minor;
                $scope.beacons[uniqueBeaconKey] = pluginResult.beacons[i];
            }
            $scope.$apply();
        });

        $cordovaBeacon.startRangingBeaconsInRegion($cordovaBeacon.createBeaconRegion("estimote", "b9407f30-f5f8-466e-aff9-25556b57fe6d"));

    });

});

Available Functions

Here are a list of available functions:

$cordovaBeacon.requestWhenInUseAuthorization();
$cordovaBeacon.requestAlwaysAuthorization();
BeaconRegion $cordovaBeacon.createBeaconRegion(string identifier, string uuid, int major, int minor);
$cordovaBeacon.startRangingBeaconsInRegion(BeaconRegion beaconRegion);
$cordovaBeacon.startMonitoringForRegion(BeaconRegion beaconRegion);
$cordovaBeacon.stopRangingBeaconsInRegion(BeaconRegion beaconRegion);
$cordovaBeacon.stopMonitoringForRegion(BeaconRegion beaconRegion);

The startRangingBeaconsInRegion and startMonitoringForRegion functions broadcast the results as they happen. To receive these results, do something like:

$rootScope.$on("$cordovaBeacon:didRangeBeaconsInRegion", function(event, data) {
    // Data contains beacon information
});

Have a question or found a bug (compliments work too)?

Tweet me on Twitter - @nraboy

Resources

AngularJS - http://www.angularjs.org

Apache Cordova - http://cordova.apache.org

Nic Raboy's Code Blog - https://blog.nraboy.com

ng-cordova-beacon's People

Contributors

nraboy avatar gortok avatar

Watchers

James Cloos avatar Voravit Euavatanakorn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.