-
Notifications
You must be signed in to change notification settings - Fork 10
Question - working with cordova-plugin-ibeacon #8
Comments
@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. |
@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 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! |
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! |
@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 For our use case this sends the enter or exit event to our server through an api call, you should replace the logic in |
@stephenrob This is exactly what I did with your plugin. Javascript: I am only making a call to start service on 'onDeviceReady'
On Java side,I replaced the logic in BeaconLoggingMonitorNotifier.java The other change I made to your plugin - Instead of making a separate call to I hardcoded to start monitoring in BackgroundBeaconManager.java onServiceConnection. This should not make any difference.
And I also commented out the following in BackgroundBeaconService.java
Its all working fine in foreground and background. Service keeps running when app is killed, but the beacon monitoring stops working. |
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. |
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. |
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. |
Does that mean this plugin will not work with cordova-plugin-ibeacon? or we just have to leave the reference to lib commented out and it will work fine? I am using cordova-plugin-ibeacon in my project, but for background monitoring I want to use your plugin. I will change it according to my requirements.
Thanks!
The text was updated successfully, but these errors were encountered: