From 50120081450a318e97186067304c1d01d22d6521 Mon Sep 17 00:00:00 2001 From: Olena Stepaniuk <92721590+OlenaPostindustria@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:42:51 +0200 Subject: [PATCH] Add getter for click URL (#1084) --- PrebidMobile/AdUnits/Native/NativeAd.swift | 4 ++++ PrebidMobileTests/NativeUnitTests/NativeAdTests.swift | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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() {