Multiple ESTBeaconManager(s)

I’m wondering what the repercussions are of instantiating ESTBeaconManager in AppDelegate AND again in a ViewController. I want to have background processing for didEnterRegion (via AppDelegate)…but also in a specific view controller (while that view is visible) I want the ability to determine the closes beacon to allow the user to save that beacon’s major/minor for later purposes.

Should I use didEnterRegion and didExitRegion in my AppDelegate to write to a global variable that my VC looks at? Or is it ok to instantiate a second ESTBeaconManager object to do it all in my VC (in addition to the App Delegate). I assume the former (just once in the App Delegate), but wanted to see what the community thinks. Thanks!

It’s okay to use multiple beacon managers, there’s just one thing to keep in mind—monitored regions are shared system resources, and will trigger all of your beacon managers.

Example:

AppDelegate’s Beacon Manager starts monitoring for region A.
VC’s Beacon Manager starts monitoring for region B.

When you come in range of the region A, both the AppDelegate’s Beacon Manager and the VC’s Beacon Manager will have their “didEnterRegion” triggered, with the region A.

Same for region B.

So if you only want to handle enter/exit events for region A in the AppDelegate, and region B in the VC, you’ll need to filter out unwanted regions.

1 Like