didEnterRegion works in foreground but not background or other VCs

后端 未结 4 601
夕颜
夕颜 2020-12-16 03:56

If the app is running and the CLLocationManagerDelegate class is the foreground (i.e. visible) then the didEnterRegions triggers and I get both the NSLog as well as the Aler

4条回答
  •  长情又很酷
    2020-12-16 04:51

    A friend of mine wrote up a nice tutorial on using geofencing that might help clear up some issues you are having.

    Get started with geofencing

    There are plenty of examples online and here on SO. Start out small and work your way up. Once you start getting your callbacks, you can start expanding things out to your other view controllers.

    UPDATE

    As explained in the comments the benefits of creating a singleton class to control your location manager and delegate methods. By using a singleton, you prevent the possibility of getting multiple calls to your delegate methods. You can prevent this by careful coding, but using a singleton does this for you. This is also a nice class to handle all the work needing to be done by your delegate methods.

提交回复
热议问题