API key not appending to ReverseGeocode request

Hi everyone!

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

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

Hi Olivier!

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)
    }
    (...)

Let us know if you’ll have more questions.

2 Likes

Hi @szczepam thanks for that answer!

The Reverse Geocode is working great now. Im wondering if you would have any tips on how I could achieve the following?

I want to continuously check the posted SpeedLimit of the road a user is travelling on.This can be achieved using the above code, I can simply pass in the Lat and Long with each location update. The problem with this though is I have already almost eaten though the 2k free requests with only driving about 30km.

When we scale this up to cover our 3 thousand users will cost us an absolute fortune! So would you know of any way to drastically reduce the number of requests made?

One idea we did have was to only check for location every 50m or so… But even still that will use a crazy amount of requests

I really appreciate your time and help with this

Thanks
Oliver

Hi.

Checking location less often is one of the ideas. Maybe it would be also good to connect it with CrossStreet Lookup API and rely not only on a distance but also on the intersections.

Regards,
Mateusz