简体   繁体   English

如果其他应用已经注册了Google Maps网址计划,该怎么办

[英]What if Google Maps Url Scheme is Already registered by Another App

I want to open google maps with a coordinate and the problem is that the scheme comgooglemaps is already registered for another app (!!!) and when i try to launch it , the other apps is launched ! 我想用坐标打开Goog​​le地图,问题是该方案comgooglemaps已经为另一个应用程序注册(!!!),当我尝试启动它时,其他应用程序也启动了! , so how can I open google maps now ? ,那么我现在如何打开谷歌地图? Im currently using this method 我目前正在使用此方法

if UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
            UIApplication.shared.open(URL(string: "comgooglemaps://?center=\(latitude),\(longitude)&zoom=14&views=traffic&q=loc:\(latitude),\(longitude)")!, options: [:], completionHandler: nil)
        } else {
            print("Can't use comgooglemaps://")
            UIApplication.shared.open(URL(string: "http://maps.google.com/maps?q=loc:\(latitude),\(longitude)&zoom=14&views=traffic")!, options: [:], completionHandler: nil)
        }

which the if is true but the other app is openned comgooglemaps key and googlechromes is listed in info.plist 如果为true,但打开了另一个应用程序,则comgooglemaps键和googlechromes列在info.plist中

There's nothing your app can do. 您的应用无法执行任何操作。 If two apps register the same custom URL scheme, iOS will open one of them. 如果两个应用程序注册了相同的自定义URL方案,iOS将打开其中一个。 A third app has no way to know that there is more than one app with the same registered URL scheme. 第三个应用程序无法知道有多个具有相同注册URL方案的应用程序。 A third app simply makes the request. 第三个应用程序只是发出请求。 It can't know which of the two is actually launched nor can it specify which of the two to launch. 它既不知道实际启动了这两个中的哪个,也无法指定要启动的两个中的哪个。

None of this is specific to the Goole Maps custom URL scheme. 这些都不是特定于Goole Maps自定义URL方案的。 Sadly, Apple makes no attempt to ensure that apps have a unique custom URL scheme. 可悲的是,Apple没有尝试确保应用程序具有唯一的自定义URL方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM