我在iOS 7上运行良好的应用程序无法与iOS 8 SDK一起使用.
CLLocationManager没有返回位置,我也没有在设置 - > 位置服务下看到我的应用程序.我在这个问题上进行了谷歌搜索,但没有出现任何问题.可能有什么不对?
我在Xcode6中创建了新项目,并将旧文件添加到此项目中(旧文件在xcode5中创建),但是发生的事情是一切正常,但是"didUpdateToLocation"委托方法没有调用,我还使用了"didUpdateLocations"委托方法但两个都没有工作.我从旧文件中使用过代码,但核心位置框架已从xcode6添加,我不知道我缺少什么,请任何人指导我获得解决方案.
我只想按需跟踪用户当前位置。我只需要初始位置,不需要持续更新。我认为最好的方法是向用户发送静默通知,以便一次获取用户的当前位置。接收静默通知效果很好,但 LocationManager 无法对位置进行初始修复。我的位置管理器委托类正常实例化,但在调用位置管理器方法 startUpdatingLocation() 后的任何时候都不会触发 didUpdateLocations 函数。当应用程序从 AppDelegate:didFinishLaunchingWithOptions 正常启动时,LocationManager 会毫无问题地更新用户位置。
我正在 Xcode 6.3.2 到 iOS 8.3 上进行开发
我的 AppDelegate:DidReceiveRemoteNotification 看起来像这样:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) {
var bgTask = bgManager()
bgTask.registerBackgroundTask()
LocManager.locationMngr.startUpdatingLocation() // LocManager is global variable
let delayInSeconds = 8.0
let popTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delayInSeconds * Double(NSEC_PER_SEC)))
dispatch_after(popTime, dispatch_get_main_queue()) {
println(LocManager.updated)
bgTask.endBackgroundTask()
handler(UIBackgroundFetchResult.NewData)
}
}
Run Code Online (Sandbox Code Playgroud)
我首先尝试仅使用以下行:
LocManager.locationMngr.startUpdatingLocation()
Run Code Online (Sandbox Code Playgroud)
但当它不起作用时,我添加了后台任务和dispatch_after,以确保我的位置管理器有足够的时间在终止之前检索第一个位置更新。
这是 LocationManager 类:
class LocationManager: NSObject, CLLocationManagerDelegate {
let locationMngr:CLLocationManager
var coord:CLLocationCoordinate2D
var …Run Code Online (Sandbox Code Playgroud) core-location apple-push-notifications appdelegate swift ios8.3