Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLFloor returning nil in iOS 8

So I am trying to get CLFloor in Core Location to give me data instead of returning nil in Swift, but I have not been able to. I have tried my own code and the following from NSHipster:

import CoreLocation

class LocationManagerDelegate: NSObject, CLLocationManagerDelegate {
    func locationManager(manager: CLLocationManager!, didUpdateLocations locations: AnyObject[]!) {
        let location: CLLocation? = locations[0] as? CLLocation
        if let floor: CLFloor? = location?.floor {
            println("Current Floor: \(floor?.level)")
        }
    }
}

let manager = CLLocationManager()
manager.delegate = LocationManagerDelegate()
manager.startUpdatingLocation()

Does anybody know how to make this work on a device or in the simulator, I'm sure the answer would benefit a lot of people. If anyone knows of any good resources on this or CLVisit, that would also be helpful.

like image 783
tfrank377 Avatar asked Jun 21 '14 21:06

tfrank377


3 Answers

As far as I understand what was said in WWDC session 708 - Taking Core Location Indoors, You need to manually register and set up the particular venue on the new Apple's Maps Connect page in order to get the floor information in iOS.

Therefore, it seems there is no way that the floor info is provided automatically (e.g. based altitude information from on GPS) for an arbitrary venue.

like image 150
Tom Kraina Avatar answered Nov 19 '22 18:11

Tom Kraina


based on these 2 links from Apple's website

CLFloor Ref

CLLoaction Class Ref

Discussion If floor information is not available for the current location, the value of this property is nil.

I'm not expert in swift but i think returns nil possibly means that there is no floor information at that location.

like image 32
iEmad Avatar answered Nov 19 '22 16:11

iEmad


I don't think iOS will magically tell you the floor level from what I understand https://developer.apple.com/videos/wwdc/2014/?id=708. You need to somehow get that number in another way. E.g. you may capture some iBeacon signal and from that download the floor level number, or swipe on your screen to find the correct floor map you are on?

like image 1
leonard Avatar answered Nov 19 '22 18:11

leonard