kontaktio / kontakt-ios-sdk

This SDK makes it easy for you to configure, monitor, and securely update Kontakt.io Beacons through our Kontakt.io API.
http://developer.kontakt.io
Other
48 stars 9 forks source link

beaconManager:monitoringDidFailFor:withError fails with While Using the App location permission in iOS 10 & 11 #52

Closed ghost closed 6 years ago

ghost commented 6 years ago

On ios10-11 if app receive While Using the App location permission, KTKBeaconManager delegate fails in

func beaconManager(_ manager: KTKBeaconManager,  monitoringDidFailFor region: KTKBeaconRegion?, withError error: Error?) {
}

with kCLErrorDomain error 4

In case of Always Allow app works correct. In both cases we only change location permission. All keys for requesting permission already added into info.plist.

stoprocent commented 6 years ago

Hi @sacred0x01

I think you have answered your own question :)

Error Code 4 is regionMonitoringDenied

A constant indicating that access to the region monitoring service was denied by the user.

If you look here kCLAuthorizationStatusAuthorizedWhenInUse

This authorization does not allow you to use APIs that could launch your app in response to an event, such as region monitoring and the significant location change services.

ghost commented 6 years ago

So what should we do in case of this permission? No way to use it with our beacon feature?

stoprocent commented 6 years ago

You can range beacons in the foreground and determine beacons states or use KTKDevicesManager together with The bluetooth-central Background Execution Mode

ghost commented 6 years ago

Fix me if i am not correct, but You can range beacons in the foreground but this is what we doing according to you docs:

beaconManager = KTKBeaconManager(delegate: self)
...
beaconManager.requestLocationAlwaysAuthorization()
...
beaconManager.startMonitoring(for: region)

Or we should somehow skip region monitoring and replace it with something else?

ghost commented 6 years ago

Oh, finally got the idea: use startRangingBeacons. Thanks)