I'm trying to get the user's location in a Today Extension and I'm hitting a dead end.
On an OS X app, when you call locationManager.startUpdatingLocation()
, a dialog pops up asking if you want to let the app use your location. In the Today view, though, nothing comes up at all after calling this method, and my delegate doesn't get called for didUpdateLocations
or for didFailWithError
. CLLocationManager.authorizationStatus()
returns NotDetermined
. I have been looking at Apple's docs on Today Extensions and am not seeing much about permissions or about getting the user's location.
How are we intended to get the user's location in an OS X Today Extension?
Edit: One thing to note is that CLLocationManager.locationServicesEnabled()
returns true
on my OS X app and false
on my Today Extension. What does this mean, and how can I change this?
OS X Today Extensions use an App Sandbox by default and you need to check the right boxes to allow the Today Extension to do things like get the user's location and make network calls.
Go to your project settings in Xcode, select your OS X Today Extension target, click the Capabilities tab, expand the App Sandbox section, and check the boxes for the capabilities you want (in my case, Location and Outgoing Network Connections).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With