简体   繁体   English

解析localoint swift没有获得当前位置

[英]Parse geopoint swift not getting current location

trying to use parses PFGeoPoint.geoPointForCurrentLocationInBackground to get current location when i send something to my backend. 尝试使用解析PFGeoPoint.geoPointForCurrentLocationInBackground来获取当我向后端发送内容时的当前位置。 The code looks like 代码看起来像

NSLog("Before block")
    PFGeoPoint.geoPointForCurrentLocationInBackground {
        (geoPoint: PFGeoPoint!, error: NSError!) -> Void in
        NSLog("inside block")
        if !error {
            // do something with the new geoPoint
        }
    }

and I never get my inside block on the console. 我从来没有在控制台上得到我的内部块。 I have Core Locations Framework installed and it allows me to do something like 我安装了Core Locations Framework,它允许我做类似的事情

let point = PFGeoPoint(latitude:40.0, longitude:-30.0)

If it helps i am not being requested for user location when I do the call above. 如果在我上面的呼叫时,我没有被要求提供用户位置。

 NSLocationWhenInUseUsageDescription

and

NSLocationAlwaysUsageDescription

Put this keys in the info.plist 将此键放在info.plist中

I had a similar issue in objective c. 我在目标c中遇到了类似的问题。 I placed this key in my info.plist 我把这把钥匙放在我的info.plist中

NSLocationWhenInUseUsageDescription NSLocationWhenInUseUsageDescription

It worked fine in iOS 7 without that key but in 8 it won't. 它在没有那个密钥的iOS 7中运行良好,但在8中它不会。

Parse will most likely handle this situation when 8 is out. 当8出局时,Parse很可能会处理这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM