DidEnterRegion only called if requestAlwaysAuthorization is called. Beacons

833 Views Asked by At

didEnterRegion and didExitRegion are only called after I request and allow Always Authorization for CoreLocation

Even if I request WhenInUseAuthorization didExit and didEnter won't be called

How am I supposed to trigger ranging of beacons if I can't get this to be called?

Any solutions?

UPDATE

Apple rejected my app for calling requestAlwaysAuthorization()

Here is my question submitted to the review team this morning:

In order to monitor beacon regions (a very core functionality of beacons used in many apps including some Apple apps) you need to have the user allow the app to access location even when not using the app. I am using .requestAlwaysAuthorization to enable beacons to monitor in the background. Why won't this be allowed?

Apples response this afternoon on iTunes Connect:

Thank you for your feedback. However, background location is not necessary for iBeacon functionality. Therefore, it is necessary to remove the background location feature before resubmission.

So if beacons are supposed to automatically monitor regions in the background, but I can't ask permission for background monitoring and beacons won't monitor in the background unless I get permission, how then am I supposed to monitor regions in the background??

3

There are 3 best solutions below

8
On BEST ANSWER

Do you mean when the app is in the background? If so, then it is true that didEnterRegion and didExitRegion don't get called with only a WhenInUseAuthorization. They will only get called when you app is in the foreground and you enter/exit a region

0
On

Unfortunately, you must request Always Allow location access to use region monitoring with beacons.

From the docs:

Important

Apps must have always authorization to use region monitoring, and they must be configured with the Location updates background mode to be launched.

https://developer.apple.com/documentation/corelocation/determining_the_proximity_to_an_ibeacon

2
On

background location is not necessary for iBeacon functionality. Therefore, it is necessary to remove the background location feature before resubmission.

It seems that your app was rejected because of the Background Modes (specifically, the "location updates" mode), no the "always" authorization. You don't need any Background Modes enabled for beacon monitoring to work in the background, the "always" authorization is enough.

Simply disable the Background Modes capability in your project settings and you should be good!