-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observables does not send updated value when app enters foreground #24
Comments
By the way this is the wrong way to do subscription. you should use manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation() |
Hi, Why do you need to startUpdatingLocation to know if location services are on? this is a static method of CLLocationManager and shouldn't be related between them. Using the example I project config, I also see that sometimes it's not deliver in background when you go to settings and change locations services on/off |
@bobgodwinx I'm referring to the example on line 85
|
@havard024 I think I now understand what you're trying todo here. Correct me if I am wrong.
|
@bobgodwinx Yes exactly and when you put the app in foreground again, there is no event to notify that the location service is disabled |
@havard024 Here is my advice: The API is actually working as expected. The event you are expecting is not emitted because
manager.rx
.didChangeAuthorization
.debug("didChangeAuthorization")
.subscribe(onNext: { e in
let a = e.status
switch a {
case .denied, .notDetermined, .restricted:
print("Stay there blocking the screen! don't move")
default:
print("Stop blocking the screen let him enter now")
}
})
.disposed(by: bag) Let me know if this helps. |
Our app requires the user to allow access to the devices location.
To handle this we first check if the location service is enabled, if it's not enabled we present a view controller letting the user know that he / she needs to enable the location service to continue.
The user would then most likely put the app in the background, enable the location service, open the app again.
In the view we present to the user when location service is disabled, we would like to automatically detect if the location service has been enabled, the code below is our attempt to react to the
isEnabled
event.When we test this by putting the app in the background then to foreground, no event is triggered.
Is this something the library is designed to handle?
If not, how would one go about creating this functionality in an app?
The text was updated successfully, but these errors were encountered: