Showing
1 changed file
with
20 additions
and
0 deletions
... | @@ -469,6 +469,26 @@ var timer2: DispatchSourceTimer? | ... | @@ -469,6 +469,26 @@ var timer2: DispatchSourceTimer? |
469 | decisionHandler(.cancel) | 469 | decisionHandler(.cancel) |
470 | return | 470 | return |
471 | } | 471 | } |
472 | + | ||
473 | + // Example Deeplink: maps://?q=37.96951649191105,23.72242553856438 | ||
474 | + if redirectedUrl.absoluteString.contains("maps:") { | ||
475 | + // Extract the latitude and longitude from the query string | ||
476 | + if let query = redirectedUrl.query { | ||
477 | + let coordinates = query.replacingOccurrences(of: "q=", with: "").split(separator: ",") | ||
478 | + if coordinates.count == 2, | ||
479 | + let lat = coordinates.first, | ||
480 | + let lon = coordinates.last { | ||
481 | + | ||
482 | + // Create a new Apple Maps URL | ||
483 | + if let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") { | ||
484 | + // Open Apple Maps with the generated URL | ||
485 | + UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil) | ||
486 | + decisionHandler(.cancel) | ||
487 | + return | ||
488 | + } | ||
489 | + } | ||
490 | + } | ||
491 | + } | ||
472 | } | 492 | } |
473 | 493 | ||
474 | // } | 494 | // } | ... | ... |
-
Please register or login to post a comment