Skip to content

Commit 2755aa3

Browse files
[interactive_media_ads] Adds remaining methods for internal wrapper of the native AdsRequest (#9663)
## 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 249d2ee commit 2755aa3

File tree

13 files changed

+2042
-6
lines changed

13 files changed

+2042
-6
lines changed

packages/interactive_media_ads/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.5+1
2+
3+
* Adds remaining methods for internal wrapper of the Android native `AdsRequest`.
4+
* Adds remaining methods for internal wrapper of the iOS native `IMAAdsRequest`.
5+
16
## 0.2.5
27

38
* Adds support to set general SDK settings. See `ImaSettings` and `AdsLoader.settings`.

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

Lines changed: 37 additions & 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.5"
24+
const val pluginVersion = "0.2.5+1"
2525
}
2626

2727
override fun setAdTagUrl(pigeon_instance: AdsRequest, adTagUrl: String) {
@@ -39,4 +39,40 @@ class AdsRequestProxyApi(override val pigeonRegistrar: ProxyApiRegistrar) :
3939
) {
4040
pigeon_instance.contentProgressProvider = provider
4141
}
42+
43+
override fun setAdWillAutoPlay(pigeon_instance: AdsRequest, willAutoPlay: Boolean) {
44+
pigeon_instance.setAdWillAutoPlay(willAutoPlay)
45+
}
46+
47+
override fun setAdWillPlayMuted(pigeon_instance: AdsRequest, willPlayMuted: Boolean) {
48+
pigeon_instance.setAdWillPlayMuted(willPlayMuted)
49+
}
50+
51+
override fun setAdsResponse(pigeon_instance: AdsRequest, cannedAdResponse: String) {
52+
pigeon_instance.adsResponse = cannedAdResponse
53+
}
54+
55+
override fun setContentDuration(pigeon_instance: AdsRequest, duration: Double) {
56+
pigeon_instance.setContentDuration(duration.toFloat())
57+
}
58+
59+
override fun setContentKeywords(pigeon_instance: AdsRequest, keywords: List<String>) {
60+
pigeon_instance.setContentKeywords(keywords)
61+
}
62+
63+
override fun setContentTitle(pigeon_instance: AdsRequest, title: String) {
64+
pigeon_instance.setContentTitle(title)
65+
}
66+
67+
override fun setContinuousPlayback(pigeon_instance: AdsRequest, continuousPlayback: Boolean) {
68+
pigeon_instance.setContinuousPlayback(continuousPlayback)
69+
}
70+
71+
override fun setLiveStreamPrefetchSeconds(pigeon_instance: AdsRequest, prefetchTime: Double) {
72+
pigeon_instance.setLiveStreamPrefetchSeconds(prefetchTime.toFloat())
73+
}
74+
75+
override fun setVastLoadTimeout(pigeon_instance: AdsRequest, timeout: Double) {
76+
pigeon_instance.setVastLoadTimeout(timeout.toFloat())
77+
}
4278
}

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

