© 2013 All rights reserved.
5

iOs 6: How to open the native application with navigation

Ios version 6 and higher deprecated Google Maps. How to properly open and navigate user to the target object in a native application?


MKMapItem class

We can use MKMapItem class, but this class was publicly available starting with iOS 6.0.
In this case you typically check whether that class is nil. Unfortunately, this test is not correct accurate for MKMapItem. Although this class was available with iOS 6.0, it was in development prior to that. But Apple does not recommend using it in earlier versions
Correct test might loog like the following:

We can test weather the class object is not nill and openMapsWithItems:launchOptions: class method exists.
If everything is ok, you can use this class, otherwise open Google Maps in browser.

 

How to use MKMapItem

 

As you can see in the following code, using is simple.
We create start and end coordinates and open maps with navigation.

Comments (5)

Michal Sänger

Better to test as first if Google maps app is available, default Apple maps sucks.

    admin

    Google Maps in the browser are always available. This is a demonstration when we need use native maps.

Michal Sänger

Btw why do you create CLLocationCoordinate2D coordinate_end and CLLocationCoordinate2D coordinate_start when you already have CLLocationCoordinate2D end and CLLocationCoordinate2D start?

admin

Yes, you’re right, you do not have to do a new instance, I wrote this more for better readability in code.

Hey Hi,

When i tried with the above i am getting error like “A route to the nearest road can not be determined “. Could you please explain me why
/?

Leave a Reply to Hanu Cancel Reply

About
Hi, i am programmer from the Czech Republic. I love web development (Ruby, Ruby on Rails, PHP, Nette) and iOS development (Objective-C, Cocoa).
To cooperate, here is my phone:
+420 608 836