diff --git a/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/Info.plist b/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/Info.plist index 7aa3664..da17e4c 100644 --- a/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/Info.plist +++ b/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/Info.plist @@ -2,6 +2,8 @@ + UID2EnvironmentEUID + UIMainStoryboardFile~ipad iPad UIMainStoryboardFile diff --git a/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/ViewController.swift b/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/ViewController.swift index 1219b98..f14f0e8 100644 --- a/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/ViewController.swift +++ b/Development/UID2GoogleIMADevelopmentApp/UID2GoogleIMADevelopmentApp/ViewController.swift @@ -28,7 +28,16 @@ class ViewController: UIViewController, IMAAdsLoaderDelegate, IMAAdsManagerDeleg private var contentPlayhead: IMAAVPlayerContentPlayhead? private let adsLoader = IMAAdsLoader(settings: nil) private var adsManager: IMAAdsManager? - + + private let manager: UID2Manager = { + let isEUID = Bundle.main.object(forInfoDictionaryKey: "UID2EnvironmentEUID") as? Bool ?? false + if isEUID { + return EUIDManager.shared + } else { + return UID2Manager.shared + } + }() + // MARK: - View controller lifecycle methods override func viewDidLoad() { @@ -69,7 +78,7 @@ class ViewController: UIViewController, IMAAdsLoaderDelegate, IMAAdsManagerDeleg refreshResponseKey: uid2IdentityFromFile.refreshResponseKey) Task { - await UID2Manager.shared.setIdentity(uid2Identity) + await manager.setIdentity(uid2Identity) } } catch { print("Error loading UID2Identity") diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index b7586b5..6ae346d 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -15,6 +15,8 @@ Version Numbering follows [Semantic Versioning](https://semver.org) standards. *https://github.com/IABTechLab/uid2-ios-plugin-google-ima/blob/ac286e2c9241c04c001ff7a42a4cbb1dfc2c80b9/Package.swift#L18 * Update / Confirm `adapterVersion()` in `UID2IMASecureSignalsAdapter.swift` is set to expected version * https://github.com/IABTechLab/uid2-ios-plugin-google-ima/blob/ac286e2c9241c04c001ff7a42a4cbb1dfc2c80b9/Sources/UID2IMAPlugin/UID2IMASecureSignalsAdapter.swift#L24-L30 + * Update / Confirm `adapterVersion()` in `EUIDIMASecureSignalsAdapter.swift` is set to expected version + * https://github.com/IABTechLab/uid2-ios-plugin-google-ima/blob/d5278ce634aa228712d9a6dae032232df7f2a434/Sources/UID2IMAPlugin/EUIDIMASecureSignalsAdapter.swift#L22-L28 * Update / Confirm `version` and `source.tag` in `UID2IMAPlugin.podspec.json` are set to expected version * https://github.com/IABTechLab/uid2-ios-plugin-google-ima/blob/main/UID2IMAPlugin.podspec.jsonL6-L12 * Add and / or Edit any ADRs that support this release diff --git a/Sources/UID2IMAPlugin/EUIDIMASecureSignalsAdapter.swift b/Sources/UID2IMAPlugin/EUIDIMASecureSignalsAdapter.swift new file mode 100644 index 0000000..a9d74a9 --- /dev/null +++ b/Sources/UID2IMAPlugin/EUIDIMASecureSignalsAdapter.swift @@ -0,0 +1,49 @@ +// +// EUIDIMASecureSignalsAdapter.swift +// + +import Foundation +import GoogleInteractiveMediaAds +import UID2 + +@available(iOS 13.0, *) +@objc(EUIDIMASecureSignalsAdapter) +public class EUIDIMASecureSignalsAdapter: NSObject { + + required public override init() { + // Ensure UID2Manager has started + _ = EUIDManager.shared + } + +} + +@available(iOS 13, *) +extension EUIDIMASecureSignalsAdapter: IMASecureSignalsAdapter { + + public static func adapterVersion() -> IMAVersion { + let version = IMAVersion() + version.majorVersion = 1 + version.minorVersion = 0 + version.patchVersion = 0 + return version + } + + public static func adSDKVersion() -> IMAVersion { + let sdkVersion = UID2SDKProperties.getUID2SDKVersion() + let version = IMAVersion() + version.majorVersion = sdkVersion.major + version.minorVersion = sdkVersion.minor + version.patchVersion = sdkVersion.patch + return version + } + + public func collectSignals(completion: @escaping IMASignalCompletionHandler) { + Task { + guard let advertisingToken = await EUIDManager.shared.getAdvertisingToken() else { + completion(nil, AdvertisingTokenNotFoundError()) + return + } + completion(advertisingToken, nil) + } + } +} diff --git a/Sources/UID2IMAPlugin/UID2IMASecureSignalsAdapter.swift b/Sources/UID2IMAPlugin/UID2IMASecureSignalsAdapter.swift index 0fdc245..4effa8d 100644 --- a/Sources/UID2IMAPlugin/UID2IMASecureSignalsAdapter.swift +++ b/Sources/UID2IMAPlugin/UID2IMASecureSignalsAdapter.swift @@ -25,17 +25,18 @@ extension UID2IMASecureSignalsAdapter: IMASecureSignalsAdapter { public static func adapterVersion() -> IMAVersion { let version = IMAVersion() - version.majorVersion = 0 - version.minorVersion = 4 + version.majorVersion = 1 + version.minorVersion = 0 version.patchVersion = 0 return version } public static func adSDKVersion() -> IMAVersion { + let sdkVersion = UID2SDKProperties.getUID2SDKVersion() let version = IMAVersion() - version.majorVersion = UID2SDKProperties.getUID2SDKVersion().major - version.minorVersion = UID2SDKProperties.getUID2SDKVersion().minor - version.patchVersion = UID2SDKProperties.getUID2SDKVersion().patch + version.majorVersion = sdkVersion.major + version.minorVersion = sdkVersion.minor + version.patchVersion = sdkVersion.patch return version } diff --git a/Tests/UID2IMAPluginTests/EUIDIMASecureSignalsAdapterTests.swift b/Tests/UID2IMAPluginTests/EUIDIMASecureSignalsAdapterTests.swift new file mode 100644 index 0000000..4099621 --- /dev/null +++ b/Tests/UID2IMAPluginTests/EUIDIMASecureSignalsAdapterTests.swift @@ -0,0 +1,78 @@ +// +// EUIDIMASecureSignalsAdapterTests.swift +// + +import XCTest +import GoogleInteractiveMediaAds +import UID2 +import UID2IMAPlugin + +final class EUIDIMASecureSignalsAdapterTests: XCTestCase { + /// 🟩 - IMA Adapter Request Signal Success + func testRequestSignalsSuccess() async throws { + // Seed the sample UID2Identity data in the UID2Manager + await EUIDManager.shared.setAutomaticRefreshEnabled(false) + await EUIDManager.shared.setIdentity( + UID2Identity( + advertisingToken: "euid-test-token", + refreshToken: "refresh-token", + identityExpires: Date(timeIntervalSinceNow: 60 * 60).millisecondsSince1970, + refreshFrom: Date(timeIntervalSinceNow: 60 * 40).millisecondsSince1970, + refreshExpires: Date(timeIntervalSinceNow: 60 * 50).millisecondsSince1970, + refreshResponseKey: "" + ) + ) + + let signal = try await EUIDIMASecureSignalsAdapter().collectSignals() + + // Confirm that Adapter returns expected data + XCTAssertEqual("euid-test-token", signal) + } + + /// 🟥 - GMA Adapter Request Signal Error No Identity + func testRequestSignalsNoIdentity() async throws { + // Ensure no identity is set + await EUIDManager.shared.resetIdentity() + + let result = await Task { + try await EUIDIMASecureSignalsAdapter().collectSignals() + }.result + XCTAssertThrowsError(try result.get()) { error in + let adapterError = error as? AdvertisingTokenNotFoundError + XCTAssertEqual(AdvertisingTokenNotFoundError(), adapterError) + } + } + + /// 🟥 - IMA Adapter Request Signal No Advertising Token Error + func testRequestSignalsNoAdvertisingToken() async throws { + // Set an identity with an invalid advertisingToken + await EUIDManager.shared.setAutomaticRefreshEnabled(false) + await EUIDManager.shared.setIdentity( + UID2Identity( + advertisingToken: "", + refreshToken: "refresh-token", + identityExpires: Date(timeIntervalSinceNow: 60 * 60).millisecondsSince1970, + refreshFrom: Date(timeIntervalSinceNow: 60 * 40).millisecondsSince1970, + refreshExpires: Date(timeIntervalSinceNow: 60 * 50).millisecondsSince1970, + refreshResponseKey: "" + ) + ) + + let result = await Task { + try await EUIDIMASecureSignalsAdapter().collectSignals() + }.result + XCTAssertThrowsError(try result.get()) { error in + let adapterError = error as? AdvertisingTokenNotFoundError + XCTAssertEqual(AdvertisingTokenNotFoundError(), adapterError) + } + } + + func testAdSDKVersion() async throws { + let adSDKVersion = EUIDIMASecureSignalsAdapter.adSDKVersion() + let sdkVersion = await EUIDManager.shared.sdkVersion + + XCTAssertEqual(sdkVersion.major, adSDKVersion.majorVersion) + XCTAssertEqual(sdkVersion.minor, adSDKVersion.minorVersion) + XCTAssertEqual(sdkVersion.patch, adSDKVersion.patchVersion) + } +} diff --git a/UID2IMAPlugin.podspec.json b/UID2IMAPlugin.podspec.json index 2aecb02..23e4ed1 100644 --- a/UID2IMAPlugin.podspec.json +++ b/UID2IMAPlugin.podspec.json @@ -3,13 +3,13 @@ "summary": "A plugin for integrating UID2 and Google IMA into iOS applications.", "homepage": "https://unifiedid.com/", "license": "Apache License, Version 2.0", - "version": "0.4.0", + "version": "1.0.0", "authors": { "David Snabel-Caunt": "dave.snabel-caunt@thetradedesk.com" }, "source": { "git": "https://github.com/IABTechLab/uid2-ios-plugin-google-ima.git", - "tag": "v0.4.0" + "tag": "v1.0.0" }, "platforms": { "ios": "12.0"