Comments (13)
Is it possible to create a local notification then? That would be really awesome (:
from cordova-plugin-ibeacon.
It is possible but for the notification you will need to utilize another Cordova plugin.
from cordova-plugin-ibeacon.
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.
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.
@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.
@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.
@petermetz -- awesome. Thanks for your help. I'll post an update with my results.
from cordova-plugin-ibeacon.
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.
@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.
@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.
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.
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.
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)
- trying to use in Ionic/Capacitor env. , no response HOT 8
- what is the identifier used for? looking at all the underlying code it isn't used for beacon recognizing. HOT 2
- when debug is enabled, where is it viewable or stored? HOT 1
- how do I build another version of this library? HOT 1
- using thru Ionic-Native with Capacitor on android , Uncaught (in promise) TypeError: e.beacon.stopRangingBeaconsInRegion is not a function HOT 1
- i expect to see duplicates of beacons where there are multiple, but only see one.. am I doing something wrong? HOT 2
- is there a way to get the mac address of the beacon? HOT 1
- Does this plugin support android 9 and greater ? HOT 7
- Read custom field
- No beacons are found in Andoid 11 smartphones HOT 1
- exitRegion configuration timeout request
- Error: Importing IBeacon which does not have a ɵmod property
- Question: How can I decrease advertising interval as ibeacon device in android and ios?
- Sometimes Beacons within the range are detected differently. HOT 1
- Major and minor with wrong values HOT 1
- Compatibility with Android 12 HOT 4
- Add support of Android 12 (Google API 31) HOT 21
- Use plugin on iOS16+, there's no beacons response from callback! What does can we do on iOS16+
- cordova-plugin-ibeacon not working starting android 11 HOT 7
- Dependency missing in build.gradle for org.altbeacon:android-beacon-library:2.16.1 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-ibeacon.