Creating GADNativeAdView programmatically

433 views
Skip to first unread message

Hermawan Winata

unread,
Mar 28, 2023, 8:21:37 AM3/28/23
to Google Mobile Ads SDK Developers
Hi Google Mobile Ads team,


I have created a repository to test creating the GADNativeAdView programmatically  https://github.com/shinwan2/iOSGoogleAdsClient. Is it okay to create the layout programmatically?


Thank you.

Mobile Ads SDK Forum Advisor

unread,
Mar 28, 2023, 2:59:44 PM3/28/23
to shin...@gmail.com, google-adm...@googlegroups.com

Hi Hermawan,

Thank you for reaching out to us.

With regard to your concern, you are able to build Native ad views without Storyboard or .xibs. However, in the code you need to set the values back to the superclass GADNativeAdView. 

For example, you've created a custom `actionButton` in your subclass. However, no clicks are being recorded because you have not set that value back to the superclass. You need to do something such as "storeView = actionButton" storeView coming from the GADNativeAdView. You'll need to do that with all of your respective values that are supposed to represented in your native ad view. 

Regards,

Google Logo Mobile Ads SDK Team


ref:_00D1U1174p._5004Q2kCNyQ:ref

Hermawan Winata

unread,
Mar 28, 2023, 10:13:18 PM3/28/23
to Google Mobile Ads SDK Developers
Hi Google Mobile Ads team,

Thank you for the confirmation. I did actually set them (except the optional `imageView`). Kindly take a look here https://github.com/shinwan2/iOSGoogleAdsClient/blob/764ac16b17112db0e7d9c5d60061e6b6737b1877/NativeAdvancedExample/NativeAdViewProg.swift#L205-L213 if that's what you mean.

Thank you.

Mobile Ads SDK Forum Advisor

unread,
Mar 29, 2023, 5:23:41 AM3/29/23
to shin...@gmail.com, google-adm...@googlegroups.com
Hello Hermawan,

Thank you for the clarification.

If you encounter any issues with this, feel free to reach back to us for further assistance.
Reply all
Reply to author
Forward
0 new messages