Comments (8)
@codingjam this plugin works fine when using with cordova-plugin-ibeacon, its what we use in our Library Journeys mobile app alongside this. You will just need to make the modifications needed for your own requirements as you say.
from background-beacon-monitoring.
@stephenrob I ended up creating my own basic background service plugin that monitors for beacons. I am running into a strange issue. Beacon monitoring works fine when my app is in background/foreground, when I kill the app my service keeps running but the beacon monitoring stops working! Monitoring starts working again as soon as I open my app again. Since you have already created something similar, could you think of something that might be causing it? I appreciate your help!
- I did not include libs/altbeacon.jar in my background service plugin as I am already using cordova-plugin-ibeacon
- My app has all the right permissions as I am able to monitor beacons when the app is in foreground/background.
I noticed that as soon as I kill the app, my beaconManager becomes null, and it doesn't bind again until you start the app.
Thanks!
from background-beacon-monitoring.
UPDATE: I tried your plugin and it's the same exact behavior. Beacon Monitoring stops working when app is killed but the service continues to run. I wonder if it's Phone or Android version specific, or I am doing something wrong!
from background-beacon-monitoring.
@codingjam have you got the logic for what to do when you enter/exit a region written in the Java code not the Javascript or Cordova layer ?
On android this has to be written within the service in Java code so it is available when your app is killed and the service is still running - unlike on iOS where any app logic is available when the region is entered/exited on android this is not the case.
In our case we have this logic in src/android/uk/ac/lancaster/library/backgroundbeacons/BeaconLoggingMonitorNotifier.java
For our use case this sends the enter or exit event to our server through an api call, you should replace the logic in didEnterRegion
and didExitRegion
with what you want to happen when you enter or exit a region - this could be display a local notification or open up your application etc.
from background-beacon-monitoring.
@stephenrob This is exactly what I did with your plugin.
Javascript: I am only making a call to start service on 'onDeviceReady'
BackgroundBeaconMonitoring.startService('aaaa', 'email', 'deviceidd', 'url', 'version', false, successeCallback, errorCallback);
On Java side,I replaced the logic in BeaconLoggingMonitorNotifier.java didEnterRegion/didExitRegion
to make a api call to our backend. This is all working fine when the app is in foreground or background. But doesn't work when the app is killed for some reason.
The other change I made to your plugin - Instead of making a separate call to BackgroundBeaconMonitoring.startMonitoringRegion(identifier, uuid, major, minor, successCallback, errorCallback)
I hardcoded to start monitoring in BackgroundBeaconManager.java onServiceConnection. This should not make any difference.
private ServiceConnection serviceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
LocalBinder binder = (LocalBinder) service;
backgroundBeaconService = binder.getService();
serviceBound = true;
backgroundBeaconService.startMonitoringRegion("myregion", "BBBBBBB0-DDD0-CCC0-DDD0-11E5A2EEEEE0", null, null);
}
public void onServiceDisconnected(ComponentName arg0) {
serviceBound = false;
}
};
And I also commented out the following in BackgroundBeaconService.java
if(iBeaconManager.isBackgroundModeUninitialized()) {
iBeaconManager.setBackgroundMode(true);
}
Its all working fine in foreground and background. Service keeps running when app is killed, but the beacon monitoring stops working.
from background-beacon-monitoring.
Are you able to leave the following not commented out and see if that makes any difference?
if(iBeaconManager.isBackgroundModeUninitialized()) {
iBeaconManager.setBackgroundMode(true);
}
Also what version of Android are you running this again and which version of Cordova, cordova-plugin-ibeacon
I'm not currently working on this project at the minute, so its not fresh in my head how exactly I got this working.
from background-beacon-monitoring.
I tried that as well, but didn't make any POSITIVE difference :) Beacon Scanning doesn't work in foreground also when I setBackgroundMode to true. All it should do is increase the time period between scans to save battery.
I am using Cordova 6.4.0, cordova-plugin-ibeacon 3.4.1 and Android 6.0
I am going to try running it on a different Android version and check.
from background-beacon-monitoring.
Update: I got the same service working on a different phone running Android 5.1. Looks like some issue with the 6.0 and Altbeacon library working together. Also, I notice that the service becomes inactive after a long period of time and stops monitoring? Did you face a similar issue. I am still testing this behavior on different OS versions.
from background-beacon-monitoring.
Related Issues (10)
- exit region HOT 1
- background monitoring not giving didenter or didexit notifications in android?
- Is notification not getting from Enter/Exit Region in Background Mode ?
- Problem, BackgroundPowerSaver: Context is not an application instance, so we cannot use the BackgroundPowerSaver
- No success or error callbacks for request permissions HOT 1
- Can't find BackgroundBeaconMonitoring HOT 1
- Remember previous registred regions when app is in background HOT 2
- generic version HOT 1
- How can i use it with ionic 2? 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 background-beacon-monitoring.