Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse.com PFGeoPoint.geoPointForCurrentLocationInBackground not doing anything

I'm using Parse.com iOS SDK, and I need the current location of the user, so I'm using the function PFGeoPoint.geoPointForCurrentLocationInBackground(...).

The problem is: the block in the argument list is never called. Here is my code:

PFGeoPoint.geoPointForCurrentLocationInBackground() {
    (point:PFGeoPoint!, error:NSError!) -> Void in

    NSLog("Test log 1") // Never printed

    if point != nil {
        // Succeeding in getting current location
        NSLog("Got current location successfully") // never printed
        PFUser.currentUser().setValue(point, forKey: "location")
        PFUser.currentUser().saveInBackground()
    } else {
        // Failed to get location
        NSLog("Failed to get current location") // never printed
    }
}

Any idea?

like image 303
Bryan Avatar asked Aug 22 '14 06:08

Bryan


1 Answers

I had the same problem. It's fixed in Parse 1.4.0.

Also you need to add the following key/value pair to your app's info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>We want to send your location data to the NSA, please allow access to location services. (replace this text with whatever you want the dialog to say)</string>

References:

  • Parse SDK for iOS 8
  • CLLocationManager in iOS 8 - use of NSLocationWhenInUseUsageDescription
like image 145
n13 Avatar answered Dec 15 '22 00:12

n13