Search code examples
iosswiftcllocationmanageribeaconcore-bluetooth

How to use framework func in didFinishLaunchingWithOptions AppDelegate?


Thanks for the Tip @davidyoung need one more help

I have a similar problem that showed in link bellow and I tried it's working but Here in App delegate you are initializing new location manager instance .. Is there any way that I can do same thing in my framework project(I have location manager initialization in sdk framework) so that developer can access that func in order to start again..

MY IOS App is not getting any region updates when ever I restart my device any ideas?


Solution

  • If you build an iOS Framework to detect beacons, the same rules apply as if you write code in an iOS app. You will get auto-launch behavior on beacon region entry/exit under the following conditions:

    1. Bluetooth is on and Location is enabled
    2. Use CoreLocation to successfully obtain background permissions with locationManager.requestAlwaysAuthorization()
    3. Call locationManager.startMonitoring(for: beaconRegion) or a CLBeaconRegion
    4. Set up your CLLocationManagerDelegate to receive the callbacks somewhere in the execution thread triggered by didFinishLaunching of the AppDelegate.

    For this to work with auto-launch, it is critical that items 3 and 4 execute as a result of that didFinishLaunching call. But they don't actually have to appear inside that method itself, they can be executed inside the framework.

    What you must do is instruct users of your framework to put a method call inside didFinishLaunching that calls your framework so it can take care of the bottom two items above.