From ff54c06ebd85b7ca9b763b33855dbe2397d61553 Mon Sep 17 00:00:00 2001 From: Dave Snabel-Caunt Date: Mon, 4 Nov 2024 12:41:52 +0000 Subject: [PATCH] Check iOS 13 is available at runtime --- .../UID2GMAPlugin/EUIDGMAMediationAdapter.swift | 9 ++++++++- .../OperatingSystemUnsupportedError.swift | 14 ++++++++++++++ .../UID2GMAPlugin/UID2GMAMediationAdapter.swift | 9 ++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Sources/UID2GMAPlugin/OperatingSystemUnsupportedError.swift diff --git a/Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift b/Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift index 2326c45..495947f 100644 --- a/Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift +++ b/Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift @@ -20,7 +20,10 @@ class EUIDGMAMediationAdapter: NSObject { extension EUIDGMAMediationAdapter: GADRTBAdapter { static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) { - + guard #available(iOS 13, *) else { + completionHandler(OperatingSystemUnsupportedError()) + return + } // Ensure UID2Manager has started _ = EUIDManager.shared @@ -28,6 +31,10 @@ extension EUIDGMAMediationAdapter: GADRTBAdapter { } func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) { + guard #available(iOS 13, *) else { + completionHandler(nil, OperatingSystemUnsupportedError()) + return + } Task { guard let advertisingToken = await EUIDManager.shared.getAdvertisingToken() else { completionHandler(nil, AdvertisingTokenNotFoundError()) diff --git a/Sources/UID2GMAPlugin/OperatingSystemUnsupportedError.swift b/Sources/UID2GMAPlugin/OperatingSystemUnsupportedError.swift new file mode 100644 index 0000000..6edea26 --- /dev/null +++ b/Sources/UID2GMAPlugin/OperatingSystemUnsupportedError.swift @@ -0,0 +1,14 @@ +// +// OperatingSystemUnsupportedError.swift +// + +import Foundation + +/// Adapter called on an unsupported operating system version i.e. lower than UID2's deployment target. +@objc(UID2GMAOperatingSystemUnsupported) +public final class OperatingSystemUnsupportedError: NSError, @unchecked Sendable { + + convenience init() { + self.init(domain: "UID", code: 2) + } +} diff --git a/Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift b/Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift index 54045ab..07c1fd4 100644 --- a/Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift +++ b/Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift @@ -23,7 +23,10 @@ class UID2GMAMediationAdapter: NSObject { extension UID2GMAMediationAdapter: GADRTBAdapter { static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) { - + guard #available(iOS 13, *) else { + completionHandler(OperatingSystemUnsupportedError()) + return + } // Ensure UID2Manager has started _ = UID2Manager.shared @@ -31,6 +34,10 @@ extension UID2GMAMediationAdapter: GADRTBAdapter { } func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) { + guard #available(iOS 13, *) else { + completionHandler(nil, OperatingSystemUnsupportedError()) + return + } Task { guard let advertisingToken = await UID2Manager.shared.getAdvertisingToken() else { completionHandler(nil, AdvertisingTokenNotFoundError())