Skip to content

[interactive_media_ads] Adds remaining methods for internal wrapper of the native AdsRequest #9663

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

Merged
merged 13 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/interactive_media_ads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.5+1

* Adds remaining methods for internal wrapper of the Android native `AdsRequest`.
* Adds remaining methods for internal wrapper of the iOS native `IMAAdsRequest`.

## 0.2.5

* Adds support to set general SDK settings. See `ImaSettings` and `AdsLoader.settings`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
*
* This must match the version in pubspec.yaml.
*/
const val pluginVersion = "0.2.5"
const val pluginVersion = "0.2.5+1"
}

override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {
Expand All @@ -39,4 +39,40 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
) {
pigeon_instance.contentProgressProvider = provider
}

override fun setAdWillAutoPlay(pigeon_instance: AdsRequest, willAutoPlay: Boolean) {
pigeon_instance.setAdWillAutoPlay(willAutoPlay)
}

override fun setAdWillPlayMuted(pigeon_instance: AdsRequest, willPlayMuted: Boolean) {
pigeon_instance.setAdWillPlayMuted(willPlayMuted)
}

override fun setAdsResponse(pigeon_instance: AdsRequest, cannedAdResponse: String) {
pigeon_instance.adsResponse = cannedAdResponse
}

override fun setContentDuration(pigeon_instance: AdsRequest, duration: Double) {
pigeon_instance.setContentDuration(duration.toFloat())
}

override fun setContentKeywords(pigeon_instance: AdsRequest, keywords: List<String>) {
pigeon_instance.setContentKeywords(keywords)
}

override fun setContentTitle(pigeon_instance: AdsRequest, title: String) {
pigeon_instance.setContentTitle(title)
}

override fun setContinuousPlayback(pigeon_instance: AdsRequest, continuousPlayback: Boolean) {
pigeon_instance.setContinuousPlayback(continuousPlayback)
}

override fun setLiveStreamPrefetchSeconds(pigeon_instance: AdsRequest, prefetchTime: Double) {
pigeon_instance.setLiveStreamPrefetchSeconds(prefetchTime.toFloat())
}

override fun setVastLoadTimeout(pigeon_instance: AdsRequest, timeout: Double) {
pigeon_instance.setVastLoadTimeout(timeout.toFloat())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ abstract class PigeonApiAdError(
* An object containing the data used to request ads from the server.
*
* See
* https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest.
* https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/kotlin/com/google/ads/interactivemedia/v3/api/AdsRequest.
*/
@Suppress("UNCHECKED_CAST")
abstract class PigeonApiAdsRequest(
Expand All @@ -1494,6 +1494,103 @@ abstract class PigeonApiAdsRequest(
provider: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider
)

/**
* Notifies the SDK whether the player intends to start the content and ad in response to a user
* action or whether it will be automatically played.
*
* Not calling this function leaves the setting as unknown. Note: Changing this setting will have
* no impact on ad playback.
*/
abstract fun setAdWillAutoPlay(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
willAutoPlay: Boolean
)

/**
* Notifies the SDK whether the player intends to start the content and ad while muted.
*
* Not calling this function leaves the setting as unknown. Note: Changing this setting will have
* no impact on ad playback.
*/
abstract fun setAdWillPlayMuted(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
willPlayMuted: Boolean
)

/**
* Specifies a VAST, VMAP, or ad rules response to be used instead of making a request through an
* ad tag URL.
*/
abstract fun setAdsResponse(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
cannedAdResponse: String
)

/**
* Specifies the duration of the content in seconds to be shown.
*
* This optional parameter is used by AdX requests. It is recommended for AdX users.
*/
abstract fun setContentDuration(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
duration: Double
)

/**
* Specifies the keywords used to describe the content to be shown.
*
* This optional parameter is used by AdX requests and is recommended for AdX users.
*/
abstract fun setContentKeywords(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
keywords: List<String>
)

/**
* Specifies the title of the content to be shown.
*
* Used in AdX requests. This optional parameter is used by AdX requests and is recommended for
* AdX users.
*/
abstract fun setContentTitle(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
title: String
)

/**
* Notifies the SDK whether the player intends to continuously play the content videos one after
* another similar to TV broadcast.
*
* Not calling this function leaves the setting as unknown. Note: Changing this setting will have
* no impact on ad playback.
*/
abstract fun setContinuousPlayback(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
continuousPlayback: Boolean
)

/**
* Specifies the maximum amount of time to wait in seconds, after calling requestAds, before
* requesting the ad tag URL.
*
* This can be used to stagger requests during a live-stream event, in order to mitigate spikes in
* the number of requests.
*/
abstract fun setLiveStreamPrefetchSeconds(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
prefetchTime: Double
)

/**
* Specifies the VAST load timeout in milliseconds for a single wrapper.
*
* This parameter is optional and will override the default timeout, currently set to 5000ms.
*/
abstract fun setVastLoadTimeout(
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
timeout: Double
)

companion object {
@Suppress("LocalVariableName")
fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsRequest?) {
Expand Down Expand Up @@ -1547,6 +1644,222 @@ abstract class PigeonApiAdsRequest(
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdWillAutoPlay",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val willAutoPlayArg = args[1] as Boolean
val wrapped: List<Any?> =
try {
api.setAdWillAutoPlay(pigeon_instanceArg, willAutoPlayArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdWillPlayMuted",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val willPlayMutedArg = args[1] as Boolean
val wrapped: List<Any?> =
try {
api.setAdWillPlayMuted(pigeon_instanceArg, willPlayMutedArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdsResponse",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val cannedAdResponseArg = args[1] as String
val wrapped: List<Any?> =
try {
api.setAdsResponse(pigeon_instanceArg, cannedAdResponseArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentDuration",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val durationArg = args[1] as Double
val wrapped: List<Any?> =
try {
api.setContentDuration(pigeon_instanceArg, durationArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentKeywords",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val keywordsArg = args[1] as List<String>
val wrapped: List<Any?> =
try {
api.setContentKeywords(pigeon_instanceArg, keywordsArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentTitle",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val titleArg = args[1] as String
val wrapped: List<Any?> =
try {
api.setContentTitle(pigeon_instanceArg, titleArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContinuousPlayback",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val continuousPlaybackArg = args[1] as Boolean
val wrapped: List<Any?> =
try {
api.setContinuousPlayback(pigeon_instanceArg, continuousPlaybackArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setLiveStreamPrefetchSeconds",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val prefetchTimeArg = args[1] as Double
val wrapped: List<Any?> =
try {
api.setLiveStreamPrefetchSeconds(pigeon_instanceArg, prefetchTimeArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setVastLoadTimeout",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
val timeoutArg = args[1] as Double
val wrapped: List<Any?> =
try {
api.setVastLoadTimeout(pigeon_instanceArg, timeoutArg)
listOf(null)
} catch (exception: Throwable) {
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}

Expand Down
Loading