Monitor beacons in the background iOS
I am developing an iOS app in Swift that monitors beacon events. This is my first real lighthouse.
I am using Estimote beacons, but not using the Evaluation SDK. I am using main layout and CLLocationManager with didExit and didEnter events.
I only listen to beacons that are registered with the current user who has signed up to my application. For example, John Doe can be registered with beacons A and B, while Mary Sue is only registered for beacon C. I am experiencing a lot of false leaves and wondering, not because of where I am implementing my code.
I understand that there is a default 30 second delay when checking for a vacation event, but I am experiencing periods over 30 seconds with no empty range bluetooth signal. Perhaps a 30 minute window rather than 30 seconds for a validation check?
Since the user must be logged in to know which beacons to track, the location manager is in the user's default profile view controller. I successfully interact with the beacon even when the phone is locked, but it is not compatible. I am concerned that I know that the view controller itself is paused / activated at the discretion of the iPhone and may be identified by flaws in my logic.
Should all location-oriented code go in the app's delegate file? If I implement the protocol from my profile's profile to the application delegate, I can create it there inside the application delegate and then get the beacon data later, once the user is signed.
I have struggled to find an "iOS beacon convention" in my research, just examples that give some results. Not too sure what actually counts as good practice.
Thank!
source to share
Typically a software filter is used to ignore parasitic region exit events if a write event occurs soon.
To make this independent of any ViewController, it is essential that the logic is run by the AppDelegate. Two options:
-
Put the scope of control callbacks and filtering logic directly into the AppDelegate. This is suitable for small and simple applications.
-
Put the callbacks and filter logic in a custom class and initialize it from the AppDelegate didFinishLaunching method. ... This is the best approach for larger, more complex applications to keep the AppDelegate simple and clean.
In any case, it is important to initiate the start of monitoring using the didFinishLaunching method. ... This will ensure that CoreLocation is set up correctly in the background if your app automatically launches by region navigation.
source to share