0
votes

I'm currently trying to get an app-screen running that displays user's location (may be hardcoded)

This is what I have so far:

Link to img of code

I get the Error:

Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

I did add the NSLocationWhenInUseUsageDescription String in the info.plist

Anyone can help me ?

1
We don't like codedumps in the form of a picture...please fix that. - rene
As I know self.mapView.showsUserLocation = YES; is also calls the delegate method for Location Changes and since before you get the authorization, you are trying to get the user's location. have you tried moving that below authorization request? - iremk
replacing self.mapView.showsUserLocation = YES; beneath the requestAuthorizations still gives same error - UserUser123
post your code, not a picture of, so that someone can paste and try out options for solutions if they have to. - crafter
I found the problem. In the simulator is default selected to "None Location" If you select one first (For Example Apple base). It works fine and asks the persmission - UserUser123

1 Answers

0
votes

It looks like you have not added keys (NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription) to your info.plist file. Please refer to this tutorial and see if your problem is resolved. I am sure this will be helpful.