iOS app doesn't ask for location permission

廉价感情. 提交于 2019-11-29 06:39:22
David Berry

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

Update

Make sure that

  1. the map is centered on the simulated location.
  2. Also make sure that a location is simulated. Either do so in the Debug Area (down below) of XCode (see image), or do it in the simulator under Debug > Location.

Debug Area:

You need to use requestWhenInUseAuthorization and also need to create a value at yourapp-Info.plist named NSLocationWhenInUseUsageDescription

Levi Johnson

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!