-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make RegionBootstrap easier to use #151
Comments
A few ideas for improvements:
|
Why MUST the RegionBootstrap be created inside a custom Application class? I'm trying to add background beacon detection into a cordova plugin (which should not require taking control of the Application class). What's the technical reason for not supporting creating RegionBootstraps within a Service? Details here: petermetz/cordova-plugin-ibeacon#141 |
Good question, @Crashthatch. The The At the same time the If you want to construct the
|
It shouldn't be too hard to restructure the code that the Beacon Library is able to run autonomously as its own Instead of the developer being responsible for pushing the configuration such as for what kind of region to monitor, the service has to detect that itself. This could be done by making done by making the service abstract or detecting this information using reflection. I think that the public interface also will become simpler, since users of the library no longer have to bind with services or have to change state in static fields/singletons themselves as for example is the case for I could work on a prototype if you're interested somewhere in the coming week. |
Understand that this library already does run autonomously as a service. That's what the The purpose of the In terms of simplifying this and making it easier to use, I'm open to suggestions for a design. I'd like any new API design to meet the following goals:
One thought I had is to store any defined |
I like that design- takes a lot of the maintenance out of the user's hands and puts it into the Altbeacon library for the 90% use-case where the user just wants to resume monitoring for beacons on boot / after app is closed. I don't see using an abstract class instead of an interface as a huge problem. Only possible situation might be where someone would need their notifier to extend another base-class (and so be unable to also inherit from our abstract BootstrapNotifier class)? Do you think this is a common occurrence? Are there any other classes in the altbeacon library that a notifier might want to extend for other functionality (I'm not that familiar with the rest of the library)? I think we'd also need to persist some of the BeaconManager settings to the nonvolatile storage too (like the beaconParsers and fore/background time settings too) so that we can restore the same search parameters after reboot. Possibly could use .scanOnBoot / .stopScanningOnBoot methods on the BeaconRegion to add/remove it from the shared preferences, enabling / disabling search for that region on boot. This is backwards compatible with RegionBootstrap as regions would still be created as non-resuming-on-boot until .scanOnBoot was called (and RegionBootstrap's constructor could just wrap this call). Maybe it even makes sense to put these into MonitorNotifier instead and remove BootstrapNotifier all togther? I haven't done a huge amount of development with beacons on iOS, but it was my impression that iOS just starts monitoring in the background automatically with no further action from the user, and makes the same callbacks as it does when the app is running. |
Yes, I agree that the other settings you mention would also have to be saved to non-volatile storage. Here's the thing about how iOS does it: Every application in iOS has an We could do the same on Android with a custom |
Hi, I'm completely against an abstract Application class. This also assume I know the region to scan / beacon layout at compile time. I wish the boot receiver was something I had to register in the manifest, so that I could implement my own version of it with my initialization and detaching the beacon initialization from the Application class. I receive the region to parse from a remote service and I sync it locally in a local database. Thus I need to initialize beacon in background and at runtime. Furthermore: I think the way the library currently work for handling background events is wrong: it should use PendingIntent and call them when the app enter a beacon zone. Look at the FusedLocation API by google. It has an online api where you register a listener and you had to keep a static reference to that listener all the time (this is meant to be used from an Activity, or UI anyway). Then there's the background implementation that requires a PendingIntent. After registering a PendingIntent your Service/Activity can be stopped and the intent is sent to the app waking it up. Also: if you run a service in background and want it to consistently keep running all the time you have to use wake lock permission to avoid the device going to sleep. So an always running service is a bad thing. You should instead use Intent and Alarms (or new Job Sheduler) to wake your service up and check for beacons. This means every configuration for the beacon must be stored somewhere independent to app initialization. |
closed per #1046 |
In order for RegionBootstrap to work properly, it must be put in the Application class onCreate method, and must be instantiated before any binding operations are done on the BeaconManager. This needs to be simplified so it is harder to misconfigure.
The text was updated successfully, but these errors were encountered: