Skip to content

Commit b535930

Browse files
[interactive_media_ads] Fixes setting adsresponse on Android (#9744)
## 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 28c35c6 commit b535930

File tree

6 files changed

+74
-4
lines changed

6 files changed

+74
-4
lines changed

packages/interactive_media_ads/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.6+1
2+
3+
* Fixes passing ads response to Android native `AdsRequest`.
4+
15
## 0.2.6
26

37
* Adds support to configure ad requests. See `AdsRequest`.

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"
24+
const val pluginVersion = "0.2.6+1"
2525
}
2626

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

packages/interactive_media_ads/ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AdsRequestProxyAPIDelegate: PigeonApiDelegateIMAAdsRequest {
1313
/// The current version of the `interactive_media_ads` plugin.
1414
///
1515
/// This must match the version in pubspec.yaml.
16-
static let pluginVersion = "0.2.6"
16+
static let pluginVersion = "0.2.6+1"
1717

1818
func pigeonDefaultConstructor(
1919
pigeonApi: PigeonApiIMAAdsRequest, adTagUrl: String, adDisplayContainer: IMAAdDisplayContainer,

packages/interactive_media_ads/lib/src/android/android_ads_loader.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ base class AndroidAdsLoader extends PlatformAdsLoader {
9292
if (request case final PlatformAdsRequestWithAdTagUrl request)
9393
androidRequest.setAdTagUrl(request.adTagUrl),
9494
if (request case final PlatformAdsRequestWithAdsResponse request)
95-
androidRequest.setAdTagUrl(request.adsResponse),
95+
androidRequest.setAdsResponse(request.adsResponse),
9696
if (request.adWillAutoPlay case final bool adWillAutoPlay)
9797
androidRequest.setAdWillAutoPlay(adWillAutoPlay),
9898
if (request.adWillPlayMuted case final bool adWillPlayMuted)

packages/interactive_media_ads/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: interactive_media_ads
22
description: A Flutter plugin for using the Interactive Media Ads SDKs on Android and iOS.
33
repository: https://github.com/flutter/packages/tree/main/packages/interactive_media_ads
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+interactive_media_ads%22
5-
version: 0.2.6 # This must match the version in
5+
version: 0.2.6+1 # This must match the version in
66
# `android/src/main/kotlin/dev/flutter/packages/interactive_media_ads/AdsRequestProxyApi.kt` and
77
# `ios/interactive_media_ads/Sources/interactive_media_ads/AdsRequestProxyAPIDelegate.swift`
88

packages/interactive_media_ads/test/android/ads_loader_test.dart

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ void main() {
147147
),
148148
);
149149

150+
verifyNever(mockAdsRequest.setAdsResponse(any));
150151
verifyInOrder(<Future<void>>[
151152
mockAdsRequest.setAdTagUrl('url'),
152153
mockAdsRequest.setAdWillAutoPlay(true),
@@ -164,6 +165,71 @@ void main() {
164165
]);
165166
});
166167

168+
testWidgets('requestAds with adsResponse', (WidgetTester tester) async {
169+
final AndroidAdDisplayContainer container =
170+
await _pumpAdDisplayContainer(tester);
171+
172+
final MockAdsLoader mockAdsLoader = MockAdsLoader();
173+
final MockAdsRequest mockAdsRequest = MockAdsRequest();
174+
_mockImaSdkFactoryInstance(
175+
adsRequest: mockAdsRequest,
176+
adsLoader: mockAdsLoader,
177+
);
178+
179+
final InteractiveMediaAdsProxy proxy = InteractiveMediaAdsProxy(
180+
newContentProgressProvider: () =>
181+
ima.ContentProgressProvider.pigeon_detached(),
182+
);
183+
184+
final AndroidAdsLoader adsLoader = AndroidAdsLoader(
185+
AndroidAdsLoaderCreationParams(
186+
container: container,
187+
settings: AndroidImaSettings(
188+
const PlatformImaSettingsCreationParams(),
189+
),
190+
onAdsLoaded: (PlatformOnAdsLoadedData data) {},
191+
onAdsLoadError: (AdsLoadErrorData data) {},
192+
proxy: proxy,
193+
),
194+
);
195+
196+
final AndroidContentProgressProvider progressProvider =
197+
AndroidContentProgressProvider(
198+
AndroidContentProgressProviderCreationParams(proxy: proxy),
199+
);
200+
await adsLoader.requestAds(
201+
PlatformAdsRequest.withAdsResponse(
202+
adsResponse: 'url',
203+
adWillAutoPlay: true,
204+
adWillPlayMuted: false,
205+
continuousPlayback: true,
206+
contentDuration: const Duration(seconds: 2),
207+
contentKeywords: <String>['keyword1', 'keyword2'],
208+
contentTitle: 'contentTitle',
209+
liveStreamPrefetchMaxWaitTime: const Duration(seconds: 3),
210+
vastLoadTimeout: const Duration(milliseconds: 5000),
211+
contentProgressProvider: progressProvider,
212+
),
213+
);
214+
215+
verifyNever(mockAdsRequest.setAdTagUrl(any));
216+
verifyInOrder(<Future<void>>[
217+
mockAdsRequest.setAdsResponse('url'),
218+
mockAdsRequest.setAdWillAutoPlay(true),
219+
mockAdsRequest.setAdWillPlayMuted(false),
220+
mockAdsRequest.setContinuousPlayback(true),
221+
mockAdsRequest.setContentDuration(2.0),
222+
mockAdsRequest.setContentKeywords(<String>['keyword1', 'keyword2']),
223+
mockAdsRequest.setContentTitle('contentTitle'),
224+
mockAdsRequest.setLiveStreamPrefetchSeconds(3.0),
225+
mockAdsRequest.setVastLoadTimeout(5000.0),
226+
mockAdsRequest.setContentProgressProvider(
227+
progressProvider.progressProvider,
228+
),
229+
mockAdsLoader.requestAds(mockAdsRequest),
230+
]);
231+
});
232+
167233
testWidgets('onAdsLoaded', (WidgetTester tester) async {
168234
final AndroidAdDisplayContainer container =
169235
await _pumpAdDisplayContainer(tester);

0 commit comments

Comments
 (0)