Ravi Ojha
Ravi Ojha

Reputation: 1480

Error in ios 8 for current location

I am using this code for current location in ios 8, but this give the error on 3rd line error is "no known class method for selector' requestAlwaysAuthorization".

  if ([CLLocationManager respondsToSelector:
       @selector(requestWhenInUseAuthorization)]) {
      [CLLocationManager requestWhenInUseAuthorization];
   }

Upvotes: 0

Views: 69

Answers (1)

WhiteLine
WhiteLine

Reputation: 1991

In iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.

Add two keys in the plist

<key>NSLocationAlwaysUsageDescription</key>
<string>Your message goes here</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your message goes here</string>

(Leave the values empty to use the default messages)

Upvotes: 1

Related Questions