Reputation: 41
Pick Place error The operation couldn’t be completed. The Places API could not find the user's location. This may be because the user has not allowed the application to access location information. How to solve it?
Upvotes: 3
Views: 4808
Reputation: 41
So what I understand from your question, you are trying to fetch the users current location, but you are getting the above mentioned error.
In iOS it is mandatory to request permission from user to access the user's current location. You can request the permission by creating an instance of the CLLocationManager & then calling the appropriate method. The appropriate method can be based on your requirement whether you want to use the location services while the app is running or always. So here is how you do it:
let locationManager = CLLocationManager()
// For getting the user permission to use location service when the app is running
locationManager.requestWhenInUseAuthorization()
// For getting the user permission to use location service always
locationManager.requestAlwaysAuthorization()
After that make sure to add an appropriate key to the Info.plist file as follows:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location is required to show suggestions</string>
OR
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location is required to show suggestions</string>
The string for the key is optional. But it recommended to include a proper string which describes why your app wants to access user's location.
Upvotes: 1