Search code examples
tomtomtomtom-android-sdk

API key not appending to ReverseGeocode request


For some reason my API key doesn’t seem to be added to my reverse Geocode request.

enter image description here

The key is correctly in my info.plist , I’ve tried adding every other key to my plist also but this still isn’t working.

Here is the request im attempting

var coordinate = CLLocationCoordinate2D()
coordinate.latitude = 54.966682
coordinate.longitude = -7.730234

let query = TTReverseGeocoderQueryBuilder.create(with: coordinate).withReturnSpeedLimit(true)
    .build()
reverseGeocoder.reverseGeocoder(with: query)

Any help is greatly appreciated!

Thanks Oliver


Solution

  • Everything looks fine. The API key is hidden inside logs.

    Note that using reverseGeocoder(with: query) method you need to conform to the TTReverseGeocoderDelegate protocol in order to get the results out. It can be easily done by adding a few lines of code:

    import TomTomOnlineSDKSearch
    import TomTomOnlineSDKRouting
    
    class MainViewController: UIViewController, TTReverseGeocoderDelegate {
    (...)
    let tomtomRGeoAPI = TTReverseGeocoder()
    
    func reverseGeocoder(_ reverseGeocoder: TTReverseGeocoder, completedWith response: TTReverseGeocoderResponse) {
        NSLog("success")
    }
    
    func reverseGeocoder(_ reverseGeocoder: TTReverseGeocoder, failedWithError error: TTResponseError) {
        NSLog("error")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tomtomRevGeoAPI.delegate = self
    
        var coordinate = CLLocationCoordinate2D()
        coordinate.latitude = 54.966682
        coordinate.longitude = -7.730234
    
        let query = TTReverseGeocoderQueryBuilder.create(with: coordinate).withReturnSpeedLimit(true)
            .build()
        self.tomtomRevGeoAPI.reverseGeocoder(with: query)
    }
    (...)
    

    Regards, Mateusz