Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[interactive_media_ads] Adds support to define parameters that control the rendering of ads #8057

Merged
merged 29 commits into from
Nov 19, 2024

Conversation

bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Nov 12, 2024

Changes PlatformAdsManager.init(AdsManagerInitParams) to the correct shared PlatformAdsManager.init(PlatformAdsRenderingSettings?) feature.

Android: https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager.html#init(com.google.ads.interactivemedia.v3.api.AdsRenderingSettings)
iOS: https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/reference/Classes/IMAAdsManager#/c:objc(cs)IMAAdsManager(im)initializeWithAdsRenderingSettings:

The platform interface and implementation aren't exposed yet, so this change should not be breaking.

Fixes flutter/flutter#152253

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@bparrishMines bparrishMines changed the title Ima adsrendering [interactive_media_ads] Adds support to define parameters that control the rendering of ads Nov 13, 2024
/// ads manager.
///
/// If null, the platform will decide the default value.
final bool? enablePreloading;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This value defaults to false on Android and true on iOS. To prevent a breaking change, I made the value nullable to indicate the platform will handle the default. Same is true for the other fields.

@bparrishMines bparrishMines requested review from stuartmorgan and removed request for stuartmorgan November 13, 2024 20:53
@bparrishMines bparrishMines marked this pull request as ready for review November 13, 2024 21:40

/// The SDK will prioritize the media with MIME type on the list.
///
/// If empty, the SDK will pick the media based on player capabilities. This
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If empty has a special meaning that's the same as null, then we should make it non-nullable.

///
/// If empty, the SDK will pick the media based on player capabilities. This
/// only refers to the mime types of videos to be selected for linear ads.
final List<String>? mimeTypes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-nullable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the documentation for iOS actually states what happens if it is empty. Android doesn't actually mention it:

If specified, the SDK will prioritize the media with MIME type on the list. If not specified,
the SDK will pick the media based on player capabilities. This only refers to the mime
types of videos to be selected for linear ads.

This is related to having a "don't set" option for optional native parameters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an implementation detail though; if we want empty to mean "the SDK decides" as the docs currently say, then we should map an empty list to not setting on platforms that treat null as not setting.

If we actually want to treat [] and null differently, then we need to explain what the difference is in the comments, ideally in a cross-platform way.

///
/// Some modifications to the uiElements list may have no effect for specific
/// ads.
final Set<UIElement>? uiElements;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-nullable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Not sure if there is a difference between setting to empty or not setting it all.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

/// 15s.
Duration? get playAdsAfterTime => platform.params.playAdsAfterTime;

/// Sets the ad UI elements to be rendered by the IMA SDK.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Sets the" -> "The" (since it's a getter)

/// The SDK will prioritize the media with MIME type on the list.
///
/// This only refers to the mime types of videos to be selected for linear
/// ads.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're keeping nullability, this needs a comment explaining that null means platform default.

///
/// Some modifications to the uiElements list may have no effect for specific
/// ads.
Set<AdUIElement>? get uiElements => platform.params.uiElements;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about nullability.

@bparrishMines bparrishMines added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2024
@auto-submit auto-submit bot merged commit 0e73a05 into flutter:main Nov 19, 2024
77 checks passed
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2024
@bparrishMines bparrishMines deleted the ima_adsrendering branch November 19, 2024 19:48
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 20, 2024
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Nov 20, 2024
flutter/packages@fc4adc7...e95f6d8

2024-11-19 louisehsu@google.com [in_app_purchase_storekit] disallow ios
versions lower than supported from enabling storekit
(flutter/packages#8110)
2024-11-19 49699333+dependabot[bot]@users.noreply.github.com
[interactive_media_ads]: Bump
com.google.ads.interactivemedia.v3:interactivemedia from 3.35.1 to
3.36.0 in /packages/interactive_media_ads/android
(flutter/packages#8046)
2024-11-19 49699333+dependabot[bot]@users.noreply.github.com
[interactive_media_ads]: Bump androidx.annotation:annotation from 1.8.2
to 1.9.1 in /packages/interactive_media_ads/android
(flutter/packages#7980)
2024-11-19 10687576+bparrishMines@users.noreply.github.com
[webview_flutter_android] Updates plugin to use `ProxyApis`s
(flutter/packages#7794)
2024-11-19 10687576+bparrishMines@users.noreply.github.com
[interactive_media_ads] Adds support to define parameters that control
the rendering of ads (flutter/packages#8057)
2024-11-19 engine-flutter-autoroll@skia.org Roll Flutter from
b3818f6 to 8536b96 (22 revisions) (flutter/packages#8124)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
sinyu1012 added a commit to sinyu1012/packages that referenced this pull request Nov 22, 2024
* main: (64 commits)
  [quick_actions_plaform_interface] add localizedSubtitle (flutter#8112)
  [tools] Don't check license of generated Swift package (flutter#8137)
  Roll Flutter from 8536b96ebb3e to 93d772c5cdd8 (37 revisions) (flutter#8147)
  [go_router] Fix: Consistent PopScope Handling on Root Routes issue #140869 (flutter#8045)
  [in_app_purchase_storekit] fix price displayed with wrong precision (flutter#8127)
  [pigeon] Removes the `@protected` annotation from the InstanceManager field of the   `PigeonInternalProxyApiBaseClass` (flutter#8125)
  [google_maps_flutter] Use structured Pigeon data on iOS (flutter#8142)
  [vector_graphics] handle errors from bytes loader (flutter#8080)
  [flutter_svg] Fix SvgNetworkLoader not closing internal http client (flutter#8126)
  [video_player_avfoundation] send video load failure even when eventsink was initialized late (flutter#7194)
  [flutter_markdown] enable Wasm support (flutter#8120)
  Reverts "[url_launcher] Add Swift Package Manager integration to example app (flutter#8128)" (flutter#8136)
  [url_launcher] Add Swift Package Manager integration to example app (flutter#8128)
  [pigeon] Enable example app build in CI (flutter#8119)
  [in_app_purchase_storekit] disallow ios versions lower than supported from enabling storekit (flutter#8110)
  [interactive_media_ads]: Bump com.google.ads.interactivemedia.v3:interactivemedia from 3.35.1 to 3.36.0 in /packages/interactive_media_ads/android (flutter#8046)
  [interactive_media_ads]: Bump androidx.annotation:annotation from 1.8.2 to 1.9.1 in /packages/interactive_media_ads/android (flutter#7980)
  [webview_flutter_android] Updates plugin to use `ProxyApis`s (flutter#7794)
  [interactive_media_ads] Adds support to define parameters that control the rendering of ads (flutter#8057)
  Roll Flutter from b3818f6b5979 to 8536b96ebb3e (22 revisions) (flutter#8124)
  ...

# Conflicts:
#	packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[interactive_media_ads] Add support for preloading ads on Android
2 participants