AZ
openMapIntent(lat: String, long: String) -> UIAlertController {
let alert = UIAlertController(title: "Выбор", message: "Какое приложение открыть?", preferredStyle: .actionSheet)
for app
in navigationApps {
if(UIApplication.shared.canOpenURL(URL(string: app.scheme)!)) {
let button = UIAlertAction(title: app.displayName, style: .default, handler: { action
in
UIApplication.shared.open(URL(string: app.mapLink.replacingOccurrences(of: "$lat", with: lat).replacingOccurrences(of: "$long", with: long))!, options: [:], completionHandler:
nil)
})
alert.addAction(button)
}
}
let button = UIAlertAction(title: "Отмена", style: .default, handler: { action
in })
alert.addAction(button)
return alert
}