21

Anyone aware how to check whether Apple Maps is installed or not? I could not find anything in the docs.

With iOS10 users can delete the Apple Maps application. While for Google Maps we can use UIApplication.shared.canOpenURL() to check if it's installed. I am not aware of such a thing exists to check for Apple Maps.

Of course one can check if opening a MKMapItem with mapItem.openInMaps() fails - but that does not help for checking in advance.

tcurdt
  • 14,518
  • 10
  • 57
  • 72
  • I'm going to guess that you can form a map link (https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html#//apple_ref/doc/uid/TP40007899-CH5-SW1) and call `canOpenURL`. – matt Sep 20 '16 at 20:27
  • [Related](http://stackoverflow.com/a/21983980/620197)? You could possibly combine that with `[UIApplication canOpenUrl]`. – Mike D Sep 20 '16 at 20:27
  • Can open URL `http://maps.apple.com` API does not work? https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html – Evgeny Karkan Sep 20 '16 at 20:29
  • 2
    `canOpenUrl(http://maps.apple.com)` also returns `true` if the Maps app is not installed. – tcurdt Sep 20 '16 at 20:40
  • @tcurdt It seems pre-installed apps are not actually deleted: https://support.apple.com/en-gb/HT204221 – Mike D Sep 20 '16 at 21:48
  • @MikeD MapKit fails to open the location in case the app is deleted. Be that "real" deleted or "not actually" deleted. – tcurdt Sep 20 '16 at 21:56
  • That still wouldn't help you in advance... – l'L'l Sep 20 '16 at 21:57
  • exactly - but that's why the "real" or "not actually" deleted does not matter here. – tcurdt Sep 20 '16 at 22:00

2 Answers2

17

The simple answer is this is not currently possible.

The reason is that Apple Maps application is not deleted, only application icon is removed from home screen (see Mike D comment).

Custom url of this app (maps://) is still registered, so sharedApplication can open this url. But when you try to open this url and app icon is removed from home screen, user is notified about restoring the application through AppStore. When user wants to restore app, it is restored immediately (nothing is downloaded).

Result of MKMapItem.openMaps means only user decision if he wants to open Apple Maps.

IMHO Apple Maps cannot be regularly uninstalled because their data are being reused by other applications.

JMI
  • 2,530
  • 15
  • 26
  • 1
    A device needs to be online for reinstallation of Apple Maps (some data are needed to be downloaded) since iOS 11 or 12. But the consequences are the same. – JMI Sep 18 '18 at 07:52
7

In the current version i.e. 11.2, it appears you are able to remove Apple Maps from your phone. But unfortunately, if you do something like:

 if (UIApplication.shared.canOpenURL(URL(string: "maps://")!)) {
        //do whatever you need to do here.
 }

it still returns true.

But it does handle navigation gracefully anyway. In my case I am providing the user a chooser between Apple Maps and Google Maps. When Apple Maps is not present it provides me with this, IMHO, this is fine because the user is not navigated away from the app and can choose a different option if they want to:

enter image description here

azwethinkweiz
  • 522
  • 4
  • 8