Skip to content

Commit 557bbc2

Browse files
[interactive_media_ads] Updates ProxyApis to prepare to add support for AdEvent.ad (#9785)
## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 58c02e0 commit 557bbc2

File tree

21 files changed

+1820
-41
lines changed

21 files changed

+1820
-41
lines changed

packages/interactive_media_ads/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
## NEXT
1+
## 0.2.6+4
22

3+
* Adds internal wrappers for iOS native `IMAAd` and `IMAUniversalAdID`.
4+
* Updates internal wrapper for iOS native `IMAAdEvent`.
5+
* Updates internal wrapper for Android native `AdEvent`.
36
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
47

58
## 0.2.6+3

packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApi.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package dev.flutter.packages.interactive_media_ads
66

7+
import com.google.ads.interactivemedia.v3.api.Ad
78
import com.google.ads.interactivemedia.v3.api.AdEvent
89

910
/**
@@ -50,4 +51,8 @@ class AdEventProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
5051
override fun adData(pigeon_instance: AdEvent): Map<String, String>? {
5152
return pigeon_instance.adData
5253
}
54+
55+
override fun ad(pigeon_instance: AdEvent): Ad? {
56+
return pigeon_instance.ad
57+
}
5358
}

packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
2121
*
2222
* This must match the version in pubspec.yaml.
2323
*/
24-
const val pluginVersion = "0.2.6+3"
24+
const val pluginVersion = "0.2.6+4"
2525
}
2626

2727
override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {

packages/interactive_media_ads/android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/InteractiveMediaAdsLibrary.g.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v26.0.0), do not edit directly.
4+
// Autogenerated from Pigeon (v26.0.1), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")
77

