Giter Site home page Giter Site logo

Comments (13)

simkli avatar simkli commented on June 12, 2024

Is it possible to create a local notification then? That would be really awesome (:

from cordova-plugin-ibeacon.

petermetz avatar petermetz commented on June 12, 2024

It is possible but for the notification you will need to utilize another Cordova plugin.

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 12, 2024

Would completing this ticket be needed in order to use this plugin to configure my application to wake from a closed or background state in response to entering an iBeacon region?

from cordova-plugin-ibeacon.

petermetz avatar petermetz commented on June 12, 2024

Hi @morrissinger,

No, that should work out of the box with the current codebase. I'm writing should, because I only ever tested it with circular regions but that's definitely working and so should with beacons too.

Peter

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 12, 2024

@petermetz , first of all, thank you for being so responsive.

I'm a little confused about how to do this from the examples in your readme. I am looking under the "Start Monitoring for a Single iBeacon" section. If I call startMonitoringForRegion() in your example, is that going to automatically start region monitoring even when the app is closed?

from cordova-plugin-ibeacon.

petermetz avatar petermetz commented on June 12, 2024

@morrissinger, yepp that's how it should work. From the calling side it should be transparent whether the app was running or not. Theoretically... :-)

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 12, 2024

@petermetz -- awesome. Thanks for your help. I'll post an update with my results.

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 12, 2024

I tried this out by using the PhoneGap local notification plugin (https://github.com/katzer/cordova-plugin-local-notifications) to generate location notifications when I entered and exited regions, and I can confirm that even with the app completely closed (i.e., double-tap home button and swipe app up), and the phone not active (i.e., screen is black), this plugin is able to do region monitoring. Excellent.

N.B.: I have not tested on Android.

from cordova-plugin-ibeacon.

Ranjan-2014 avatar Ranjan-2014 commented on June 12, 2024

@morrissinger, Can you please share some snippet on how you are implementing in the call of startMonitoringForRegion()? It seems to be not working with the same.

didEnterRegion: function(pluginResult) {
window.plugin.notification.local.add({ message: 'Exit!' });
}
Is this necessary to run the app in the background to make it work(notify on entering a region)? Or I am doing something wrong here.
Also, I do see, didStartMonitoringForRegion is giving same pluginresult when beacon is off and on.
Appreciate your response....Thanks

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 12, 2024

@petermetz -- question: given that these two properties (notifyOnEntry and notifyOnExit) are not exposed to the JavaScript side of the plugin presently, what values are being supplied to these properties by default?

The reason I ask is thatI have set up an app with your plugin and all it does is set a local notifications whenever the phone enters or exits a region. I have also installed the Locate app by Radius (https://itunes.apple.com/us/app/locate-beacon/id738709014?mt=8), which ostensibly does the same thing. I have both apps listening to my Estimote iBeacons, and yet, with both apps closed, Locate appears to pick up the iBeacons far more frequently and also picks seems to pick them up every time I turn on the screen to my iPhone.

With the Locate app operating as a sort of control in this experiment, one would think that the same iPhone would detect the same iBeacons at approximately the same times. Yet this is not the case. Thus, I am looking for anything that may be configured differently between the two and these two properties caught my eye.

from cordova-plugin-ibeacon.

petermetz avatar petermetz commented on June 12, 2024

@morrissinger

By default, both notifyOnEntry and notifyOnExit are set to YES, according to the documentation of Apple (see the description of this issue for reference).

The difference between Locate Beacon and the Cordova iBeacon plugin is definitely not because of the two mentioned properties, since they are both enabled by default.

My guess is that Locate Beacon might be using the iOS Core Bluetooth API under the hood, to be a bit more sophisticated than the simplistic Core Location API (which is used by this plugin).

This is just pure speculation though, the only surefire way to tell if you go and ask Radius Networks about their code. :-)

Peter

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 12, 2024

Ransome14: Here is what I did to get it working. Note, I needed to use the localnotification plugin as well to ensure that I could actually receive an event with the app closed. An alert() is not sufficient. You need to use a method that iOS provides for actually delivering a message to a user when an app is closed. Local notifications are a perfect method for this.

        var createLocalNotification = function (message) {
            window.plugin.notification.local.add({
                title:   'iBeaconSpike1',
                message: message
            });
        };

        var delegate = new cordova.plugins.locationManager.Delegate().implement({

            didDetermineStateForRegion: function (pluginResult) {
                createLocalNotification('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
            },

            didStartMonitoringForRegion: function (pluginResult) {
                createLocalNotification('didStartMonitoringForRegion:' + JSON.stringify(pluginResult));
            },

            didRangeBeaconsInRegion: function (pluginResult) {
                createLocalNotification('[DOM] didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult));
            }

        });

        var uuid = 'MY UUID';
        var identifier = 'JUST AN IDENTIFIER PASSED IN ON THE MESSAGE';
        var minor = /* MY MAJOR */;
        var major = /* MY MINOR */;
        var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor);

        cordova.plugins.locationManager.setDelegate(delegate);
        cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion)
                .fail(console.error)
                .done();

from cordova-plugin-ibeacon.

sebastianh84 avatar sebastianh84 commented on June 12, 2024

Hi I monitor a single beacon. The didDetermineStateForRegion with notification works fine.
Now i want to notify the user just one time if he enters the region - just to say "hello please open your app now" - and only if he is about 4meters away from the beacon. The user should be notified if the app is closed - is that possible? something like:

     delegate.didDetermineStateForRegion = function (pluginResult) {
            //window.alert('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
           if ( notAlreadyNotified == true && distanceToBeacon < 4 meters && appIsInBackground)
            {
                createLocalNotification('Welcome to our company please open your app ' + JSON.stringify(pluginResult.state));notAlreadyNotified = false;

            }               
        };

from cordova-plugin-ibeacon.

Related Issues (20)

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.