29 lines
740 B
Swift
29 lines
740 B
Swift
import Foundation
|
|
|
|
#if canImport(UIKit)
|
|
import UIKit
|
|
#endif
|
|
|
|
enum SubBannerLinkOpener {
|
|
static func open(_ banner: SubBanner, using opener: @escaping (URL, @escaping (Bool) -> Void) -> Void) {
|
|
let webURL = banner.webURL
|
|
if let iosURL = banner.iosURL {
|
|
opener(iosURL) { opened in
|
|
if !opened, let webURL {
|
|
opener(webURL) { _ in }
|
|
}
|
|
}
|
|
} else if let webURL {
|
|
opener(webURL) { _ in }
|
|
}
|
|
}
|
|
|
|
#if canImport(UIKit)
|
|
static func open(_ banner: SubBanner) {
|
|
open(banner) { url, completion in
|
|
UIApplication.shared.open(url, options: [:], completionHandler: completion)
|
|
}
|
|
}
|
|
#endif
|
|
}
|