8

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?

Bryan
  • 1,438
  • 3
  • 15
  • 24

3 Answers3

17

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:

n13
  • 6,843
  • 53
  • 40
  • 3
    I think this would be more prominent in their documentation as it will not work at ALL in iOS8 without these. THANKS so much for this post! – rckehoe Oct 26 '14 at 15:32
3

UPDATE:

Fixed


Got back with Facebook on this issue.

Geopoint

Similar question posted here: Parse geopoint swift not getting current location

Will update as they respond back.

Community
  • 1
  • 1
Bryan
  • 1,438
  • 3
  • 15
  • 24
0

Check this:

Click at your Project Targets/Build Phases/Link Binary With Libraries/

This file must be listed: CoreLocation.framework 
if there is not click Add and select it from the list.

In your ViewController.swift check this:

import CoreLocation

class ViewController: UIViewController, CLLocationManagerDelegate {

/Supporting Files/info.plist <- Click on this file

Click on + to add: Key: NSLocationAlwaysUsageDescription Type: String Value: Add a description

Click on + to add: Key : NSLocationWhenInUseUsageDescription Type: String Value: Add a description

check IOS Simulator /Debug/Location/Apple here you must select something (none => error)

Ajochope
  • 11
  • 3
  • 1
    You could add a few words around this rather than just files and command titles. I understand what you say needs to be done, but most people probably won't... – Wain Feb 14 '15 at 16:04