// URL string
enum KakaoMapURL {
static let kakaoMapScheme = "kakaomap://"
static let appPrefix = "kakaomap://look?p="
static let safariPrefix = "https://map.kakao.com/link/map/marker,"
}
// 카카오 맵 열기 코드
func openKakaoMap(locationX: String, locationY: String) {
guard let kakaoMapScheme = URL(string: KakaoMapURL.kakaoMapScheme) else { return }
let stringUrl = UIApplication.shared.canOpenURL(kakaoMapScheme)
? "\(KakaoMapURL.appPrefix)\(locationY),\(locationX)" // 카카오맵 설치 디바이스
: "\(KakaoMapURL.safariPrefix)\(locationY),\(locationX)" // 카카오맵 미설치 디바이스
guard let url = URL(string: stringUrl) else { return }
DispatchQueue.main.async {
UIApplication.shared.open(
url,
options: [:]
)
}
}