@@ -2558,7 +2558,7 @@ abstract class PigeonApiBaseManager(
25582558
* Event to notify publisher that an event occurred with an Ad.
25592559
*
25602560
* See
2561-
* https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.html.
2561+
* https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/kotlin/com/google/ads/interactivemedia/v3/api/AdEvent.
25622562
*/
25632563
@Suppress("UNCHECKED_CAST")
25642564
abstract class PigeonApiAdEvent(
@@ -2572,6 +2572,11 @@ abstract class PigeonApiAdEvent(
25722572
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdEvent
25732573
): Map<String, String>?
25742574

2575+
/** The ad with which this event is associated. */
2576+
abstract fun ad(
2577+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdEvent
2578+
): com.google.ads.interactivemedia.v3.api.Ad?
2579+
25752580
@Suppress("LocalVariableName", "FunctionName")
25762581
/** Creates a Dart instance of AdEvent and attaches it to [pigeon_instanceArg]. */
25772582
fun pigeon_newInstance(
@@ -2589,11 +2594,12 @@ abstract class PigeonApiAdEvent(
25892594
pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg)
25902595
val typeArg = type(pigeon_instanceArg)
25912596
val adDataArg = adData(pigeon_instanceArg)
2597+
val adArg = ad(pigeon_instanceArg)
25922598
val binaryMessenger = pigeonRegistrar.binaryMessenger
25932599
val codec = pigeonRegistrar.codec
25942600
val channelName = "dev.flutter.pigeon.interactive_media_ads.AdEvent.pigeon_newInstance"
25952601
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
2596-
channel.send(listOf(pigeon_identifierArg, typeArg, adDataArg)) {
2602+
channel.send(listOf(pigeon_identifierArg, typeArg, adDataArg, adArg)) {
25972603
if (it is List<*>) {
25982604
if (it.size > 1) {
25992605
callback(

packages/interactive_media_ads/android/src/test/kotlin/dev/flutter/packages/interactive_media_ads/AdEventProxyApiTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package dev.flutter.packages.interactive_media_ads
66

7+
import com.google.ads.interactivemedia.v3.api.Ad
78
import com.google.ads.interactivemedia.v3.api.AdEvent
89
import kotlin.test.Test
910
import kotlin.test.assertEquals
@@ -30,4 +31,15 @@ class AdEventProxyApiTest {
3031

3132
assertEquals(mapOf("a" to "b", "c" to "d"), api.adData(instance))
3233
}
34+
35+
@Test
36+
fun ad() {
37+
val api = TestProxyApiRegistrar().getPigeonApiAdEvent()
38+
39+
val ad = Mockito.mock<Ad>()
40+
val instance = Mockito.mock<AdEvent>()
41+
whenever(instance.ad).thenReturn(ad)
42+
43+
assertEquals(ad, api.ad(instance))
44+
}
3345
}

packages/interactive_media_ads/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
1515
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
1616
8F0EDFD12E0A2906001938E6 /* SettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD02E0A2906001938E6 /* SettingsTests.swift */; };
17+
8F0EDFD62E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD52E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift */; };
18+
8F0EDFD72E4AA191001938E6 /* AdProxyAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD42E4AA191001938E6 /* AdProxyAPITests.swift */; };
19+
8F0EDFD92E4AA1B0001938E6 /* ViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F0EDFD82E4AA1B0001938E6 /* ViewTests.swift */; };
1720
8F599BB12C2DD1FD0090A0DF /* AdsManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F599BB02C2DD1FD0090A0DF /* AdsManagerTests.swift */; };
1821
8F599BB32C2DD87D0090A0DF /* AdsLoaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F599BB22C2DD87D0090A0DF /* AdsLoaderTests.swift */; };
1922
8F599BB52C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F599BB42C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift */; };
@@ -77,6 +80,9 @@
7780
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7881
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 = "<group>"; };
7982
8F0EDFD02E0A2906001938E6 /* SettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTests.swift; sourceTree = "<group>"; };
83+
8F0EDFD42E4AA191001938E6 /* AdProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdProxyAPITests.swift; sourceTree = "<group>"; };
84+
8F0EDFD52E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniversalAdIDProxyAPITests.swift; sourceTree = "<group>"; };
85+
8F0EDFD82E4AA1B0001938E6 /* ViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTests.swift; sourceTree = "<group>"; };
8086
8F599BB02C2DD1FD0090A0DF /* AdsManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsManagerTests.swift; sourceTree = "<group>"; };
8187
8F599BB22C2DD87D0090A0DF /* AdsLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsLoaderTests.swift; sourceTree = "<group>"; };
8288
8F599BB42C2DD8EC0090A0DF /* AdsLoaderDelegateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdsLoaderDelegateTests.swift; sourceTree = "<group>"; };
@@ -130,6 +136,9 @@
130136
331C8082294A63A400263BE5 /* RunnerTests */ = {
131137
isa = PBXGroup;
132138
children = (
139+
8F0EDFD82E4AA1B0001938E6 /* ViewTests.swift */,
140+
8F0EDFD42E4AA191001938E6 /* AdProxyAPITests.swift */,
141+
8F0EDFD52E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift */,
133142
8F0EDFD02E0A2906001938E6 /* SettingsTests.swift */,
134143
8FC919912CA5D86F00188068 /* FriendlyObstructionTests.swift */,
135144
8F977DCE2C2B99C600A90D4B /* AdDisplayContainerTests.swift */,
@@ -256,6 +265,7 @@
256265
97C146EC1CF9000F007C117D /* Resources */,
257266
9705A1C41CF9048500538489 /* Embed Frameworks */,
258267
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
268+
776DEB6D359E63A1B5E520A7 /* [CP] Embed Pods Frameworks */,
259269
);
260270
buildRules = (
261271
);
@@ -371,6 +381,23 @@
371381
shellPath = /bin/sh;
372382
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
373383
};
384+
776DEB6D359E63A1B5E520A7 /* [CP] Embed Pods Frameworks */ = {
385+
isa = PBXShellScriptBuildPhase;
386+
buildActionMask = 2147483647;
387+
files = (
388+
);
389+
inputFileListPaths = (
390+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
391+
);
392+
name = "[CP] Embed Pods Frameworks";
393+
outputFileListPaths = (
394+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
395+
);
396+
runOnlyForDeploymentPostprocessing = 0;
397+
shellPath = /bin/sh;
398+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
399+
showEnvVarsInLog = 0;
400+
};
374401
8BF613E92E45E672229E9718 /* [CP] Check Pods Manifest.lock */ = {
375402
isa = PBXShellScriptBuildPhase;
376403
buildActionMask = 2147483647;
@@ -418,8 +445,11 @@
418445
8F599BBF2C3335B40090A0DF /* ViewControllerTests.swift in Sources */,
419446
8F8382A32CBDB4A4007F28E0 /* CompanionAdProxyApiTests.swift in Sources */,
420447
8F0EDFD12E0A2906001938E6 /* SettingsTests.swift in Sources */,
448+
8F0EDFD62E4AA191001938E6 /* UniversalAdIDProxyAPITests.swift in Sources */,
449+
8F0EDFD72E4AA191001938E6 /* AdProxyAPITests.swift in Sources */,
421450
8FC919922CA5D86F00188068 /* FriendlyObstructionTests.swift in Sources */,
422451
8F977DD92C2C8C6A00A90D4B /* AdLoadingErrorDataTests.swift in Sources */,
452+
8F0EDFD92E4AA1B0001938E6 /* ViewTests.swift in Sources */,
423453
8F599BB32C2DD87D0090A0DF /* AdsLoaderTests.swift in Sources */,
424454
8F977DD72C2C89A600A90D4B /* AdEventTests.swift in Sources */,
425455
8F977DD32C2BA15100A90D4B /* TestProxyApiRegistrar.swift in Sources */,
@@ -520,7 +550,7 @@
520550
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
521551
GCC_WARN_UNUSED_FUNCTION = YES;
522552
GCC_WARN_UNUSED_VARIABLE = YES;
523-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
553+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
524554
MTL_ENABLE_DEBUG_INFO = NO;
525555
SDKROOT = iphoneos;
526556
SUPPORTED_PLATFORMS = iphoneos;
@@ -650,7 +680,7 @@
650680
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
651681
GCC_WARN_UNUSED_FUNCTION = YES;
652682
GCC_WARN_UNUSED_VARIABLE = YES;
653-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
683+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
654684
MTL_ENABLE_DEBUG_INFO = YES;
655685
ONLY_ACTIVE_ARCH = YES;
656686
SDKROOT = iphoneos;
@@ -701,7 +731,7 @@
701731
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
702732
GCC_WARN_UNUSED_FUNCTION = YES;
703733
GCC_WARN_UNUSED_VARIABLE = YES;
704-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
734+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
705735
MTL_ENABLE_DEBUG_INFO = NO;
706736
SDKROOT = iphoneos;
707737
SUPPORTED_PLATFORMS = iphoneos;

packages/interactive_media_ads/example/ios/RunnerTests/AdEventTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,30 @@ final class AdEventTests: XCTestCase {
4141

4242
XCTAssertEqual(value as! [String: String], ["my": "string"])
4343
}
44+
45+
func testAd() {
46+
let registrar = TestProxyApiRegistrar()
47+
let api = registrar.apiDelegate.pigeonApiIMAAdEvent(registrar)
48+
49+
let instance = TestAdEvent.customInit()
50+
let value = try? api.pigeonDelegate.ad(pigeonApi: api, pigeonInstance: instance)
51+
52+
XCTAssertNotNil(value)
53+
XCTAssertEqual(value, instance.ad)
54+
}
4455
}
4556

4657
class TestAdEvent: IMAAdEvent {
4758
// Workaround to subclass an Objective-C class that has an `init` constructor with NS_UNAVAILABLE
4859
static func customInit() -> TestAdEvent {
4960
let instance =
5061
TestAdEvent.perform(NSSelectorFromString("new")).takeRetainedValue() as! TestAdEvent
62+
instance._ad = TestAd.customInit()
5163
return instance
5264
}
5365

66+
var _ad: TestAd?
67+
5468
override var type: IMAAdEventType {
5569
return .AD_BREAK_ENDED
5670
}
@@ -62,4 +76,8 @@ class TestAdEvent: IMAAdEvent {
6276
override var adData: [String: Any]? {
6377
return ["my": "string"]
6478
}
79+
80+
override var ad: IMAAd? {
81+
return _ad!
82+
}
6583
}

0 commit comments

Comments
 (0)