Manos Chorianopoulos

fix open websiteUrl at MapVC

......@@ -209,26 +209,53 @@ import MapKit
alert.addAction(UIAlertAction(title: "Δες το eshop", style: .default, handler: { action in
switch action.style{
case .default:
if (self.merchantsArray.count > 0) {
for item in self.merchantsArray {
let eshopWebsite = item._website
if (eshopWebsite != "") {
guard let websiteUrl = URL(string: eshopWebsite) else {
print("Error creating URL")
return
if (self.couponSet != nil) {
if let merchantUuid: String = self.couponSet?.merchant_uuid {
for item in swiftApi().getMerchantList() {
if (item._uuid == merchantUuid) {
let eshopWebsite = item._website
if (eshopWebsite != "") {
guard let websiteUrl = URL(string: eshopWebsite) else {
print("Error creating URL")
return
}
// check if link can be opened.
guard UIApplication.shared.canOpenURL(websiteUrl) else {
return
}
swiftApi().logTrackersEvent("click", "SeeShopWebsite")
UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
break;
}
}
// check if link can be opened.
guard UIApplication.shared.canOpenURL(websiteUrl) else {
return
}
swiftApi().logTrackersEvent("click", "SeeShopWebsite")
UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
break;
}
}
}
// if (self.merchantsArray.count > 0) {
// for item in self.merchantsArray {
// let eshopWebsite = item._website
//
// if (eshopWebsite != "") {
// guard let websiteUrl = URL(string: eshopWebsite) else {
// print("Error creating URL")
// return
// }
//
// // check if link can be opened.
// guard UIApplication.shared.canOpenURL(websiteUrl) else {
// return
// }
//
// swiftApi().logTrackersEvent("click", "SeeShopWebsite")
// UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
// break;
// }
// }
// }
case .cancel:
print("cancel")
......