Skip to content

Commit

Permalink
Check iOS 13 is available at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaunt committed Nov 4, 2024
1 parent 0a1e93f commit ff54c06
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ 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

completionHandler(nil)
}

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())
Expand Down
14 changes: 14 additions & 0 deletions Sources/UID2GMAPlugin/OperatingSystemUnsupportedError.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
9 changes: 8 additions & 1 deletion Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ 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

completionHandler(nil)
}

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())
Expand Down

0 comments on commit ff54c06

Please sign in to comment.