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

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

Open
aubrey-fowler opened this issue Apr 16, 2018 · 0 comments
Open

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

aubrey-fowler opened this issue Apr 16, 2018 · 0 comments

Comments

@aubrey-fowler
Copy link

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.

@aubrey-fowler aubrey-fowler changed the title How to use this plugin? How to use this plugin cordova-plugin-beacon? Apr 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant