Skip to content
This repository was archived by the owner on Sep 4, 2019. It is now read-only.
This repository was archived by the owner on Sep 4, 2019. It is now read-only.

How to use this plugin cordova-plugin-beacon? #434

Description

@aubrey-fowler

I am just getting started with this plugin and I'm not sure what I need to do.

I am writing an app with Cordova cli v8, Ionic 1.3.4, and AngularJS 1.5.3.

Here is my controller:

app.controller('myCtrl', function($scope) {

    $scope.version = 0;
    $scope.result = {};
    $scope.running = 0;

    $scope.onClick = onClick;
    $scope.stop = stop;

    function onClick() {

        console.log(' on click ');

        $scope.running = 0;


        cordova.plugins.simplexpbeacon.initialiseBluetooth(
            function(data) {
                var json = JSON.parse(data);
                if (json.status === 'OK') {

                    console.log(' initialiseBluetooth ', json);

                }
            }, onError
        );

        cordova.plugins.simplexpbeacon.pluginVersion(onSuccess, onError);

        cordova.plugins.simplexpbeacon.startMonitoring(function (response) {
            console.log(' startMonitoring ', response);
            $scope.running++;

            $scope.result = JSON.parse(response);

        }, onError);


    }



    function stop() {

        cordova.plugins.simplexpbeacon.stopMonitoring(function (response) {
            console.log(response);
        }, onError);

    }

    function onSuccess(result) {
        console.log(result);
        $scope.version = JSON.parse(result).plugin_version;
    }

    function onError(error) {
        console.log(error);
    }

});

Do I need to call initialiseBluetooth each time I click on the button or just when the application runs?

startMonitoring is called but it never gets any updates or new data.

I am not sure if what I am doing is correct or what I need to do. I want the user to push a button and then start scanning for ibeacon tiles.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions