diff --git a/packages/interactive_media_ads/CHANGELOG.md b/packages/interactive_media_ads/CHANGELOG.md index 7a4e068c4a0..091170255ef 100644 --- a/packages/interactive_media_ads/CHANGELOG.md +++ b/packages/interactive_media_ads/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.2.6+3 + +* Adds internal wrappers for iOS native `IMAAd` and `IMAUniversalAdID`. +* Updates internal wrapper for iOS native `IMAAdEvent`. +* Updates internal wrapper for Android native `AdEvent`. + ## 0.2.6+2 * Updates kotlin version to 2.2.0 to enable gradle 8.11 support. diff --git a/packages/interactive_media_ads/README.md b/packages/interactive_media_ads/README.md index b80b5a10d5f..cdefce296a9 100644 --- a/packages/interactive_media_ads/README.md +++ b/packages/interactive_media_ads/README.md @@ -14,8 +14,7 @@ a separate video player positioned on top of the app's content video player. | **Support** | SDK 21+ | 12.0+ | **NOTE:** -* Companion ads, Background Audio ads and Google Dynamic Ad Insertion methods are currently not - supported. +* Background Audio ads and Google Dynamic Ad Insertion methods are currently not supported. ## IMA client-side overview diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt index 8cbf527a375..d2cef4e54c9 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt @@ -4,6 +4,7 @@ package dev.flutter.packages.interactive_media_ads +import com.google.ads.interactivemedia.v3.api.Ad import com.google.ads.interactivemedia.v3.api.AdEvent /** @@ -50,4 +51,8 @@ class AdEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : override fun adData(pigeon_instance: AdEvent): Map? { return pigeon_instance.adData } + + override fun ad(pigeon_instance: AdEvent): Ad? { + return pigeon_instance.ad + } } diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt index d5928fe1a48..8b48a5a2db4 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) : * * This must match the version in pubspec.yaml. */ - const val pluginVersion = "0.2.6+2" + const val pluginVersion = "0.2.6+3" } override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) { diff --git a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt index 05c1b2f9bbe..dee5d5d1ebf 100644 --- a/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt +++ b/packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -2558,7 +2558,7 @@ abstract class PigeonApiBaseManager( * Event to notify publisher that an event occurred with an Ad. * * See - * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. + * https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/kotlin/com/google/ads/interactivemedia/v3/api/AdEvent. */ @Suppress("UNCHECKED_CAST") abstract class PigeonApiAdEvent( @@ -2572,6 +2572,11 @@ abstract class PigeonApiAdEvent( pigeon_instance: com.google.ads.interactivemedia.v3.api.AdEvent ): Map? + /** The ad with which this event is associated. */ + abstract fun ad( + pigeon_instance: com.google.ads.interactivemedia.v3.api.AdEvent + ): com.google.ads.interactivemedia.v3.api.Ad? + @Suppress("LocalVariableName", "FunctionName") /** Creates a Dart instance of AdEvent and attaches it to [pigeon_instanceArg]. */ fun pigeon_newInstance( @@ -2589,11 +2594,12 @@ abstract class PigeonApiAdEvent( pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg) val typeArg = type(pigeon_instanceArg) val adDataArg = adData(pigeon_instanceArg) + val adArg = ad(pigeon_instanceArg) val binaryMessenger = pigeonRegistrar.binaryMessenger val codec = pigeonRegistrar.codec val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(pigeon_identifierArg, typeArg, adDataArg)) { + channel.send(listOf(pigeon_identifierArg, typeArg, adDataArg, adArg)) { if (it is List<*>) { if (it.size > 1) { callback( diff --git a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt index 974ad7b5f3e..86a8386ed7a 100644 --- a/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt +++ b/packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt @@ -4,6 +4,7 @@ package dev.flutter.packages.interactive_media_ads +import com.google.ads.interactivemedia.v3.api.Ad import com.google.ads.interactivemedia.v3.api.AdEvent import kotlin.test.Test import kotlin.test.assertEquals @@ -30,4 +31,15 @@ class AdEventProxyApiTest { assertEquals(mapOf("a" to "b", "c" to "d"), api.adData(instance)) } + + @Test + fun ad() { + val api = TestProxyApiRegistrar().getPigeonApiAdEvent() + + val ad = Mockito.mock() + val instance = Mockito.mock() + whenever(instance.ad).thenReturn(ad) + + assertEquals(ad, api.ad(instance)) + } } diff --git a/packages/interactive_media_ads/example/ios/Runner.xcodeproj/project.pbxproj b/packages/interactive_media_ads/example/ios/Runner.xcodeproj/project.pbxproj index 7950738349b..cf164f39c3e 100644 --- a/packages/interactive_media_ads/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/interactive_media_ads/example/ios/Runner.xcodeproj/project.pbxproj @@ -14,6 +14,9 @@ 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 8F0EDFD12E0A2906001938E6 /* SettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD02E0A2906001938E6 /* SettingsTests.swift */; }; + 8F0EDFD62E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD52E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift */; }; + 8F0EDFD72E4AA191001938E6 /* AdProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD42E4AA191001938E6 /* AdProxyAPITests.swift */; }; + 8F0EDFD92E4AA1B0001938E6 /* ViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD82E4AA1B0001938E6 /* ViewTests.swift */; }; 8F599BB12C2DD1FD0090A0DF /* AdsManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F599BB02C2DD1FD0090A0DF /* AdsManagerTests.swift */; }; 8F599BB32C2DD87D0090A0DF /* AdsLoaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F599BB22C2DD87D0090A0DF /* AdsLoaderTests.swift */; }; 8F599BB52C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F599BB42C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift */; }; @@ -77,6 +80,9 @@ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 89C6230E68C80A6F4B207726 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 8F0EDFD02E0A2906001938E6 /* SettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTests.swift; sourceTree = ""; }; + 8F0EDFD42E4AA191001938E6 /* AdProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdProxyAPITests.swift; sourceTree = ""; }; + 8F0EDFD52E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniversalAdIDProxyAPITests.swift; sourceTree = ""; }; + 8F0EDFD82E4AA1B0001938E6 /* ViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTests.swift; sourceTree = ""; }; 8F599BB02C2DD1FD0090A0DF /* AdsManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsManagerTests.swift; sourceTree = ""; }; 8F599BB22C2DD87D0090A0DF /* AdsLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsLoaderTests.swift; sourceTree = ""; }; 8F599BB42C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsLoaderDelegateTests.swift; sourceTree = ""; }; @@ -130,6 +136,9 @@ 331C8082294A63A400263BE5 /* RunnerTests */ = { isa = PBXGroup; children = ( + 8F0EDFD82E4AA1B0001938E6 /* ViewTests.swift */, + 8F0EDFD42E4AA191001938E6 /* AdProxyAPITests.swift */, + 8F0EDFD52E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift */, 8F0EDFD02E0A2906001938E6 /* SettingsTests.swift */, 8FC919912CA5D86F00188068 /* FriendlyObstructionTests.swift */, 8F977DCE2C2B99C600A90D4B /* AdDisplayContainerTests.swift */, @@ -256,6 +265,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 776DEB6D359E63A1B5E520A7 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -371,6 +381,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 776DEB6D359E63A1B5E520A7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 8BF613E92E45E672229E9718 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -418,8 +445,11 @@ 8F599BBF2C3335B40090A0DF /* ViewControllerTests.swift in Sources */, 8F8382A32CBDB4A4007F28E0 /* CompanionAdProxyApiTests.swift in Sources */, 8F0EDFD12E0A2906001938E6 /* SettingsTests.swift in Sources */, + 8F0EDFD62E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift in Sources */, + 8F0EDFD72E4AA191001938E6 /* AdProxyAPITests.swift in Sources */, 8FC919922CA5D86F00188068 /* FriendlyObstructionTests.swift in Sources */, 8F977DD92C2C8C6A00A90D4B /* AdLoadingErrorDataTests.swift in Sources */, + 8F0EDFD92E4AA1B0001938E6 /* ViewTests.swift in Sources */, 8F599BB32C2DD87D0090A0DF /* AdsLoaderTests.swift in Sources */, 8F977DD72C2C89A600A90D4B /* AdEventTests.swift in Sources */, 8F977DD32C2BA15100A90D4B /* TestProxyApiRegistrar.swift in Sources */, @@ -520,7 +550,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -650,7 +680,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -701,7 +731,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/packages/interactive_media_ads/example/ios/RunnerTests/AdEventTests.swift b/packages/interactive_media_ads/example/ios/RunnerTests/AdEventTests.swift index 9906e315734..9b5a2947b25 100644 --- a/packages/interactive_media_ads/example/ios/RunnerTests/AdEventTests.swift +++ b/packages/interactive_media_ads/example/ios/RunnerTests/AdEventTests.swift @@ -41,6 +41,17 @@ final class AdEventTests: XCTestCase { XCTAssertEqual(value as! [String: String], ["my": "string"]) } + + func testAd() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAdEvent(registrar) + + let instance = TestAdEvent.customInit() + let value = try? api.pigeonDelegate.ad(pigeonApi: api, pigeonInstance: instance) + + XCTAssertNotNil(value) + XCTAssertEqual(value, instance.ad) + } } class TestAdEvent: IMAAdEvent { @@ -48,9 +59,12 @@ class TestAdEvent: IMAAdEvent { static func customInit() -> TestAdEvent { let instance = TestAdEvent.perform(NSSelectorFromString("new")).takeRetainedValue() as! TestAdEvent + instance._ad = TestAd.customInit() return instance } + var _ad: TestAd? + override var type: IMAAdEventType { return .AD_BREAK_ENDED } @@ -62,4 +76,8 @@ class TestAdEvent: IMAAdEvent { override var adData: [String: Any]? { return ["my": "string"] } + + override var ad: IMAAd? { + return _ad! + } } diff --git a/packages/interactive_media_ads/example/ios/RunnerTests/AdProxyAPITests.swift b/packages/interactive_media_ads/example/ios/RunnerTests/AdProxyAPITests.swift new file mode 100644 index 00000000000..20102a6eac4 --- /dev/null +++ b/packages/interactive_media_ads/example/ios/RunnerTests/AdProxyAPITests.swift @@ -0,0 +1,424 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Flutter +import GoogleInteractiveMediaAds +import XCTest + +@testable import interactive_media_ads + +class AdProxyAPITests: XCTestCase { + func testAdId() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.adId(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adId) + } + + func testAdTitle() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.adTitle(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adTitle) + } + + func testAdDescription() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.adDescription(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adDescription) + } + + func testAdSystem() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.adSystem(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adSystem) + } + + @MainActor func testCompanionAds() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try! api.pigeonDelegate.companionAds(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.companionAds) + } + + func testContentType() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.contentType(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.contentType) + } + + func testDuration() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.duration(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.duration) + } + + func testUiElements() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let elementArray = NSMutableArray() + elementArray.add(NSNumber(value: IMAUiElementType.elements_AD_ATTRIBUTION.rawValue)) + let instance = TestAd.customInit() + instance.testElements = elementArray + let value = try? api.pigeonDelegate.uiElements(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, [UIElementType.adAttribution]) + } + + func testUiElementsWithStrings() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let elementArray = NSMutableArray() + elementArray.add("adAttribution") + let instance = TestAd.customInit() + instance.testElements = elementArray + let value = try? api.pigeonDelegate.uiElements(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, [UIElementType.adAttribution]) + } + + func testWidth() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.width(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(try XCTUnwrap(value), Int64(instance.width)) + } + + func testHeight() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.height(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(try XCTUnwrap(value), Int64(instance.height)) + } + + func testVastMediaWidth() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.vastMediaWidth(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(try XCTUnwrap(value), Int64(instance.vastMediaWidth)) + } + + func testVastMediaHeight() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.vastMediaHeight(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(try XCTUnwrap(value), Int64(instance.vastMediaHeight)) + } + + func testVastMediaBitrate() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.vastMediaBitrate(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(try XCTUnwrap(value), Int64(instance.vastMediaBitrate)) + } + + func testIsLinear() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.isLinear(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.isLinear) + } + + func testIsSkippable() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.isSkippable(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.isSkippable) + } + + func testSkipTimeOffset() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.skipTimeOffset(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.skipTimeOffset) + } + + @MainActor func testAdPodInfo() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.adPodInfo(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adPodInfo) + } + + func testTraffickingParameters() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.traffickingParameters( + pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.traffickingParameters) + } + + func testCreativeID() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.creativeID(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.creativeID) + } + + func testCreativeAdID() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.creativeAdID(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.creativeAdID) + } + + @MainActor func testUniversalAdIDs() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try! api.pigeonDelegate.universalAdIDs(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.universalAdIDs) + } + + func testAdvertiserName() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.advertiserName(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.advertiserName) + } + + func testSurveyURL() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.surveyURL(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.surveyURL) + } + + func testDealID() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.dealID(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.dealID) + } + + func testWrapperAdIDs() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.wrapperAdIDs(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.wrapperAdIDs) + } + + func testWrapperCreativeIDs() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.wrapperCreativeIDs(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.wrapperCreativeIDs) + } + + func testWrapperSystems() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAAd(registrar) + + let instance = TestAd.customInit() + let value = try? api.pigeonDelegate.wrapperSystems(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.wrapperSystems) + } +} + +class TestAd: IMAAd { + // Workaround to subclass an Objective-C class that has an `init` constructor with NS_UNAVAILABLE + static func customInit() -> TestAd { + let instance = + TestAd.perform(NSSelectorFromString("new")).takeRetainedValue() as! TestAd + instance._companionAd = TestCompanionAd.customInit() + instance._universalAdID = TestUniversalAdID.customInit() + instance._adPodInfo = TestAdPodInfo.customInit() + return instance + } + + var _companionAd: TestCompanionAd? + var _adPodInfo: TestAdPodInfo? + var _universalAdID: TestUniversalAdID? + + var testElements: NSArray = NSArray() + + override var adId: String { + return "string1" + } + + override var adTitle: String { + return "string2" + } + + override var adDescription: String { + return "string3" + } + + override var adSystem: String { + return "string4" + } + + override var companionAds: [IMACompanionAd] { + return [_companionAd!] + } + + override var contentType: String { + return "string5" + } + + override var duration: TimeInterval { + return 9.0 + } + + override var uiElements: [NSNumber] { + return testElements as! [NSNumber] + } + + override var width: Int { + return 0 + } + + override var height: Int { + return 1 + } + + override var vastMediaWidth: Int { + return 2 + } + + override var vastMediaHeight: Int { + return 3 + } + + override var vastMediaBitrate: Int { + return 4 + } + + override var isLinear: Bool { + return true + } + + override var isSkippable: Bool { + return false + } + + override var skipTimeOffset: TimeInterval { + return 3.0 + } + + override var adPodInfo: IMAAdPodInfo { + return _adPodInfo! + } + + override var traffickingParameters: String { + return "string123" + } + + override var creativeID: String { + return "string6" + } + + override var creativeAdID: String { + return "string7" + } + + override var universalAdIDs: [IMAUniversalAdID] { + return [_universalAdID!] + } + + override var advertiserName: String { + return "string8" + } + + override var surveyURL: String? { + return "string10" + } + + override var dealID: String { + return "string9" + } + + override var wrapperAdIDs: [String] { + return ["string1"] + } + + override var wrapperCreativeIDs: [String] { + return ["string2"] + } + + override var wrapperSystems: [String] { + return ["string3"] + } +} diff --git a/packages/interactive_media_ads/example/ios/RunnerTests/UniversalAdIDProxyAPITests.swift b/packages/interactive_media_ads/example/ios/RunnerTests/UniversalAdIDProxyAPITests.swift new file mode 100644 index 00000000000..fb510abc88e --- /dev/null +++ b/packages/interactive_media_ads/example/ios/RunnerTests/UniversalAdIDProxyAPITests.swift @@ -0,0 +1,49 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Flutter +import GoogleInteractiveMediaAds +import XCTest + +@testable import interactive_media_ads + +class UniversalAdIDProxyAPITests: XCTestCase { + func testAdIDValue() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAUniversalAdID(registrar) + + let instance = TestUniversalAdID.customInit() + let value = try? api.pigeonDelegate.adIDValue(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adIDValue) + } + + func testAdIDRegistry() { + let registrar = TestProxyApiRegistrar() + let api = registrar.apiDelegate.pigeonApiIMAUniversalAdID(registrar) + + let instance = TestUniversalAdID.customInit() + let value = try? api.pigeonDelegate.adIDRegistry(pigeonApi: api, pigeonInstance: instance) + + XCTAssertEqual(value, instance.adIDRegistry) + } +} + +class TestUniversalAdID: IMAUniversalAdID { + // Workaround to subclass an Objective-C class that has an `init` constructor with NS_UNAVAILABLE + static func customInit() -> TestUniversalAdID { + let instance = + TestUniversalAdID.perform(NSSelectorFromString("new")).takeRetainedValue() + as! TestUniversalAdID + return instance + } + + override var adIDValue: String { + return "string1" + } + + override var adIDRegistry: String { + return "string2" + } +} diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdEventProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdEventProxyAPIDelegate.swift index f4d018700d0..0af0c10204e 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdEventProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdEventProxyAPIDelegate.swift @@ -72,4 +72,8 @@ class AdEventProxyAPIDelegate: PigeonApiDelegateIMAAdEvent { func typeString(pigeonApi: PigeonApiIMAAdEvent, pigeonInstance: IMAAdEvent) throws -> String { return pigeonInstance.typeString } + + func ad(pigeonApi: PigeonApiIMAAdEvent, pigeonInstance: IMAAdEvent) throws -> IMAAd? { + return pigeonInstance.ad + } } diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdProxyAPIDelegate.swift new file mode 100644 index 00000000000..4205b6fd33d --- /dev/null +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdProxyAPIDelegate.swift @@ -0,0 +1,144 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Foundation +import GoogleInteractiveMediaAds + +/// ProxyApi implementation for `IMAAd`. +/// +/// This class may handle instantiating native object instances that are attached to a Dart instance +/// or handle method calls on the associated native class or an instance of that class. +class AdProxyAPIDelegate: PigeonApiDelegateIMAAd { + func adId(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.adId + } + + func adTitle(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.adTitle + } + + func adDescription(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.adDescription + } + + func adSystem(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.adSystem + } + + func companionAds(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [IMACompanionAd] { + return pigeonInstance.companionAds + } + + func contentType(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.contentType + } + + func duration(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Double { + return pigeonInstance.duration + } + + func uiElements(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [UIElementType] { + var uiElements: [UIElementType] = [] + let uiElementsArray = pigeonInstance.uiElements as NSArray + // IMAAd.uiElements is expected to be NSArray, but is returning as + // an NSArray and causing a crash when using Swift. This attempts + // to handle both scenarios and returns UIElementType.unknown if the value + // can't be handled. + for uiElement in uiElementsArray { + switch uiElement { + case let uiElement as String where uiElement == "adAttribution": + uiElements.append(UIElementType.adAttribution) + case let uiElement as NSNumber + where uiElement.intValue == IMAUiElementType.elements_AD_ATTRIBUTION.rawValue: + uiElements.append(UIElementType.adAttribution) + case let uiElement as String where uiElement == "countdown": + uiElements.append(UIElementType.countdown) + case let uiElement as NSNumber + where uiElement.intValue == IMAUiElementType.elements_COUNTDOWN.rawValue: + uiElements.append(UIElementType.countdown) + default: + uiElements.append(UIElementType.unknown) + } + } + return uiElements + } + + func width(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 { + return Int64(pigeonInstance.width) + } + + func height(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 { + return Int64(pigeonInstance.height) + } + + func vastMediaWidth(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 { + return Int64(pigeonInstance.vastMediaWidth) + } + + func vastMediaHeight(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 { + return Int64(pigeonInstance.vastMediaHeight) + } + + func vastMediaBitrate(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 { + return Int64(pigeonInstance.vastMediaBitrate) + } + + func isLinear(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Bool { + return pigeonInstance.isLinear + } + + func isSkippable(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Bool { + return pigeonInstance.isSkippable + } + + func skipTimeOffset(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Double { + return pigeonInstance.skipTimeOffset + } + + func adPodInfo(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> IMAAdPodInfo { + return pigeonInstance.adPodInfo + } + + func traffickingParameters(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.traffickingParameters + } + + func creativeID(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.creativeID + } + + func creativeAdID(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.creativeAdID + } + + func universalAdIDs(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [IMAUniversalAdID] + { + return pigeonInstance.universalAdIDs + } + + func advertiserName(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.advertiserName + } + + func surveyURL(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String? { + return pigeonInstance.surveyURL + } + + func dealID(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String { + return pigeonInstance.dealID + } + + func wrapperAdIDs(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [String] { + return pigeonInstance.wrapperAdIDs + } + + func wrapperCreativeIDs(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [String] { + return pigeonInstance.wrapperCreativeIDs + } + + func wrapperSystems(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [String] { + return pigeonInstance.wrapperSystems + } + +} diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift index d98862c976d..baf2bcab164 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift @@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest { /// The current version of the `interactive_media_ads` plugin. /// /// This must match the version in pubspec.yaml. - static let pluginVersion = "0.2.6+2" + static let pluginVersion = "0.2.6+3" func pigeonDefaultConstructor( pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer, diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/FriendlyObstructionAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/FriendlyObstructionProxyAPIDelegate.swift similarity index 100% rename from packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/FriendlyObstructionAPIDelegate.swift rename to packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/FriendlyObstructionProxyAPIDelegate.swift diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/InteractiveMediaAdsLibrary.g.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/InteractiveMediaAdsLibrary.g.swift index a7c0614893d..8faa555dafe 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/InteractiveMediaAdsLibrary.g.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/InteractiveMediaAdsLibrary.g.swift @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -472,6 +472,14 @@ protocol InteractiveMediaAdsLibraryPigeonProxyApiDelegate { /// `IMAAdPodInfo` to the Dart `InstanceManager` and make calls to Dart. func pigeonApiIMAAdPodInfo(_ registrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar) -> PigeonApiIMAAdPodInfo + /// An implementation of [PigeonApiIMAAd] used to add a new Dart instance of + /// `IMAAd` to the Dart `InstanceManager` and make calls to Dart. + func pigeonApiIMAAd(_ registrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar) + -> PigeonApiIMAAd + /// An implementation of [PigeonApiIMAUniversalAdID] used to add a new Dart instance of + /// `IMAUniversalAdID` to the Dart `InstanceManager` and make calls to Dart. + func pigeonApiIMAUniversalAdID(_ registrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar) + -> PigeonApiIMAUniversalAdID } extension InteractiveMediaAdsLibraryPigeonProxyApiDelegate { @@ -846,8 +854,8 @@ private class InteractiveMediaAdsLibraryPigeonInternalProxyApiCodecReaderWriter: return } - if let instance = value as? NSObject { - pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar).pigeonNewInstance( + if let instance = value as? IMAAdPodInfo { + pigeonRegistrar.apiDelegate.pigeonApiIMAAdPodInfo(pigeonRegistrar).pigeonNewInstance( pigeonInstance: instance ) { _ in } super.writeByte(128) @@ -857,8 +865,30 @@ private class InteractiveMediaAdsLibraryPigeonInternalProxyApiCodecReaderWriter: return } - if let instance = value as? IMAAdPodInfo { - pigeonRegistrar.apiDelegate.pigeonApiIMAAdPodInfo(pigeonRegistrar).pigeonNewInstance( + if let instance = value as? IMAAd { + pigeonRegistrar.apiDelegate.pigeonApiIMAAd(pigeonRegistrar).pigeonNewInstance( + pigeonInstance: instance + ) { _ in } + super.writeByte(128) + super.writeValue( + pigeonRegistrar.instanceManager.identifierWithStrongReference( + forInstance: instance as AnyObject)!) + return + } + + if let instance = value as? IMAUniversalAdID { + pigeonRegistrar.apiDelegate.pigeonApiIMAUniversalAdID(pigeonRegistrar).pigeonNewInstance( + pigeonInstance: instance + ) { _ in } + super.writeByte(128) + super.writeValue( + pigeonRegistrar.instanceManager.identifierWithStrongReference( + forInstance: instance as AnyObject)!) + return + } + + if let instance = value as? NSObject { + pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar).pigeonNewInstance( pigeonInstance: instance ) { _ in } super.writeByte(128) @@ -3606,6 +3636,11 @@ protocol PigeonApiDelegateIMAAdEvent { func typeString(pigeonApi: PigeonApiIMAAdEvent, pigeonInstance: IMAAdEvent) throws -> String /// Extra data about the ad. func adData(pigeonApi: PigeonApiIMAAdEvent, pigeonInstance: IMAAdEvent) throws -> [String: Any]? + /// The current ad that is playing or just played. + /// + /// This will be null except for events where an ad is available (start, + /// quartiles, midpoint, complete, and tap). + func ad(pigeonApi: PigeonApiIMAAdEvent, pigeonInstance: IMAAdEvent) throws -> IMAAd? } protocol PigeonApiProtocolIMAAdEvent { @@ -3645,14 +3680,16 @@ final class PigeonApiIMAAdEvent: PigeonApiProtocolIMAAdEvent { let typeStringArg = try! pigeonDelegate.typeString( pigeonApi: self, pigeonInstance: pigeonInstance) let adDataArg = try! pigeonDelegate.adData(pigeonApi: self, pigeonInstance: pigeonInstance) + let adArg = try! pigeonDelegate.ad(pigeonApi: self, pigeonInstance: pigeonInstance) let binaryMessenger = pigeonRegistrar.binaryMessenger let codec = pigeonRegistrar.codec let channelName: String = "dev.flutter.pigeon.interactive_media_ads.IMAAdEvent.pigeon_newInstance" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([pigeonIdentifierArg, typeArg, typeStringArg, adDataArg] as [Any?]) { - response in + channel.sendMessage( + [pigeonIdentifierArg, typeArg, typeStringArg, adDataArg, adArg] as [Any?] + ) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -4222,6 +4259,11 @@ protocol PigeonApiProtocolIMACompanionAdSlot { final class PigeonApiIMACompanionAdSlot: PigeonApiProtocolIMACompanionAdSlot { unowned let pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar let pigeonDelegate: PigeonApiDelegateIMACompanionAdSlot + ///An implementation of [NSObject] used to access callback methods + var pigeonApiNSObject: PigeonApiNSObject { + return pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar) + } + init( pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar, delegate: PigeonApiDelegateIMACompanionAdSlot @@ -4593,6 +4635,11 @@ protocol PigeonApiProtocolIMAAdPodInfo { final class PigeonApiIMAAdPodInfo: PigeonApiProtocolIMAAdPodInfo { unowned let pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar let pigeonDelegate: PigeonApiDelegateIMAAdPodInfo + ///An implementation of [NSObject] used to access callback methods + var pigeonApiNSObject: PigeonApiNSObject { + return pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar) + } + init( pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar, delegate: PigeonApiDelegateIMAAdPodInfo @@ -4655,3 +4702,271 @@ final class PigeonApiIMAAdPodInfo: PigeonApiProtocolIMAAdPodInfo { } } } +protocol PigeonApiDelegateIMAAd { + /// The ad ID as specified in the VAST response. + func adId(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The ad title from the VAST response. + func adTitle(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The ad description. + func adDescription(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The source ad server information included in the ad response. + func adSystem(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The companion ads specified in the VAST response when using DAI. + /// + /// Empty for client-side ads. + func companionAds(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [IMACompanionAd] + /// Content type of the currently selected creative. + /// + /// For linear creatives returns the content type of the currently selected + /// media file. Returns empty string if no creative or media file is selected + /// on this ad. + func contentType(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The duration of the ad from the VAST response. + func duration(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Double + /// The UI elements that will be displayed during ad playback. + func uiElements(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [UIElementType] + /// The width of the ad asset. + /// + /// For non-linear ads, this is the actual width of the ad representation. + /// For linear ads, since they scale seamlessly, we currently return 0 for + /// width. + func width(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 + /// The height of the ad asset. + /// + /// For non-linear ads, this is the actual height of the ad representation. + /// For linear ads, since they scale seamlessly, we currently return 0 for + /// height. + func height(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 + /// The width of the selected creative as specified in the VAST response. + func vastMediaWidth(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 + /// The height of the selected creative as specified in the VAST response. + func vastMediaHeight(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 + /// The bitrate of the selected creative as specified in the VAST response. + func vastMediaBitrate(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Int64 + /// Specifies whether the ad is linear or non-linear. + func isLinear(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Bool + /// Specifies whether the ad is skippable. + func isSkippable(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Bool + /// The number of seconds of playback before the ad becomes skippable. + /// + /// -1 is returned for non skippable ads or if this is unavailable. + func skipTimeOffset(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> Double + /// Set of ad podding properties. + func adPodInfo(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> IMAAdPodInfo + /// String representing custom trafficking parameters from the VAST response. + func traffickingParameters(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// Returns the ID of the selected creative for the ad. + func creativeID(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// Returns the ISCI (Industry Standard Commercial Identifier) code for an ad. + /// + /// This is the Ad-ID of the selected creative in the VAST response. + func creativeAdID(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The list of all UniversalAdIds of the selected creative for this ad. + /// + /// Returns an empty array if no universal ad IDs are found. + func universalAdIDs(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [IMAUniversalAdID] + /// The advertiser name as defined by the serving party. + func advertiserName(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// Returns the URL associated with the survey for the given ad. + func surveyURL(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String? + /// Returns the first deal ID present in the wrapper chain for the current ad, + /// starting from the top. + func dealID(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> String + /// The IDs of the ads, starting with the first wrapper ad. + func wrapperAdIDs(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [String] + /// The IDs of the ads’ creatives, starting with the first wrapper ad. + func wrapperCreativeIDs(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [String] + /// Ad systems used for wrapper ads. + /// + /// The ad systems returned begin with the first wrapper ad and continue to + /// each wrapper ad recursively. + func wrapperSystems(pigeonApi: PigeonApiIMAAd, pigeonInstance: IMAAd) throws -> [String] +} + +protocol PigeonApiProtocolIMAAd { +} + +final class PigeonApiIMAAd: PigeonApiProtocolIMAAd { + unowned let pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar + let pigeonDelegate: PigeonApiDelegateIMAAd + ///An implementation of [NSObject] used to access callback methods + var pigeonApiNSObject: PigeonApiNSObject { + return pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar) + } + + init( + pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar, + delegate: PigeonApiDelegateIMAAd + ) { + self.pigeonRegistrar = pigeonRegistrar + self.pigeonDelegate = delegate + } + ///Creates a Dart instance of IMAAd and attaches it to [pigeonInstance]. + func pigeonNewInstance( + pigeonInstance: IMAAd, completion: @escaping (Result) -> Void + ) { + if pigeonRegistrar.ignoreCallsToDart { + completion( + .failure( + PigeonError( + code: "ignore-calls-error", + message: "Calls to Dart are being ignored.", details: ""))) + } else if pigeonRegistrar.instanceManager.containsInstance(pigeonInstance as AnyObject) { + completion(.success(())) + } else { + let pigeonIdentifierArg = pigeonRegistrar.instanceManager.addHostCreatedInstance( + pigeonInstance as AnyObject) + let adIdArg = try! pigeonDelegate.adId(pigeonApi: self, pigeonInstance: pigeonInstance) + let adTitleArg = try! pigeonDelegate.adTitle(pigeonApi: self, pigeonInstance: pigeonInstance) + let adDescriptionArg = try! pigeonDelegate.adDescription( + pigeonApi: self, pigeonInstance: pigeonInstance) + let adSystemArg = try! pigeonDelegate.adSystem( + pigeonApi: self, pigeonInstance: pigeonInstance) + let companionAdsArg = try! pigeonDelegate.companionAds( + pigeonApi: self, pigeonInstance: pigeonInstance) + let contentTypeArg = try! pigeonDelegate.contentType( + pigeonApi: self, pigeonInstance: pigeonInstance) + let durationArg = try! pigeonDelegate.duration( + pigeonApi: self, pigeonInstance: pigeonInstance) + let uiElementsArg = try! pigeonDelegate.uiElements( + pigeonApi: self, pigeonInstance: pigeonInstance) + let widthArg = try! pigeonDelegate.width(pigeonApi: self, pigeonInstance: pigeonInstance) + let heightArg = try! pigeonDelegate.height(pigeonApi: self, pigeonInstance: pigeonInstance) + let vastMediaWidthArg = try! pigeonDelegate.vastMediaWidth( + pigeonApi: self, pigeonInstance: pigeonInstance) + let vastMediaHeightArg = try! pigeonDelegate.vastMediaHeight( + pigeonApi: self, pigeonInstance: pigeonInstance) + let vastMediaBitrateArg = try! pigeonDelegate.vastMediaBitrate( + pigeonApi: self, pigeonInstance: pigeonInstance) + let isLinearArg = try! pigeonDelegate.isLinear( + pigeonApi: self, pigeonInstance: pigeonInstance) + let isSkippableArg = try! pigeonDelegate.isSkippable( + pigeonApi: self, pigeonInstance: pigeonInstance) + let skipTimeOffsetArg = try! pigeonDelegate.skipTimeOffset( + pigeonApi: self, pigeonInstance: pigeonInstance) + let adPodInfoArg = try! pigeonDelegate.adPodInfo( + pigeonApi: self, pigeonInstance: pigeonInstance) + let traffickingParametersArg = try! pigeonDelegate.traffickingParameters( + pigeonApi: self, pigeonInstance: pigeonInstance) + let creativeIDArg = try! pigeonDelegate.creativeID( + pigeonApi: self, pigeonInstance: pigeonInstance) + let creativeAdIDArg = try! pigeonDelegate.creativeAdID( + pigeonApi: self, pigeonInstance: pigeonInstance) + let universalAdIDsArg = try! pigeonDelegate.universalAdIDs( + pigeonApi: self, pigeonInstance: pigeonInstance) + let advertiserNameArg = try! pigeonDelegate.advertiserName( + pigeonApi: self, pigeonInstance: pigeonInstance) + let surveyURLArg = try! pigeonDelegate.surveyURL( + pigeonApi: self, pigeonInstance: pigeonInstance) + let dealIDArg = try! pigeonDelegate.dealID(pigeonApi: self, pigeonInstance: pigeonInstance) + let wrapperAdIDsArg = try! pigeonDelegate.wrapperAdIDs( + pigeonApi: self, pigeonInstance: pigeonInstance) + let wrapperCreativeIDsArg = try! pigeonDelegate.wrapperCreativeIDs( + pigeonApi: self, pigeonInstance: pigeonInstance) + let wrapperSystemsArg = try! pigeonDelegate.wrapperSystems( + pigeonApi: self, pigeonInstance: pigeonInstance) + let binaryMessenger = pigeonRegistrar.binaryMessenger + let codec = pigeonRegistrar.codec + let channelName: String = "dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage( + [ + pigeonIdentifierArg, adIdArg, adTitleArg, adDescriptionArg, adSystemArg, companionAdsArg, + contentTypeArg, durationArg, uiElementsArg, widthArg, heightArg, vastMediaWidthArg, + vastMediaHeightArg, vastMediaBitrateArg, isLinearArg, isSkippableArg, skipTimeOffsetArg, + adPodInfoArg, traffickingParametersArg, creativeIDArg, creativeAdIDArg, universalAdIDsArg, + advertiserNameArg, surveyURLArg, dealIDArg, wrapperAdIDsArg, wrapperCreativeIDsArg, + wrapperSystemsArg, + ] as [Any?] + ) { response in + guard let listResponse = response as? [Any?] else { + completion(.failure(createConnectionError(withChannelName: channelName))) + return + } + if listResponse.count > 1 { + let code: String = listResponse[0] as! String + let message: String? = nilOrValue(listResponse[1]) + let details: String? = nilOrValue(listResponse[2]) + completion(.failure(PigeonError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } + } +} +protocol PigeonApiDelegateIMAUniversalAdID { + /// The universal ad ID value. + /// + /// This will be “unknown” if it isn’t defined by the ad. + func adIDValue(pigeonApi: PigeonApiIMAUniversalAdID, pigeonInstance: IMAUniversalAdID) throws + -> String + /// The universal ad ID registry with which the value is registered. + /// + /// This will be “unknown” if it isn’t defined by the ad. + func adIDRegistry(pigeonApi: PigeonApiIMAUniversalAdID, pigeonInstance: IMAUniversalAdID) throws + -> String +} + +protocol PigeonApiProtocolIMAUniversalAdID { +} + +final class PigeonApiIMAUniversalAdID: PigeonApiProtocolIMAUniversalAdID { + unowned let pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar + let pigeonDelegate: PigeonApiDelegateIMAUniversalAdID + ///An implementation of [NSObject] used to access callback methods + var pigeonApiNSObject: PigeonApiNSObject { + return pigeonRegistrar.apiDelegate.pigeonApiNSObject(pigeonRegistrar) + } + + init( + pigeonRegistrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar, + delegate: PigeonApiDelegateIMAUniversalAdID + ) { + self.pigeonRegistrar = pigeonRegistrar + self.pigeonDelegate = delegate + } + ///Creates a Dart instance of IMAUniversalAdID and attaches it to [pigeonInstance]. + func pigeonNewInstance( + pigeonInstance: IMAUniversalAdID, completion: @escaping (Result) -> Void + ) { + if pigeonRegistrar.ignoreCallsToDart { + completion( + .failure( + PigeonError( + code: "ignore-calls-error", + message: "Calls to Dart are being ignored.", details: ""))) + } else if pigeonRegistrar.instanceManager.containsInstance(pigeonInstance as AnyObject) { + completion(.success(())) + } else { + let pigeonIdentifierArg = pigeonRegistrar.instanceManager.addHostCreatedInstance( + pigeonInstance as AnyObject) + let adIDValueArg = try! pigeonDelegate.adIDValue( + pigeonApi: self, pigeonInstance: pigeonInstance) + let adIDRegistryArg = try! pigeonDelegate.adIDRegistry( + pigeonApi: self, pigeonInstance: pigeonInstance) + let binaryMessenger = pigeonRegistrar.binaryMessenger + let codec = pigeonRegistrar.codec + let channelName: String = + "dev.flutter.pigeon.interactive_media_ads.IMAUniversalAdID.pigeon_newInstance" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([pigeonIdentifierArg, adIDValueArg, adIDRegistryArg] as [Any?]) { + response in + guard let listResponse = response as? [Any?] else { + completion(.failure(createConnectionError(withChannelName: channelName))) + return + } + if listResponse.count > 1 { + let code: String = listResponse[0] as! String + let message: String? = nilOrValue(listResponse[1]) + let details: String? = nilOrValue(listResponse[2]) + completion(.failure(PigeonError(code: code, message: message, details: details))) + } else { + completion(.success(())) + } + } + } + } +} diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/ProxyApiDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/ProxyApiDelegate.swift index 3a14efd82e4..63e83d1f1e5 100644 --- a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/ProxyApiDelegate.swift +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/ProxyApiDelegate.swift @@ -165,4 +165,17 @@ open class ProxyApiDelegate: InteractiveMediaAdsLibraryPigeonProxyApiDelegate { { return PigeonApiIMASettings(pigeonRegistrar: registrar, delegate: SettingsProxyAPIDelegate()) } + + func pigeonApiIMAAd(_ registrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar) + -> PigeonApiIMAAd + { + return PigeonApiIMAAd(pigeonRegistrar: registrar, delegate: AdProxyAPIDelegate()) + } + + func pigeonApiIMAUniversalAdID(_ registrar: InteractiveMediaAdsLibraryPigeonProxyApiRegistrar) + -> PigeonApiIMAUniversalAdID + { + return PigeonApiIMAUniversalAdID( + pigeonRegistrar: registrar, delegate: UniversalAdIDProxyAPIDelegate()) + } } diff --git a/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/UniversalAdIDProxyAPIDelegate.swift b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/UniversalAdIDProxyAPIDelegate.swift new file mode 100644 index 00000000000..7230829bb8e --- /dev/null +++ b/packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/UniversalAdIDProxyAPIDelegate.swift @@ -0,0 +1,24 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import Foundation +import GoogleInteractiveMediaAds + +/// ProxyApi implementation for `IMAUniversalAdID`. +/// +/// This class may handle instantiating native object instances that are attached to a Dart instance +/// or handle method calls on the associated native class or an instance of that class. +class UniversalAdIDProxyAPIDelegate: PigeonApiDelegateIMAUniversalAdID { + func adIDValue(pigeonApi: PigeonApiIMAUniversalAdID, pigeonInstance: IMAUniversalAdID) throws + -> String + { + return pigeonInstance.adIDValue + } + + func adIDRegistry(pigeonApi: PigeonApiIMAUniversalAdID, pigeonInstance: IMAUniversalAdID) throws + -> String + { + return pigeonInstance.adIDRegistry + } +} diff --git a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart index 2b382216ef8..ac2d1955846 100644 --- a/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/android/interactive_media_ads.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -32,8 +32,8 @@ List wrapResponse( return [error.code, error.message, error.details]; } -/// Provides overrides for the constructors and static members of each proxy -/// API. +/// Provides overrides for the constructors and static members of each +/// Dart proxy class. /// /// This is only intended to be used with unit tests to prevent errors from /// making message calls in a unit test. @@ -156,8 +156,8 @@ class PigeonOverrides { } } -/// An immutable object that serves as the base class for all ProxyApis and -/// can provide functional copies of itself. +/// An immutable object that serves as the base class for all Dart proxy classes +/// and can provide functional copies of itself. /// /// All implementers are expected to be [immutable] as defined by the annotation /// and override [pigeon_copy] returning an instance of itself. @@ -222,7 +222,7 @@ class PigeonInstanceManager { // 0 <= n < 2^16. static const int _maxDartCreatedIdentifier = 65536; - /// The default [PigeonInstanceManager] used by ProxyApis. + /// The default [PigeonInstanceManager] used by Dart proxy classes. /// /// On creation, this manager makes a call to clear the native /// InstanceManager. This is to prevent identifier conflicts after a host @@ -2677,7 +2677,7 @@ class BaseManager extends PigeonInternalProxyApiBaseClass { /// Event to notify publisher that an event occurred with an Ad. /// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/kotlin/com/google/ads/interactivemedia/v3/api/AdEvent. class AdEvent extends PigeonInternalProxyApiBaseClass { /// Constructs [AdEvent] without creating the associated native object. /// @@ -2689,6 +2689,7 @@ class AdEvent extends PigeonInternalProxyApiBaseClass { super.pigeon_instanceManager, required this.type, this.adData, + this.ad, }); /// The type of event that occurred. @@ -2697,6 +2698,9 @@ class AdEvent extends PigeonInternalProxyApiBaseClass { /// A map containing any extra ad data for the event, if needed. final Map? adData; + /// The ad with which this event is associated. + final Ad? ad; + static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, BinaryMessenger? pigeon_binaryMessenger, @@ -2704,6 +2708,7 @@ class AdEvent extends PigeonInternalProxyApiBaseClass { AdEvent Function( AdEventType type, Map? adData, + Ad? ad, )? pigeon_newInstance, }) { final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = @@ -2732,15 +2737,17 @@ class AdEvent extends PigeonInternalProxyApiBaseClass { 'Argument for dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance was null, expected non-null AdEventType.'); final Map? arg_adData = (args[2] as Map?)?.cast(); + final Ad? arg_ad = (args[3] as Ad?); try { (pigeon_instanceManager ?? PigeonInstanceManager.instance) .addHostCreatedInstance( - pigeon_newInstance?.call(arg_type!, arg_adData) ?? + pigeon_newInstance?.call(arg_type!, arg_adData, arg_ad) ?? AdEvent.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, type: arg_type!, adData: arg_adData, + ad: arg_ad, ), arg_pigeon_instanceIdentifier!, ); @@ -2763,6 +2770,7 @@ class AdEvent extends PigeonInternalProxyApiBaseClass { pigeon_instanceManager: pigeon_instanceManager, type: type, adData: adData, + ad: ad, ); } } diff --git a/packages/interactive_media_ads/lib/src/ios/interactive_media_ads.g.dart b/packages/interactive_media_ads/lib/src/ios/interactive_media_ads.g.dart index 0b3b490a609..5ecff6b7542 100644 --- a/packages/interactive_media_ads/lib/src/ios/interactive_media_ads.g.dart +++ b/packages/interactive_media_ads/lib/src/ios/interactive_media_ads.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.0.0), do not edit directly. +// Autogenerated from Pigeon (v26.0.1), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -32,8 +32,8 @@ List wrapResponse( return [error.code, error.message, error.details]; } -/// Provides overrides for the constructors and static members of each proxy -/// API. +/// Provides overrides for the constructors and static members of each +/// Dart proxy class. /// /// This is only intended to be used with unit tests to prevent errors from /// making message calls in a unit test. @@ -171,8 +171,8 @@ class PigeonOverrides { } } -/// An immutable object that serves as the base class for all ProxyApis and -/// can provide functional copies of itself. +/// An immutable object that serves as the base class for all Dart proxy classes +/// and can provide functional copies of itself. /// /// All implementers are expected to be [immutable] as defined by the annotation /// and override [pigeon_copy] returning an instance of itself. @@ -237,7 +237,7 @@ class PigeonInstanceManager { // 0 <= n < 2^16. static const int _maxDartCreatedIdentifier = 65536; - /// The default [PigeonInstanceManager] used by ProxyApis. + /// The default [PigeonInstanceManager] used by Dart proxy classes. /// /// On creation, this manager makes a call to clear the native /// InstanceManager. This is to prevent identifier conflicts after a host @@ -321,6 +321,9 @@ class PigeonInstanceManager { pigeon_instanceManager: instanceManager); IMAAdPodInfo.pigeon_setUpMessageHandlers( pigeon_instanceManager: instanceManager); + IMAAd.pigeon_setUpMessageHandlers(pigeon_instanceManager: instanceManager); + IMAUniversalAdID.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); return instanceManager; } @@ -4364,6 +4367,7 @@ class IMAAdEvent extends NSObject { required this.type, required this.typeString, this.adData, + this.ad, }) : super.pigeon_detached(); /// Type of the event. @@ -4375,6 +4379,12 @@ class IMAAdEvent extends NSObject { /// Extra data about the ad. final Map? adData; + /// The current ad that is playing or just played. + /// + /// This will be null except for events where an ad is available (start, + /// quartiles, midpoint, complete, and tap). + final IMAAd? ad; + static void pigeon_setUpMessageHandlers({ bool pigeon_clearHandlers = false, BinaryMessenger? pigeon_binaryMessenger, @@ -4383,6 +4393,7 @@ class IMAAdEvent extends NSObject { AdEventType type, String typeString, Map? adData, + IMAAd? ad, )? pigeon_newInstance, }) { final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = @@ -4414,17 +4425,19 @@ class IMAAdEvent extends NSObject { 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAdEvent.pigeon_newInstance was null, expected non-null String.'); final Map? arg_adData = (args[3] as Map?)?.cast(); + final IMAAd? arg_ad = (args[4] as IMAAd?); try { (pigeon_instanceManager ?? PigeonInstanceManager.instance) .addHostCreatedInstance( pigeon_newInstance?.call( - arg_type!, arg_typeString!, arg_adData) ?? + arg_type!, arg_typeString!, arg_adData, arg_ad) ?? IMAAdEvent.pigeon_detached( pigeon_binaryMessenger: pigeon_binaryMessenger, pigeon_instanceManager: pigeon_instanceManager, type: arg_type!, typeString: arg_typeString!, adData: arg_adData, + ad: arg_ad, ), arg_pigeon_instanceIdentifier!, ); @@ -4448,6 +4461,7 @@ class IMAAdEvent extends NSObject { type: type, typeString: typeString, adData: adData, + ad: ad, ); } } @@ -5165,7 +5179,7 @@ class IMACompanionAd extends NSObject { /// Ad slot for companion ads. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMACompanionAdSlot. -class IMACompanionAdSlot extends PigeonInternalProxyApiBaseClass { +class IMACompanionAdSlot extends NSObject { /// Initializes an instance of a IMACompanionAdSlot with fluid size. factory IMACompanionAdSlot({ BinaryMessenger? pigeon_binaryMessenger, @@ -5188,7 +5202,7 @@ class IMACompanionAdSlot extends PigeonInternalProxyApiBaseClass { super.pigeon_binaryMessenger, super.pigeon_instanceManager, required this.view, - }) { + }) : super.pigeon_detached() { final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = @@ -5259,7 +5273,7 @@ class IMACompanionAdSlot extends PigeonInternalProxyApiBaseClass { required this.view, required int width, required int height, - }) { + }) : super.pigeon_detached() { final int pigeonVar_instanceIdentifier = pigeon_instanceManager.addDartCreatedInstance(this); final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = @@ -5301,7 +5315,7 @@ class IMACompanionAdSlot extends PigeonInternalProxyApiBaseClass { super.pigeon_binaryMessenger, super.pigeon_instanceManager, required this.view, - }); + }) : super.pigeon_detached(); late final _PigeonInternalProxyApiBaseCodec _pigeonVar_codecIMACompanionAdSlot = @@ -5761,7 +5775,7 @@ class IMACompanionDelegate extends NSObject { /// Simple data object containing podding metadata. /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAAdPodInfo.html. -class IMAAdPodInfo extends PigeonInternalProxyApiBaseClass { +class IMAAdPodInfo extends NSObject { /// Constructs [IMAAdPodInfo] without creating the associated native object. /// /// This should only be used by subclasses created by this library or to @@ -5776,7 +5790,7 @@ class IMAAdPodInfo extends PigeonInternalProxyApiBaseClass { required this.timeOffset, required this.totalAds, required this.isBumper, - }); + }) : super.pigeon_detached(); /// The position of this ad within an ad pod. /// @@ -5919,3 +5933,498 @@ class IMAAdPodInfo extends PigeonInternalProxyApiBaseClass { ); } } + +/// Data object representing a single ad. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAAd. +class IMAAd extends NSObject { + /// Constructs [IMAAd] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + IMAAd.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.adId, + required this.adTitle, + required this.adDescription, + required this.adSystem, + required this.companionAds, + required this.contentType, + required this.duration, + required this.uiElements, + required this.width, + required this.height, + required this.vastMediaWidth, + required this.vastMediaHeight, + required this.vastMediaBitrate, + required this.isLinear, + required this.isSkippable, + required this.skipTimeOffset, + required this.adPodInfo, + required this.traffickingParameters, + required this.creativeID, + required this.creativeAdID, + required this.universalAdIDs, + required this.advertiserName, + this.surveyURL, + required this.dealID, + required this.wrapperAdIDs, + required this.wrapperCreativeIDs, + required this.wrapperSystems, + }) : super.pigeon_detached(); + + /// The ad ID as specified in the VAST response. + final String adId; + + /// The ad title from the VAST response. + final String adTitle; + + /// The ad description. + final String adDescription; + + /// The source ad server information included in the ad response. + final String adSystem; + + /// The companion ads specified in the VAST response when using DAI. + /// + /// Empty for client-side ads. + final List companionAds; + + /// Content type of the currently selected creative. + /// + /// For linear creatives returns the content type of the currently selected + /// media file. Returns empty string if no creative or media file is selected + /// on this ad. + final String contentType; + + /// The duration of the ad from the VAST response. + final double duration; + + /// The UI elements that will be displayed during ad playback. + final List uiElements; + + /// The width of the ad asset. + /// + /// For non-linear ads, this is the actual width of the ad representation. + /// For linear ads, since they scale seamlessly, we currently return 0 for + /// width. + final int width; + + /// The height of the ad asset. + /// + /// For non-linear ads, this is the actual height of the ad representation. + /// For linear ads, since they scale seamlessly, we currently return 0 for + /// height. + final int height; + + /// The width of the selected creative as specified in the VAST response. + final int vastMediaWidth; + + /// The height of the selected creative as specified in the VAST response. + final int vastMediaHeight; + + /// The bitrate of the selected creative as specified in the VAST response. + final int vastMediaBitrate; + + /// Specifies whether the ad is linear or non-linear. + final bool isLinear; + + /// Specifies whether the ad is skippable. + final bool isSkippable; + + /// The number of seconds of playback before the ad becomes skippable. + /// + /// -1 is returned for non skippable ads or if this is unavailable. + final double skipTimeOffset; + + /// Set of ad podding properties. + final IMAAdPodInfo adPodInfo; + + /// String representing custom trafficking parameters from the VAST response. + final String traffickingParameters; + + /// Returns the ID of the selected creative for the ad. + final String creativeID; + + /// Returns the ISCI (Industry Standard Commercial Identifier) code for an ad. + /// + /// This is the Ad-ID of the selected creative in the VAST response. + final String creativeAdID; + + /// The list of all UniversalAdIds of the selected creative for this ad. + /// + /// Returns an empty array if no universal ad IDs are found. + final List universalAdIDs; + + /// The advertiser name as defined by the serving party. + final String advertiserName; + + /// Returns the URL associated with the survey for the given ad. + final String? surveyURL; + + /// Returns the first deal ID present in the wrapper chain for the current ad, + /// starting from the top. + final String dealID; + + /// The IDs of the ads, starting with the first wrapper ad. + final List wrapperAdIDs; + + /// The IDs of the ads’ creatives, starting with the first wrapper ad. + final List wrapperCreativeIDs; + + /// Ad systems used for wrapper ads. + /// + /// The ad systems returned begin with the first wrapper ad and continue to + /// each wrapper ad recursively. + final List wrapperSystems; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + IMAAd Function( + String adId, + String adTitle, + String adDescription, + String adSystem, + List companionAds, + String contentType, + double duration, + List uiElements, + int width, + int height, + int vastMediaWidth, + int vastMediaHeight, + int vastMediaBitrate, + bool isLinear, + bool isSkippable, + double skipTimeOffset, + IMAAdPodInfo adPodInfo, + String traffickingParameters, + String creativeID, + String creativeAdID, + List universalAdIDs, + String advertiserName, + String? surveyURL, + String dealID, + List wrapperAdIDs, + List wrapperCreativeIDs, + List wrapperSystems, + )? pigeon_newInstance, + }) { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + pigeonVar_channel.setMessageHandler(null); + } else { + pigeonVar_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null int.'); + final String? arg_adId = (args[1] as String?); + assert(arg_adId != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final String? arg_adTitle = (args[2] as String?); + assert(arg_adTitle != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final String? arg_adDescription = (args[3] as String?); + assert(arg_adDescription != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final String? arg_adSystem = (args[4] as String?); + assert(arg_adSystem != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final List? arg_companionAds = + (args[5] as List?)?.cast(); + assert(arg_companionAds != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null List.'); + final String? arg_contentType = (args[6] as String?); + assert(arg_contentType != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final double? arg_duration = (args[7] as double?); + assert(arg_duration != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null double.'); + final List? arg_uiElements = + (args[8] as List?)?.cast(); + assert(arg_uiElements != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null List.'); + final int? arg_width = (args[9] as int?); + assert(arg_width != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null int.'); + final int? arg_height = (args[10] as int?); + assert(arg_height != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null int.'); + final int? arg_vastMediaWidth = (args[11] as int?); + assert(arg_vastMediaWidth != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null int.'); + final int? arg_vastMediaHeight = (args[12] as int?); + assert(arg_vastMediaHeight != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null int.'); + final int? arg_vastMediaBitrate = (args[13] as int?); + assert(arg_vastMediaBitrate != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null int.'); + final bool? arg_isLinear = (args[14] as bool?); + assert(arg_isLinear != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null bool.'); + final bool? arg_isSkippable = (args[15] as bool?); + assert(arg_isSkippable != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null bool.'); + final double? arg_skipTimeOffset = (args[16] as double?); + assert(arg_skipTimeOffset != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null double.'); + final IMAAdPodInfo? arg_adPodInfo = (args[17] as IMAAdPodInfo?); + assert(arg_adPodInfo != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null IMAAdPodInfo.'); + final String? arg_traffickingParameters = (args[18] as String?); + assert(arg_traffickingParameters != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final String? arg_creativeID = (args[19] as String?); + assert(arg_creativeID != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final String? arg_creativeAdID = (args[20] as String?); + assert(arg_creativeAdID != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final List? arg_universalAdIDs = + (args[21] as List?)?.cast(); + assert(arg_universalAdIDs != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null List.'); + final String? arg_advertiserName = (args[22] as String?); + assert(arg_advertiserName != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final String? arg_surveyURL = (args[23] as String?); + final String? arg_dealID = (args[24] as String?); + assert(arg_dealID != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null String.'); + final List? arg_wrapperAdIDs = + (args[25] as List?)?.cast(); + assert(arg_wrapperAdIDs != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null List.'); + final List? arg_wrapperCreativeIDs = + (args[26] as List?)?.cast(); + assert(arg_wrapperCreativeIDs != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null List.'); + final List? arg_wrapperSystems = + (args[27] as List?)?.cast(); + assert(arg_wrapperSystems != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAAd.pigeon_newInstance was null, expected non-null List.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call( + arg_adId!, + arg_adTitle!, + arg_adDescription!, + arg_adSystem!, + arg_companionAds!, + arg_contentType!, + arg_duration!, + arg_uiElements!, + arg_width!, + arg_height!, + arg_vastMediaWidth!, + arg_vastMediaHeight!, + arg_vastMediaBitrate!, + arg_isLinear!, + arg_isSkippable!, + arg_skipTimeOffset!, + arg_adPodInfo!, + arg_traffickingParameters!, + arg_creativeID!, + arg_creativeAdID!, + arg_universalAdIDs!, + arg_advertiserName!, + arg_surveyURL, + arg_dealID!, + arg_wrapperAdIDs!, + arg_wrapperCreativeIDs!, + arg_wrapperSystems!) ?? + IMAAd.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + adId: arg_adId!, + adTitle: arg_adTitle!, + adDescription: arg_adDescription!, + adSystem: arg_adSystem!, + companionAds: arg_companionAds!, + contentType: arg_contentType!, + duration: arg_duration!, + uiElements: arg_uiElements!, + width: arg_width!, + height: arg_height!, + vastMediaWidth: arg_vastMediaWidth!, + vastMediaHeight: arg_vastMediaHeight!, + vastMediaBitrate: arg_vastMediaBitrate!, + isLinear: arg_isLinear!, + isSkippable: arg_isSkippable!, + skipTimeOffset: arg_skipTimeOffset!, + adPodInfo: arg_adPodInfo!, + traffickingParameters: arg_traffickingParameters!, + creativeID: arg_creativeID!, + creativeAdID: arg_creativeAdID!, + universalAdIDs: arg_universalAdIDs!, + advertiserName: arg_advertiserName!, + surveyURL: arg_surveyURL, + dealID: arg_dealID!, + wrapperAdIDs: arg_wrapperAdIDs!, + wrapperCreativeIDs: arg_wrapperCreativeIDs!, + wrapperSystems: arg_wrapperSystems!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + IMAAd pigeon_copy() { + return IMAAd.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + adId: adId, + adTitle: adTitle, + adDescription: adDescription, + adSystem: adSystem, + companionAds: companionAds, + contentType: contentType, + duration: duration, + uiElements: uiElements, + width: width, + height: height, + vastMediaWidth: vastMediaWidth, + vastMediaHeight: vastMediaHeight, + vastMediaBitrate: vastMediaBitrate, + isLinear: isLinear, + isSkippable: isSkippable, + skipTimeOffset: skipTimeOffset, + adPodInfo: adPodInfo, + traffickingParameters: traffickingParameters, + creativeID: creativeID, + creativeAdID: creativeAdID, + universalAdIDs: universalAdIDs, + advertiserName: advertiserName, + surveyURL: surveyURL, + dealID: dealID, + wrapperAdIDs: wrapperAdIDs, + wrapperCreativeIDs: wrapperCreativeIDs, + wrapperSystems: wrapperSystems, + ); + } +} + +/// Simple data object containing universal ad ID information. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAUniversalAdID.html. +class IMAUniversalAdID extends NSObject { + /// Constructs [IMAUniversalAdID] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + IMAUniversalAdID.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.adIDValue, + required this.adIDRegistry, + }) : super.pigeon_detached(); + + /// The universal ad ID value. + /// + /// This will be “unknown” if it isn’t defined by the ad. + final String adIDValue; + + /// The universal ad ID registry with which the value is registered. + /// + /// This will be “unknown” if it isn’t defined by the ad. + final String adIDRegistry; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + IMAUniversalAdID Function( + String adIDValue, + String adIDRegistry, + )? pigeon_newInstance, + }) { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _PigeonInternalProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.interactive_media_ads.IMAUniversalAdID.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + pigeonVar_channel.setMessageHandler(null); + } else { + pigeonVar_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAUniversalAdID.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAUniversalAdID.pigeon_newInstance was null, expected non-null int.'); + final String? arg_adIDValue = (args[1] as String?); + assert(arg_adIDValue != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAUniversalAdID.pigeon_newInstance was null, expected non-null String.'); + final String? arg_adIDRegistry = (args[2] as String?); + assert(arg_adIDRegistry != null, + 'Argument for dev.flutter.pigeon.interactive_media_ads.IMAUniversalAdID.pigeon_newInstance was null, expected non-null String.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call(arg_adIDValue!, arg_adIDRegistry!) ?? + IMAUniversalAdID.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + adIDValue: arg_adIDValue!, + adIDRegistry: arg_adIDRegistry!, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + IMAUniversalAdID pigeon_copy() { + return IMAUniversalAdID.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + adIDValue: adIDValue, + adIDRegistry: adIDRegistry, + ); + } +} diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart index fed150aaa2d..9bd5a2b62d8 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_android.dart @@ -485,7 +485,7 @@ abstract class BaseManager { /// Event to notify publisher that an event occurred with an Ad. /// -/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html. +/// See https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/kotlin/com/google/ads/interactivemedia/v3/api/AdEvent. @ProxyApi( kotlinOptions: KotlinProxyApiOptions( fullClassName: 'com.google.ads.interactivemedia.v3.api.AdEvent', @@ -497,6 +497,9 @@ abstract class AdEvent { /// A map containing any extra ad data for the event, if needed. late final Map? adData; + + /// The ad with which this event is associated. + late final Ad? ad; } /// Factory class for creating SDK objects. diff --git a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart index ebf2bac37e7..ce68660e7ff 100644 --- a/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart +++ b/packages/interactive_media_ads/pigeons/interactive_media_ads_ios.dart @@ -697,6 +697,12 @@ abstract class IMAAdEvent extends NSObject { /// Extra data about the ad. late final Map? adData; + + /// The current ad that is playing or just played. + /// + /// This will be null except for events where an ad is available (start, + /// quartiles, midpoint, complete, and tap). + late final IMAAd? ad; } /// Set of properties that influence how ads are rendered. @@ -793,7 +799,7 @@ abstract class IMACompanionAd extends NSObject { /// /// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMACompanionAdSlot. @ProxyApi() -abstract class IMACompanionAdSlot { +abstract class IMACompanionAdSlot extends NSObject { /// Initializes an instance of a IMACompanionAdSlot with fluid size. IMACompanionAdSlot(); @@ -845,7 +851,7 @@ abstract class IMACompanionDelegate extends NSObject { @ProxyApi( swiftOptions: SwiftProxyApiOptions(import: 'GoogleInteractiveMediaAds'), ) -abstract class IMAAdPodInfo { +abstract class IMAAdPodInfo extends NSObject { /// The position of this ad within an ad pod. /// /// Will be 1 for standalone ads. @@ -887,3 +893,134 @@ abstract class IMAAdPodInfo { /// Bumpers are short videos used to open and close ad breaks. late final bool isBumper; } + +/// Data object representing a single ad. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAAd. +@ProxyApi( + swiftOptions: SwiftProxyApiOptions(import: 'GoogleInteractiveMediaAds'), +) +abstract class IMAAd extends NSObject { + /// The ad ID as specified in the VAST response. + late final String adId; + + /// The ad title from the VAST response. + late final String adTitle; + + /// The ad description. + late final String adDescription; + + /// The source ad server information included in the ad response. + late final String adSystem; + + /// The companion ads specified in the VAST response when using DAI. + /// + /// Empty for client-side ads. + late final List companionAds; + + /// Content type of the currently selected creative. + /// + /// For linear creatives returns the content type of the currently selected + /// media file. Returns empty string if no creative or media file is selected + /// on this ad. + late final String contentType; + + /// The duration of the ad from the VAST response. + late final double duration; + + /// The UI elements that will be displayed during ad playback. + late final List uiElements; + + /// The width of the ad asset. + /// + /// For non-linear ads, this is the actual width of the ad representation. + /// For linear ads, since they scale seamlessly, we currently return 0 for + /// width. + late final int width; + + /// The height of the ad asset. + /// + /// For non-linear ads, this is the actual height of the ad representation. + /// For linear ads, since they scale seamlessly, we currently return 0 for + /// height. + late final int height; + + /// The width of the selected creative as specified in the VAST response. + late final int vastMediaWidth; + + /// The height of the selected creative as specified in the VAST response. + late final int vastMediaHeight; + + /// The bitrate of the selected creative as specified in the VAST response. + late final int vastMediaBitrate; + + /// Specifies whether the ad is linear or non-linear. + late final bool isLinear; + + /// Specifies whether the ad is skippable. + late final bool isSkippable; + + /// The number of seconds of playback before the ad becomes skippable. + /// + /// -1 is returned for non skippable ads or if this is unavailable. + late final double skipTimeOffset; + + /// Set of ad podding properties. + late final IMAAdPodInfo adPodInfo; + + /// String representing custom trafficking parameters from the VAST response. + late final String traffickingParameters; + + /// Returns the ID of the selected creative for the ad. + late final String creativeID; + + /// Returns the ISCI (Industry Standard Commercial Identifier) code for an ad. + /// + /// This is the Ad-ID of the selected creative in the VAST response. + late final String creativeAdID; + + /// The list of all UniversalAdIds of the selected creative for this ad. + /// + /// Returns an empty array if no universal ad IDs are found. + late final List universalAdIDs; + + /// The advertiser name as defined by the serving party. + late final String advertiserName; + + /// Returns the URL associated with the survey for the given ad. + late final String? surveyURL; + + /// Returns the first deal ID present in the wrapper chain for the current ad, + /// starting from the top. + late final String dealID; + + /// The IDs of the ads, starting with the first wrapper ad. + late final List wrapperAdIDs; + + /// The IDs of the ads’ creatives, starting with the first wrapper ad. + late final List wrapperCreativeIDs; + + /// Ad systems used for wrapper ads. + /// + /// The ad systems returned begin with the first wrapper ad and continue to + /// each wrapper ad recursively. + late final List wrapperSystems; +} + +/// Simple data object containing universal ad ID information. +/// +/// See https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAUniversalAdID.html. +@ProxyApi( + swiftOptions: SwiftProxyApiOptions(import: 'GoogleInteractiveMediaAds'), +) +abstract class IMAUniversalAdID extends NSObject { + /// The universal ad ID value. + /// + /// This will be “unknown” if it isn’t defined by the ad. + late final String adIDValue; + + /// The universal ad ID registry with which the value is registered. + /// + /// This will be “unknown” if it isn’t defined by the ad. + late final String adIDRegistry; +} diff --git a/packages/interactive_media_ads/pubspec.yaml b/packages/interactive_media_ads/pubspec.yaml index 1b88ae73fed..376d105b1bf 100644 --- a/packages/interactive_media_ads/pubspec.yaml +++ b/packages/interactive_media_ads/pubspec.yaml @@ -2,7 +2,7 @@ name: interactive_media_ads description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS. repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22 -version: 0.2.6+2 # This must match the version in +version: 0.2.6+3 # This must match the version in # `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and # `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift`