Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check iOS 13 is available at runtime #21

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/UID2IMAPlugin/AdvertisingTokenNotFoundError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

/// Advertising Token Not Found for IMA Adapter
@objc(UID2IMAAdvertisingTokenNotFoundError)
public class AdvertisingTokenNotFoundError: NSError {
public class AdvertisingTokenNotFoundError: NSError, @unchecked Sendable {

convenience init() {
self.init(domain: "UID", code: 1)
Expand Down
9 changes: 8 additions & 1 deletion Sources/UID2IMAPlugin/EUIDIMASecureSignalsAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import UID2
public class EUIDIMASecureSignalsAdapter: NSObject {

required public override init() {
guard isOperatingSystemSupported else {
return
}
// Ensure UID2Manager has started
_ = EUIDManager.shared
}
Expand All @@ -24,7 +27,7 @@ extension EUIDIMASecureSignalsAdapter: IMASecureSignalsAdapter {
let version = IMAVersion()
version.majorVersion = 1
version.minorVersion = 0
version.patchVersion = 0
version.patchVersion = 1
return version
}

Expand All @@ -38,6 +41,10 @@ extension EUIDIMASecureSignalsAdapter: IMASecureSignalsAdapter {
}

public func collectSignals(completion: @escaping IMASignalCompletionHandler) {
guard isOperatingSystemSupported else {
completion(nil, OperatingSystemUnsupportedError())
return
}
Task {
guard let advertisingToken = await EUIDManager.shared.getAdvertisingToken() else {
completion(nil, AdvertisingTokenNotFoundError())
Expand Down
20 changes: 20 additions & 0 deletions Sources/UID2IMAPlugin/OperatingSystemSupport.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

/// Adapter implementations in this package are called at runtime, ignoring @available attributes.
/// By checking the operating system version we can avoid calling UID code which is unavailable.
let isOperatingSystemSupported = ProcessInfo.processInfo.isOperatingSystemAtLeast(
.init(
majorVersion: 13,
minorVersion: 0,
patchVersion: 0
)
)

/// 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)
}
}
12 changes: 9 additions & 3 deletions Sources/UID2IMAPlugin/UID2IMASecureSignalsAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import UID2
@available(iOS 13.0, *)
@objc(UID2IMASecureSignalsAdapter)
public class UID2IMASecureSignalsAdapter: NSObject {

required public override init() {
guard isOperatingSystemSupported else {
return
}
// Ensure UID2Manager has started
_ = UID2Manager.shared
}
Expand All @@ -27,7 +30,7 @@ extension UID2IMASecureSignalsAdapter: IMASecureSignalsAdapter {
let version = IMAVersion()
version.majorVersion = 1
version.minorVersion = 0
version.patchVersion = 0
version.patchVersion = 1
return version
}

Expand All @@ -41,7 +44,10 @@ extension UID2IMASecureSignalsAdapter: IMASecureSignalsAdapter {
}

public func collectSignals(completion: @escaping IMASignalCompletionHandler) {

guard isOperatingSystemSupported else {
completion(nil, OperatingSystemUnsupportedError())
return
}
Task {
guard let advertisingToken = await UID2Manager.shared.getAdvertisingToken() else {
completion(nil, AdvertisingTokenNotFoundError())
Expand Down
4 changes: 2 additions & 2 deletions UID2IMAPlugin.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "1.0.0",
"version": "1.0.1",
"authors": {
"David Snabel-Caunt": "[email protected]"
},
"source": {
"git": "https://github.com/IABTechLab/uid2-ios-plugin-google-ima.git",
"tag": "v1.0.0"
"tag": "v1.0.1"
},
"platforms": {
"ios": "12.0"
Expand Down