How to check if Apple Maps is installed

北城以北 提交于 2019-11-30 22:11:04

问题


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.


回答1:


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.




回答2:


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:



来源:https://stackoverflow.com/questions/39603120/how-to-check-if-apple-maps-is-installed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!