My Swift-iOS app is meant to show the user\'s location on a map. However, the XCode debug console tells me I need to ask permission to show the user\'s location. I think, I
You need to use requestWhenInUseAuthorization and also need to create a value at yourapp-Info.plist named NSLocationWhenInUseUsageDescription
As David Berry, Cayke Prudente and Levi Johnson mentioned, I just needed to add NSLocationAlwaysUsageDescription
to my Info.plist
file. To understand more WHY I needed this, I went for further documentation and I'm sharing here, as it can help others the same way they helped me.
The user prompt contains the text from the NSLocationWhenInUseUsageDescription key in your app’s Info.plist file, and the presence of that key is required when calling this method.
https://developer.apple.com/documentation/corelocation/cllocationmanager/1620562-requestwheninuseauthorization
As of iOS 8 you have to call one of the request... functions and add the appropriate entry to your Info.plist file, either NSLocationWhenInUseUsageDescription
or NSLocationAlwaysUsageDescription
.
For more information, see the reference here
Make sure that
Debug > Location
.Debug Area:
I use NSLocationAlwaysUsageDescription
with the value as the text that will pop up when asking for permission, such as
"I would like permission to spy on you 24/7"
I would also add NSLocationWhenInUseUsageDescription
with the value as the message.