Parse.com PFGeoPoint.geoPointForCurrentLocationInBackground没有做任何事情 [英] Parse.com PFGeoPoint.geoPointForCurrentLocationInBackground not doing anything
本文介绍了Parse.com PFGeoPoint.geoPointForCurrentLocationInBackground没有做任何事情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Parse.com iOS SDK,我需要用户的当前位置,所以我正在使用函数 PFGeoPoint.geoPointForCurrentLocationInBackground(...)。
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
}
}
任何想法?
推荐答案
我有同样的问题。它已在Parse 1.4.0中修复。
I had the same problem. It's fixed in Parse 1.4.0.
此外,您还需要将以下键/值对添加到您应用的info.plist中:
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>
参考文献:
- Parse SDK for iOS 8
- CLLocationManager in iOS 8 - use of NSLocationWhenInUseUsageDescription
这篇关于Parse.com PFGeoPoint.geoPointForCurrentLocationInBackground没有做任何事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文