Skip to content

Commit a293877

Browse files
authored
Check iOS 13 is available at runtime (#21)
1 parent 0a1e93f commit a293877

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed

Sources/UID2GMAPlugin/AdvertisingTokenNotFoundError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
/// Advertising Token Not Found for GMA Adapter
1111
@objc(UID2GMAAdvertisingTokenNotFoundError)
12-
public class AdvertisingTokenNotFoundError: NSError {
12+
public class AdvertisingTokenNotFoundError: NSError, @unchecked Sendable {
1313

1414
convenience init() {
1515
self.init(domain: "UID", code: 1)

Sources/UID2GMAPlugin/EUIDGMAMediationAdapter.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ class EUIDGMAMediationAdapter: NSObject {
2020
extension EUIDGMAMediationAdapter: GADRTBAdapter {
2121

2222
static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
23-
23+
guard isOperatingSystemSupported else {
24+
completionHandler(OperatingSystemUnsupportedError())
25+
return
26+
}
2427
// Ensure UID2Manager has started
2528
_ = EUIDManager.shared
2629

2730
completionHandler(nil)
2831
}
2932

3033
func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
34+
guard isOperatingSystemSupported else {
35+
completionHandler(nil, OperatingSystemUnsupportedError())
36+
return
37+
}
3138
Task {
3239
guard let advertisingToken = await EUIDManager.shared.getAdvertisingToken() else {
3340
completionHandler(nil, AdvertisingTokenNotFoundError())
@@ -41,7 +48,7 @@ extension EUIDGMAMediationAdapter: GADRTBAdapter {
4148
var version = GADVersionNumber()
4249
version.majorVersion = 1
4350
version.minorVersion = 0
44-
version.patchVersion = 0
51+
version.patchVersion = 1
4552
return version
4653
}
4754

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// OperatingSystemUnsupportedError.swift
3+
//
4+
5+
import Foundation
6+
7+
/// Adapter implementations in this package are called at runtime, ignoring @available attributes.
8+
/// By checking the operating system version we can avoid calling UID code which is unavailable.
9+
let isOperatingSystemSupported = ProcessInfo.processInfo.isOperatingSystemAtLeast(
10+
.init(
11+
majorVersion: 13,
12+
minorVersion: 0,
13+
patchVersion: 0
14+
)
15+
)
16+
17+
/// Adapter called on an unsupported operating system version i.e. lower than UID2's deployment target.
18+
@objc(UID2GMAOperatingSystemUnsupported)
19+
public final class OperatingSystemUnsupportedError: NSError, @unchecked Sendable {
20+
21+
convenience init() {
22+
self.init(domain: "UID", code: 2)
23+
}
24+
}

Sources/UID2GMAPlugin/UID2GMAMediationAdapter.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ class UID2GMAMediationAdapter: NSObject {
2323
extension UID2GMAMediationAdapter: GADRTBAdapter {
2424

2525
static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) {
26-
26+
guard isOperatingSystemSupported else {
27+
completionHandler(OperatingSystemUnsupportedError())
28+
return
29+
}
2730
// Ensure UID2Manager has started
2831
_ = UID2Manager.shared
2932

3033
completionHandler(nil)
3134
}
3235

3336
func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) {
37+
guard isOperatingSystemSupported else {
38+
completionHandler(nil, OperatingSystemUnsupportedError())
39+
return
40+
}
3441
Task {
3542
guard let advertisingToken = await UID2Manager.shared.getAdvertisingToken() else {
3643
completionHandler(nil, AdvertisingTokenNotFoundError())
@@ -44,7 +51,7 @@ extension UID2GMAMediationAdapter: GADRTBAdapter {
4451
var version = GADVersionNumber()
4552
version.majorVersion = 1
4653
version.minorVersion = 0
47-
version.patchVersion = 0
54+
version.patchVersion = 1
4855
return version
4956
}
5057

UID2GMAPlugin.podspec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"summary": "A plugin for integrating UID2 and Google GMA into iOS applications.",
44
"homepage": "https://unifiedid.com/",
55
"license": "Apache License, Version 2.0",
6-
"version": "1.0.0",
6+
"version": "1.0.1",
77
"authors": {
88
"David Snabel-Caunt": "dave.snabel-caunt@thetradedesk.com"
99
},
1010
"source": {
1111
"git": "https://github.com/IABTechLab/uid2-ios-plugin-google-gma.git",
12-
"tag": "v1.0.0"
12+
"tag": "v1.0.1"
1313
},
1414
"platforms": {
1515
"ios": "12.0"

0 commit comments

Comments
 (0)