-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
161 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// EUIDGMAMediationAdapter.swift | ||
// | ||
|
||
import Foundation | ||
import GoogleMobileAds | ||
import UID2 | ||
|
||
/// Adapter to connect EUID to Google Mobile Ads | ||
/// https://developers.google.com/admob/ios/open-bidding-adapter | ||
@available(iOS 13, *) | ||
@objc(EUIDGMAMediationAdapter) | ||
class EUIDGMAMediationAdapter: NSObject { | ||
|
||
required override init() { } | ||
|
||
} | ||
|
||
@available(iOS 13, *) | ||
extension EUIDGMAMediationAdapter: GADRTBAdapter { | ||
|
||
static func setUpWith(_ configuration: GADMediationServerConfiguration, completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock) { | ||
|
||
// Ensure UID2Manager has started | ||
_ = EUIDManager.shared | ||
|
||
completionHandler(nil) | ||
} | ||
|
||
func collectSignals(for params: GADRTBRequestParameters, completionHandler: @escaping GADRTBSignalCompletionHandler) { | ||
Task { | ||
guard let advertisingToken = await EUIDManager.shared.getAdvertisingToken() else { | ||
completionHandler(nil, AdvertisingTokenNotFoundError()) | ||
return | ||
} | ||
completionHandler(advertisingToken, nil) | ||
} | ||
} | ||
|
||
static func adapterVersion() -> GADVersionNumber { | ||
var version = GADVersionNumber() | ||
version.majorVersion = 0 | ||
version.minorVersion = 5 | ||
version.patchVersion = 0 | ||
return version | ||
} | ||
|
||
static func adSDKVersion() -> GADVersionNumber { | ||
let uid2Version = UID2SDKProperties.getUID2SDKVersion() | ||
var version = GADVersionNumber() | ||
version.majorVersion = uid2Version.major | ||
version.minorVersion = uid2Version.minor | ||
version.patchVersion = uid2Version.patch | ||
return version | ||
} | ||
|
||
static func networkExtrasClass() -> GADAdNetworkExtras.Type? { | ||
return nil | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
Tests/UID2GMAPluginTests/EUIDGMAMediationAdapterTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// EUIDGMAMediationAdapterTests.swift | ||
// | ||
|
||
import XCTest | ||
import GoogleMobileAds | ||
import UID2 | ||
@testable import UID2GMAPlugin | ||
|
||
final class EUIDGMAMediationAdapterTests: XCTestCase { | ||
|
||
/// 🟩 - GMA 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 EUIDGMAMediationAdapter().collectSignals(for: GADRTBRequestParameters()) | ||
|
||
// 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<String?, Error> { | ||
try await EUIDGMAMediationAdapter().collectSignals(for: GADRTBRequestParameters()) | ||
}.result | ||
XCTAssertThrowsError(try result.get()) { error in | ||
let adapterError = error as? AdvertisingTokenNotFoundError | ||
XCTAssertEqual(AdvertisingTokenNotFoundError(), adapterError) | ||
} | ||
} | ||
|
||
/// 🟥 - GMA Adapter Request Signal No Advertising Token Erro | ||
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<String?, Error> { | ||
try await EUIDGMAMediationAdapter().collectSignals(for: GADRTBRequestParameters()) | ||
}.result | ||
XCTAssertThrowsError(try result.get()) { error in | ||
let adapterError = error as? AdvertisingTokenNotFoundError | ||
XCTAssertEqual(AdvertisingTokenNotFoundError(), adapterError) | ||
} | ||
} | ||
|
||
/// 🟩 - GMA Adapter Ad SDK Version Check Success | ||
func testAdSDKVersion() async throws { | ||
|
||
let adSDKVersion = EUIDGMAMediationAdapter.adSDKVersion() | ||
let sdkVersion = await EUIDManager.shared.sdkVersion | ||
|
||
XCTAssertEqual(sdkVersion.major, adSDKVersion.majorVersion) | ||
XCTAssertEqual(sdkVersion.minor, adSDKVersion.minorVersion) | ||
XCTAssertEqual(sdkVersion.patch, adSDKVersion.patchVersion) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
"summary": "A plugin for integrating UID2 and Google GMA into iOS applications.", | ||
"homepage": "https://unifiedid.com/", | ||
"license": "Apache License, Version 2.0", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"authors": { | ||
"David Snabel-Caunt": "[email protected]" | ||
}, | ||
"source": { | ||
"git": "https://github.com/IABTechLab/uid2-ios-plugin-google-gma.git", | ||
"tag": "v0.4.0" | ||
"tag": "v0.5.0" | ||
}, | ||
"platforms": { | ||
"ios": "12.0" | ||
|