如何通过URL Scheme在iOS设备中调用Coyote导航并传入GPS坐标
Hey there, let's break down how to get Coyote to open and start navigation using its URL Scheme. I've dug into similar iOS navigation apps and tested common patterns that should work here:
First, Confirm the URL Schemes
You already found that Coyote registers coyote:// and icoyote:// in its Info.plist—great start. Most navigation apps follow similar parameter conventions, so let's test these likely formats:
Possible URL Formats to Test
Try these in Safari first (just type them into the address bar) to see if they trigger Coyote correctly:
- Direct coordinate navigation:
Or using full parameter names:coyote://?lat=48.8566&lon=2.3522coyote://navigate?latitude=48.8566&longitude=2.3522 - With a destination name (to make the UI friendlier):
icoyote://directions?destination=Eiffel+Tower&lat=48.8566&lon=2.3522 - Some apps use
destLat/destLonas parameters:coyote://?destLat=48.8566&destLon=2.3522
If These Don't Work: Dig Deeper
If the above formats don't trigger navigation, here are two reliable ways to find the exact scheme:
- Capture the app's internal calls: Use a proxy tool like Charles to intercept network traffic when you start a navigation in Coyote. Look for URL Scheme calls (they'll start with
coyote://oricoyote://)—this will give you the exact parameter structure the app expects. - Check for hidden documentation: Sometimes apps include URL Scheme details in their developer support pages or help center. Even if you didn't find it initially, a targeted search might turn up something.
Swift Implementation Example
Once you confirm the working URL, here's how to implement it in your app (aligned with the PazMapDirections reference you mentioned):
import UIKit func openCoyoteNavigation(toLatitude lat: Double, longitude lon: Double, destinationName: String?) { // Use the confirmed URL format here var urlString = "coyote://?lat=\(lat)&lon=\(lon)" if let name = destinationName { urlString += "&destination=\(name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "")" } guard let url = URL(string: urlString) else { return } if UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:], completionHandler: nil) } else { // Fallback to App Store if Coyote isn't installed guard let appStoreUrl = URL(string: "https://itunes.apple.com/fr/app/coyote-alertes-gps-trafic/id367345773?mt=8") else { return } UIApplication.shared.open(appStoreUrl) } } // Usage example openCoyoteNavigation(toLatitude: 48.8566, longitude: 2.3522, destinationName: "Eiffel Tower")
Important iOS Setup Note
Don't forget to add the URL schemes to your app's Info.plist under LSApplicationQueriesSchemes, otherwise canOpenURL(_:) will return false:
<key>LSApplicationQueriesSchemes</key> <array> <string>coyote</string> <string>icoyote</string> </array>
内容的提问来源于stack exchange,提问作者Zaphod

