1

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??

YichenBman
  • 5,011
  • 8
  • 46
  • 65

3 Answers3

1

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

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Apple rejected my app for calling `requestAlwaysAuthorization()` – YichenBman Aug 06 '15 at 02:49
  • Here is my question: 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 doesn't won't this be allowed? – YichenBman Aug 06 '15 at 02:50
  • 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. – YichenBman Aug 06 '15 at 02:51
  • According to the docs, apps can monitor beacon regions in the background. The only way, as I mentioned in my original post, to enable background monitoring is by requesting AlwaysAuthorization, however I am being rejected for requesting it. How then am I to receive notifications when a user walks inside a region – YichenBman Aug 06 '15 at 02:52
  • I don't think using requestAlwasysAuthorization is the precise reason Apple rejected the app -- this is allowed. As @heypiotr mentioned in his answer, Apple will reject apps based on background modes in the plist. Perhaps this is why you got the rejection. – davidgyoung Aug 06 '15 at 13:56
  • I added a clarification to heypiotr answer. I did not have location background modes enabled, and included an image of the capabilities page in my app with location disabled to confirm thats not what they were asking for. I Then I asked my question (see update in my post). Their response to the clarification that I do not have background location updates enabled, though I do requestAlwaysAuthorization was that "iBeacons do not require background location" and it will be "necessary to remove background location." – YichenBman Aug 06 '15 at 16:57
  • it seems as though I'm either dealing with someone who doesn't know what is going on, or requestAlwaysAuthorization is no longer allowed. Since you and others and documentation (that I have now provided to apple and am awaiting a response) all agree that requestAlwaysAuthorization is allowed I've accepted your answer and will await the review teams response. – YichenBman Aug 06 '15 at 16:59
  • Different reviewers often yield different results. It might help to explain why your app needs to look for beacons in the background. Again, I have had several apps approved with requestAlwaysAuthorization, so unless it is a very new change in policy, this may just be a case where you need to satisfy an individual reviewer. – davidgyoung Aug 06 '15 at 17:15
0

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!

heypiotr
  • 2,139
  • 2
  • 15
  • 22
  • In the question I submitted I included a picture of the capabilities/background modes with location unchecked to make sure we were on the same page. Their response came after the clarification that location updates were indeed checked off – YichenBman Aug 06 '15 at 15:44
  • Gotcha; quite likely then that either the reviewer isn't clear about what is and isn't required to have beacons working in the background; or doesn't understand why your app needs to use beacons in the background, like David mentioned. – heypiotr Aug 07 '15 at 08:13
0

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

Ric Santos
  • 15,419
  • 6
  • 50
  • 75