Lines changed: 314 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ abstract class PigeonApiAdError(
14731473
* An object containing the data used to request ads from the server.
14741474
*
14751475
* See
1476-
* https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsRequest.
1476+
* https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/api/reference/kotlin/com/google/ads/interactivemedia/v3/api/AdsRequest.
14771477
*/
14781478
@Suppress("UNCHECKED_CAST")
14791479
abstract class PigeonApiAdsRequest(
@@ -1494,6 +1494,103 @@ abstract class PigeonApiAdsRequest(
14941494
provider: com.google.ads.interactivemedia.v3.api.player.ContentProgressProvider
14951495
)
14961496

1497+
/**
1498+
* Notifies the SDK whether the player intends to start the content and ad in response to a user
1499+
* action or whether it will be automatically played.
1500+
*
1501+
* Not calling this function leaves the setting as unknown. Note: Changing this setting will have
1502+
* no impact on ad playback.
1503+
*/
1504+
abstract fun setAdWillAutoPlay(
1505+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1506+
willAutoPlay: Boolean
1507+
)
1508+
1509+
/**
1510+
* Notifies the SDK whether the player intends to start the content and ad while muted.
1511+
*
1512+
* Not calling this function leaves the setting as unknown. Note: Changing this setting will have
1513+
* no impact on ad playback.
1514+
*/
1515+
abstract fun setAdWillPlayMuted(
1516+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1517+
willPlayMuted: Boolean
1518+
)
1519+
1520+
/**
1521+
* Specifies a VAST, VMAP, or ad rules response to be used instead of making a request through an
1522+
* ad tag URL.
1523+
*/
1524+
abstract fun setAdsResponse(
1525+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1526+
cannedAdResponse: String
1527+
)
1528+
1529+
/**
1530+
* Specifies the duration of the content in seconds to be shown.
1531+
*
1532+
* This optional parameter is used by AdX requests. It is recommended for AdX users.
1533+
*/
1534+
abstract fun setContentDuration(
1535+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1536+
duration: Double
1537+
)
1538+
1539+
/**
1540+
* Specifies the keywords used to describe the content to be shown.
1541+
*
1542+
* This optional parameter is used by AdX requests and is recommended for AdX users.
1543+
*/
1544+
abstract fun setContentKeywords(
1545+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1546+
keywords: List<String>
1547+
)
1548+
1549+
/**
1550+
* Specifies the title of the content to be shown.
1551+
*
1552+
* Used in AdX requests. This optional parameter is used by AdX requests and is recommended for
1553+
* AdX users.
1554+
*/
1555+
abstract fun setContentTitle(
1556+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1557+
title: String
1558+
)
1559+
1560+
/**
1561+
* Notifies the SDK whether the player intends to continuously play the content videos one after
1562+
* another similar to TV broadcast.
1563+
*
1564+
* Not calling this function leaves the setting as unknown. Note: Changing this setting will have
1565+
* no impact on ad playback.
1566+
*/
1567+
abstract fun setContinuousPlayback(
1568+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1569+
continuousPlayback: Boolean
1570+
)
1571+
1572+
/**
1573+
* Specifies the maximum amount of time to wait in seconds, after calling requestAds, before
1574+
* requesting the ad tag URL.
1575+
*
1576+
* This can be used to stagger requests during a live-stream event, in order to mitigate spikes in
1577+
* the number of requests.
1578+
*/
1579+
abstract fun setLiveStreamPrefetchSeconds(
1580+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1581+
prefetchTime: Double
1582+
)
1583+
1584+
/**
1585+
* Specifies the VAST load timeout in milliseconds for a single wrapper.
1586+
*
1587+
* This parameter is optional and will override the default timeout, currently set to 5000ms.
1588+
*/
1589+
abstract fun setVastLoadTimeout(
1590+
pigeon_instance: com.google.ads.interactivemedia.v3.api.AdsRequest,
1591+
timeout: Double
1592+
)
1593+
14971594
companion object {
14981595
@Suppress("LocalVariableName")
14991596
fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiAdsRequest?) {
@@ -1547,6 +1644,222 @@ abstract class PigeonApiAdsRequest(
15471644
channel.setMessageHandler(null)
15481645
}
15491646
}
1647+
run {
1648+
val channel =
1649+
BasicMessageChannel<Any?>(
1650+
binaryMessenger,
1651+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdWillAutoPlay",
1652+
codec)
1653+
if (api != null) {
1654+
channel.setMessageHandler { message, reply ->
1655+
val args = message as List<Any?>
1656+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1657+
val willAutoPlayArg = args[1] as Boolean
1658+
val wrapped: List<Any?> =
1659+
try {
1660+
api.setAdWillAutoPlay(pigeon_instanceArg, willAutoPlayArg)
1661+
listOf(null)
1662+
} catch (exception: Throwable) {
1663+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1664+
}
1665+
reply.reply(wrapped)
1666+
}
1667+
} else {
1668+
channel.setMessageHandler(null)
1669+
}
1670+
}
1671+
run {
1672+
val channel =
1673+
BasicMessageChannel<Any?>(
1674+
binaryMessenger,
1675+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdWillPlayMuted",
1676+
codec)
1677+
if (api != null) {
1678+
channel.setMessageHandler { message, reply ->
1679+
val args = message as List<Any?>
1680+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1681+
val willPlayMutedArg = args[1] as Boolean
1682+
val wrapped: List<Any?> =
1683+
try {
1684+
api.setAdWillPlayMuted(pigeon_instanceArg, willPlayMutedArg)
1685+
listOf(null)
1686+
} catch (exception: Throwable) {
1687+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1688+
}
1689+
reply.reply(wrapped)
1690+
}
1691+
} else {
1692+
channel.setMessageHandler(null)
1693+
}
1694+
}
1695+
run {
1696+
val channel =
1697+
BasicMessageChannel<Any?>(
1698+
binaryMessenger,
1699+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setAdsResponse",
1700+
codec)
1701+
if (api != null) {
1702+
channel.setMessageHandler { message, reply ->
1703+
val args = message as List<Any?>
1704+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1705+
val cannedAdResponseArg = args[1] as String
1706+
val wrapped: List<Any?> =
1707+
try {
1708+
api.setAdsResponse(pigeon_instanceArg, cannedAdResponseArg)
1709+
listOf(null)
1710+
} catch (exception: Throwable) {
1711+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1712+
}
1713+
reply.reply(wrapped)
1714+
}
1715+
} else {
1716+
channel.setMessageHandler(null)
1717+
}
1718+
}
1719+
run {
1720+
val channel =
1721+
BasicMessageChannel<Any?>(
1722+
binaryMessenger,
1723+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentDuration",
1724+
codec)
1725+
if (api != null) {
1726+
channel.setMessageHandler { message, reply ->
1727+
val args = message as List<Any?>
1728+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1729+
val durationArg = args[1] as Double
1730+
val wrapped: List<Any?> =
1731+
try {
1732+
api.setContentDuration(pigeon_instanceArg, durationArg)
1733+
listOf(null)
1734+
} catch (exception: Throwable) {
1735+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1736+
}
1737+
reply.reply(wrapped)
1738+
}
1739+
} else {
1740+
channel.setMessageHandler(null)
1741+
}
1742+
}
1743+
run {
1744+
val channel =
1745+
BasicMessageChannel<Any?>(
1746+
binaryMessenger,
1747+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentKeywords",
1748+
codec)
1749+
if (api != null) {
1750+
channel.setMessageHandler { message, reply ->
1751+
val args = message as List<Any?>
1752+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1753+
val keywordsArg = args[1] as List<String>
1754+
val wrapped: List<Any?> =
1755+
try {
1756+
api.setContentKeywords(pigeon_instanceArg, keywordsArg)
1757+
listOf(null)
1758+
} catch (exception: Throwable) {
1759+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1760+
}
1761+
reply.reply(wrapped)
1762+
}
1763+
} else {
1764+
channel.setMessageHandler(null)
1765+
}
1766+
}
1767+
run {
1768+
val channel =
1769+
BasicMessageChannel<Any?>(
1770+
binaryMessenger,
1771+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContentTitle",
1772+
codec)
1773+
if (api != null) {
1774+
channel.setMessageHandler { message, reply ->
1775+
val args = message as List<Any?>
1776+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1777+
val titleArg = args[1] as String
1778+
val wrapped: List<Any?> =
1779+
try {
1780+
api.setContentTitle(pigeon_instanceArg, titleArg)
1781+
listOf(null)
1782+
} catch (exception: Throwable) {
1783+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1784+
}
1785+
reply.reply(wrapped)
1786+
}
1787+
} else {
1788+
channel.setMessageHandler(null)
1789+
}
1790+
}
1791+
run {
1792+
val channel =
1793+
BasicMessageChannel<Any?>(
1794+
binaryMessenger,
1795+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setContinuousPlayback",
1796+
codec)
1797+
if (api != null) {
1798+
channel.setMessageHandler { message, reply ->
1799+
val args = message as List<Any?>
1800+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1801+
val continuousPlaybackArg = args[1] as Boolean
1802+
val wrapped: List<Any?> =
1803+
try {
1804+
api.setContinuousPlayback(pigeon_instanceArg, continuousPlaybackArg)
1805+
listOf(null)
1806+
} catch (exception: Throwable) {
1807+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1808+
}
1809+
reply.reply(wrapped)
1810+
}
1811+
} else {
1812+
channel.setMessageHandler(null)
1813+
}
1814+
}
1815+
run {
1816+
val channel =
1817+
BasicMessageChannel<Any?>(
1818+
binaryMessenger,
1819+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setLiveStreamPrefetchSeconds",
1820+
codec)
1821+
if (api != null) {
1822+
channel.setMessageHandler { message, reply ->
1823+
val args = message as List<Any?>
1824+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1825+
val prefetchTimeArg = args[1] as Double
1826+
val wrapped: List<Any?> =
1827+
try {
1828+
api.setLiveStreamPrefetchSeconds(pigeon_instanceArg, prefetchTimeArg)
1829+
listOf(null)
1830+
} catch (exception: Throwable) {
1831+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1832+
}
1833+
reply.reply(wrapped)
1834+
}
1835+
} else {
1836+
channel.setMessageHandler(null)
1837+
}
1838+
}
1839+
run {
1840+
val channel =
1841+
BasicMessageChannel<Any?>(
1842+
binaryMessenger,
1843+
"dev.flutter.pigeon.interactive_media_ads.AdsRequest.setVastLoadTimeout",
1844+
codec)
1845+
if (api != null) {
1846+
channel.setMessageHandler { message, reply ->
1847+
val args = message as List<Any?>
1848+
val pigeon_instanceArg = args[0] as com.google.ads.interactivemedia.v3.api.AdsRequest
1849+
val timeoutArg = args[1] as Double
1850+
val wrapped: List<Any?> =
1851+
try {
1852+
api.setVastLoadTimeout(pigeon_instanceArg, timeoutArg)
1853+
listOf(null)
1854+
} catch (exception: Throwable) {
1855+
InteractiveMediaAdsLibraryPigeonUtils.wrapError(exception)
1856+
}
1857+
reply.reply(wrapped)
1858+
}
1859+
} else {
1860+
channel.setMessageHandler(null)
1861+
}
1862+
}
15501863
}
15511864
}
15521865

0 commit comments

Comments
 (0)