diff --git a/PrebidMobile/AdUnits/Native/NativeAd.swift b/PrebidMobile/AdUnits/Native/NativeAd.swift index f407df97e..15618610f 100644 --- a/PrebidMobile/AdUnits/Native/NativeAd.swift +++ b/PrebidMobile/AdUnits/Native/NativeAd.swift @@ -112,6 +112,10 @@ public class NativeAd: NSObject, CacheExpiryDelegate { return dataObjects(of: .ctaText).first?.value } + /// Returns landing URL of the clickable link. + @objc public var clickURL: String? { + nativeAdMarkup?.link?.url + } /// Creates a `NativeAd` instance from the given cache ID. /// - Parameter cacheId: The cache ID to retrieve the bid response. /// - Returns: A `NativeAd` instance if successful, otherwise `nil`. diff --git a/PrebidMobileTests/NativeUnitTests/NativeAdTests.swift b/PrebidMobileTests/NativeUnitTests/NativeAdTests.swift index dc6c6061f..1d9460650 100644 --- a/PrebidMobileTests/NativeUnitTests/NativeAdTests.swift +++ b/PrebidMobileTests/NativeUnitTests/NativeAdTests.swift @@ -23,7 +23,6 @@ class NativeAdTests: XCTestCase { } func testNativeAd() { - let cacheId = CacheManager.shared.save(content: nativeAdString) let nativeAd = NativeAd.create(cacheId: cacheId!) @@ -36,6 +35,7 @@ class NativeAdTests: XCTestCase { XCTAssertEqual(nativeAd!.nativeAdMarkup!.link!.url, "https://www.testUrl.com/") XCTAssertEqual(nativeAd!.nativeAdMarkup!.link!.clicktrackers, ["https://testUrl.com/events/click/root/url"]) XCTAssertEqual(nativeAd!.nativeAdMarkup!.eventtrackers!.first!.url, "https://testUrl.com/events/tracker/impression") + XCTAssertEqual(nativeAd!.clickURL, "https://www.testUrl.com/") } func testArrayGetters() {