I'm programming in Swift, iOS 9/10, iPhone 5C+.
App is geolocation based so user must have location enabled so send any request to server. There are 2 situations I can't solve:
a) Even when I enable location at the very start it often happens to not being able to send request to server because error is: Location is not enabled or Allow your location.
b) App has a map and when I open the map it finds my location (sometimes not, it throws the same error: allow your location) and when I leave my app opened for a few seconds without touching it the location dot goes gray, like location turns off
This is code I'm using to check the status:
App is geolocation based so user must have location enabled so send any request to server. There are 2 situations I can't solve:
a) Even when I enable location at the very start it often happens to not being able to send request to server because error is: Location is not enabled or Allow your location.
b) App has a map and when I open the map it finds my location (sometimes not, it throws the same error: allow your location) and when I leave my app opened for a few seconds without touching it the location dot goes gray, like location turns off

This is code I'm using to check the status:
Code:
if CLLocationManager.authorizationStatus() == .AuthorizedWhenInUse {...}