Implementing Click Action for AdChoice Icon in Native AdMob Banner with Jetpack Compose

248 views
Skip to first unread message

Oleksandr Palchevskyi

unread,
Jun 22, 2023, 4:32:04 AM6/22/23
to Google Mobile Ads SDK Developers

Hello,

I am currently working on implementing a native ad banner with Jetpack Compose. According to the guidelines, every native ad must include an Ad tag and an AdChoice icon.

I have prepared the layout with both these components. However, I am not certain about the behavior that should be triggered when the AdChoice icon is clicked. To be specific, I am looking for guidance on the code that needs to be included in the adChoiceClick function.

Below is the relevant section of my code:

@Composable
fun AdItem(nativeAd: NativeAd, modifier: Modifier = Modifier) {
AndroidView(
factory = { context ->
NativeAdView(context)
},
update = {
val composeView = ComposeView(it.context)
it.setNativeAd(nativeAd)
it.removeAllViews()
it.addView(composeView)
composeView.setContent {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
// My other views for native banner
AdAttributions(adChoiceClick = {
//What should go here?
})
}
}
})
}

@Composable
fun AdAttributions(adChoiceClick: () -> Unit) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Box(
contentAlignment = Alignment.BottomEnd,
modifier = Modifier
.clickable {
adChoiceClick()
}

) {
Icon(
painterResource(id = R.drawable.ad_choise),
modifier = Modifier
.width(20.dp)
.height(20.dp)
.padding(bottom = 4.dp),
tint = Color(0xff00aecd),
contentDescription = null
)
}

//Ad Mark below
}
}

What action should the adChoiceClick function trigger when the AdChoice icon is clicked? Additionally, I've encountered some suggestions that the AdChoice icon could be implemented automatically. However, I'm not certain whether this is applicable when utilizing Jetpack Compose. Any information or guidance on this would be immensely helpful. Thank you so much!




Mobile Ads SDK Forum Advisor

unread,
Jun 23, 2023, 9:34:44 AM6/23/23
to dev.alex.p...@gmail.com, google-adm...@googlegroups.com
Hello,

Please do note that AdMob is not natively supported in Jetpack Compose yet. Though some features might work; however, we can't assure you that AdMob's features will work as expected as we don't have the visibility on the implementation of the unsupported platform. 
 
This message is in relation to case "ref:_00D1U1174p._5004Q2mWMEy:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Chintan Joshi

unread,
Aug 23, 2023, 2:30:20 AM8/23/23
to Google Mobile Ads SDK Developers
I have same problem , did you slove this so please guide me on this same

Mobile Ads SDK Forum Advisor

unread,
Aug 23, 2023, 9:20:28 AM8/23/23
to jchin...@gmail.com, google-adm...@googlegroups.com
Hello,

Thank you for reaching out to us. As per discussion on this thread, I'm afraid that AdMob is not natively supported in Jetpack Compose yet.
Reply all
Reply to author
Forward
0 new messages