I have researched on this but to no avail. Is it possible to modify the beacon scan periods (e.g. BackgroundScanPeriod, BackgroundBetweenScanPeriod, ForegroundScanPeriod and ForegroundBetweenScanPeriod) in Ionic?
If it not documented in the plugin code, I would contact the plugin author directly.
What plugin are you talking about? Mentioning this would make it easier for us to maybe look it up…
By the way, thank you for your direction. I almost forgot to reply to this thread. It’s documented in the plugin code, however only for the “ForegroundBetweenScanPeriod”. I had to modify the LocationManager.java (in platform/android) to add the three other scan periods as well such as ForegroundScanPeriod, BackgroundScanPeriod and BackgroundBetweenScanPeriod, and then update also the ionic’s config.xml to make it configurable.
Care to share your code here maybe? I’m sure future developes having the same problems would appreciate it.
Sure, hope this helps!
-
In your “/platforms/android/src/com/unarin/cordova/beacon/LocationManager.java”, you can set the scan periods in your iBeaconManager:
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);final Activity cordovaActivity = cordova.getActivity(); final int foregroundScanPeriod = this.preferences.getInteger( FOREGROUND_SCAN_PERIOD_NAME, DEFAULT_FOREGROUND_SCAN_PERIOD); final int backgroundScanPeriod = this.preferences.getInteger( BACKGROUND_SCAN_PERIOD_NAME, DEFAULT_BACKGROUND_SCAN_PERIOD); final int foregroundBetweenScanPeriod = this.preferences.getInteger( FOREGROUND_BETWEEN_SCAN_PERIOD_NAME, DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD); final int backgroundBetweenScanPeriod = this.preferences.getInteger( BACKGROUND_BETWEEN_SCAN_PERIOD_NAME, DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD); Log.i(TAG, "Determined config value FOREGROUND_BETWEEN_SCAN_PERIOD: " + String.valueOf(foregroundBetweenScanPeriod)); iBeaconManager = BeaconManager.getInstanceForApplication(cordovaActivity); iBeaconManager.setForegroundScanPeriod(foregroundScanPeriod); iBeaconManager.setBackgroundScanPeriod(backgroundScanPeriod); iBeaconManager.setForegroundBetweenScanPeriod(foregroundBetweenScanPeriod); iBeaconManager.setBackgroundBetweenScanPeriod(backgroundBetweenScanPeriod);
-
And then, in your ionic’s “config.xml”, you can configure and override the scan periods in the preference.