Search code examples
swiftwatchkitbetawatchos-4

Whats the proper way to get the ETA in WatchKit


Inside iOS It's possible to get the user ETA using MKDirectionsRequest to get the user ETA from a place to another, but how to get this data inside watchkit without asking for the iOS app? It's important to the watch app be full standalone, so communication with the iOS it's not an option.

Im developing to watchOS series 2 with watchOS4 beta 6


Solution

  • Sadly routing is not available in WatchKit at the moment and according to the documentation, it won't be available in watchOS4 either.

    Even if requesting data from the iOS app would be an option for you, I don't think it is the right way to go. For this to work, you would need to have your iOS app running at least in the background, which isn't always feasible.

    However, a good alternative is to use the Google Maps Directions REST API. It works perfectly on watchOS and you need less network requests to achieve the same goal than if you used Apple Maps. For instance, you don't need to do any geocoding, you can use coordinates for the destination and an address or even the name of a place mark (such as an airport) as the starting point. Using MapKit you would first need to geocode the address before you could get destinations. You can also get both an ETA and the directions in the same request using the Google Maps Directions API, for which you would need two requests using MapKit.