How to add AdChoice view to a custom view

852 views
Skip to first unread message

saied....@smartnews.com

unread,
Mar 5, 2018, 7:53:57 PM3/5/18
to Google Mobile Ads SDK Developers
Hi,

If I set the class of my .xib file to GADNativeContentAdView or GADNativeIntallAdView, then the SDK places the adChoice view and hooks it up.

But my project requires my .xib file to be a subclass of our own hierarchy of classes, ultimate ending in UIControl.

So my question is, how can I add and wire an adChoice view to my view? (Facebook has an exposed AdChoice object that we can instantiate, configure and add to our view.)

Thanks for your help.

mobileadssdk-a...@google.com

unread,
Mar 6, 2018, 12:43:06 AM3/6/18
to saied....@smartnews.com, Google Mobile Ads SDK Developers
Hi there,

If you wish to display the Ad Choices view on places other than the pre-defined corners, then you may create a GADAdChoicesView in your .xib file and hook it up to your class. However, kindly take note that you need to hook up the GADAdChoicesView in your Native Ad before calling setNativeAd, as mentioned in the linked documentation.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/6478bb27-401e-4011-b68b-29f4fc7f5f94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

saied....@smartnews.com

unread,
Mar 7, 2018, 3:22:02 PM3/7/18
to Google Mobile Ads SDK Developers
Hello Joshua,

Thanks for your reply.

I still have trouble configuring my adChoicesView 1) To show the blue arrow and be interactive, and 2) to place correctly where I want it.

Here's what I have done:

In my xib file, I have 
  1. placed a view, 
  2. set its class to GADAdChoicesView, 
  3. sized and placed it inside my containerView
  4. class of containerView is: _CRAdmobAdCellContainerView a subclass of GADUnifiedNativeAdView
  5. The containerView is inside class CRAdmobAdCell

Then I hook up the above view to property adChoiceView inside CRAdmobAdCell.m 

@property (weak, nonatomic) IBOutlet GADAdChoicesView *adChoicesView;


and finally:

self.containerView.nativeAd = (GADUnifiedNativeAd *)self.admobAd;


So I am setting nativeAd of my self.containerView at the end, and after the hook up of my adChoicesView is done


But nothing shows up inside the view and it's inactive!



Kindly tell me what I may be doing wrong.


Thanks.

saied....@smartnews.com

unread,
Mar 7, 2018, 8:24:38 PM3/7/18
to Google Mobile Ads SDK Developers
Hello Joshua,

I have made some good progress. But the ONLY issue remaining is the position of adChoicesView, which is automatically generated once I have a view of the class GADUnifiedNativeAdView placed on my view hierarchy.

So if I do nothing, here's where the AdChoicesView is: 

Kindly notice that the AdChoicesView is on the extreme top right of the frame. I need to align it's top and right with the rest of my assets.

If, I follow your instruction: "create a GADAdChoicesView in your .xib file and hook it up to your class." I do as follows:
  1. placed a view on my container view, now a subclass of GADUnifiedNativeAdView (and change its background to RED for testing)
  2. set the class of this view to GADAdChoicesView, 
  1. sized and placed it inside my containerView
  1. hook it up to ((GADUnifiedNativeAdView *)self.containerView).adChoicesView
Then I get the original (automatic) AdChoicesView in the extreme corner AND a red square



Can you kindly let me know how to either move the original (automatically placed AdChoicesView) or how i can condition my RED AdChoicesView (that I can place at will) to show the required asset and be clickable?


Thank you very much.

Saied Nesbat

unread,
Mar 7, 2018, 10:19:05 PM3/7/18
to Google Mobile Ads SDK Developers
Dear Joshua,

You said:

You should be able to connect the GADAdChoicesView you created to your GADUnifiedNativeAd object by setting its adChoicesView property, as shown below:

However, kindly note that Native Ads must use the existing Native Ad Views (i.e. a GADUnifiedNativeAdView) to ensure that all functionalities and features work properly.
myUnifiedNativeAd.adChoicesView = _myAdChoicesView;


But please note that  GADUnifiedNativeAd does NOT have a property called adChoicesView!

You probably meant: GADUnifiedNativeAdView Which DOES have  adChoicesView as a property.

It seems to me that I cannot set this property.

Here's what I have set up:

GADUnifiedNativeAdView *gadUnifiedNativeAdView = (GADUnifiedNativeAdView *)self.containerView;

GADAdChoicesView *gadAdChoicesView = self.adChoicesView;

gadUnifiedNativeAdView.adChoicesView = gadAdChoicesView;


Than after step 1, the debugger confirms that I do have an instance GADUnifiedNativeAdView as named, pointing to my containerView
after step 2, the debugger confirms that gatAdChoicesView is connected to the view that I have on my xib file and it's hooked up to self.adChoicesView.
After step 3, the debugger confirms that gatUnifiedNativeAdView.adChoicesView (which was nil before this step) in fact is hooked up to self.acChoiceView of step 2.

after all this set up, and as advised, I connect my containerView's native add to the ad itself

self.containerView.nativeAd = (GADUnifiedNativeAd *)self.admobAd;



But I still get this:


​Which to me it means: 1) that the inserted adChiocesView (with the red bg) is not hooked up properly (non-clickable) and 2) that GADUnifiedNativeAdView did not see the new adChoicesView connected and still shows its default one!

Is this a bug in the SDK? Or am I doing something wrong?

Thanks for your help.


To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/mMFpzTfadW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

mobileadssdk-a...@google.com

unread,
Mar 8, 2018, 12:47:33 AM3/8/18
to Saied Nesbat, Google Mobile Ads SDK Developers
Hi there,

Thank you for your patience.

My apologies for the confusion. Yes, I meant you should be able to connect the GADAdChoicesView to your GADUnifiedNativeAdView object by setting its adChoicesView property. 

That said, it is peculiar that the code snippet you provided did not work as it should have. I tried it on my end and I was able to replicate this issue on my end where the Ad View is not respecting the created GADAdChoicesView, and instead defaulting to the top-right, or at least on one of the pre-defined corners. Upon further investigation, this seems to be a known issue of the SDK. 

That said, let me relay this information to the rest of the team and get back to you once I have their updates.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

mobileadssdk-a...@google.com

unread,
Apr 26, 2018, 1:04:20 AM4/26/18
to Saied Nesbat, Google Mobile Ads SDK Developers
Hi there,

I just want to inform you that a fix is already in place for this. However, we have no definite timelines for the release of the fix so I suggest that you just keep an eye on our Release Notes for future updates.

Regards,
Ivan Bautista
Mobile Ads SDK Team

Allen Xu

unread,
Jun 13, 2019, 6:48:45 AM6/13/19
to Google Mobile Ads SDK Developers
We encountered same issue with latest SDK version 7.44.0, and I came to this post after Googling for solution. I noticed this was fixed back in March, 2018, but seems the bug still exists in latest SDK. Can anyone help confirm if it's fixed and when it'll be released?

Mobile Ads SDK Forum Advisor Prod

unread,
Jun 13, 2019, 3:37:45 PM6/13/19
to al...@glowing.com, google-adm...@googlegroups.com
Hello Allen,

Can you please open a new thread for the issue with all the details so that it will easy for our tracking purposes? I see that this issue went live in the previous SDK releases. If you are still seeing this, we need to investigate this further. When you open a new thread please provide the details whether you were able to reproduce the issue with our sample apps or if you have a sample project to reproduce, please share it along with the steps to reproduce the issue. Please make sure to use "Reply Privately to Author" option when providing the sample project.

Regards,
Deepika Uragayala
Mobile Ads SDK Team
 

ref:_00D1U1174p._5001UBn4Zl:ref
Reply all
Reply to author
Forward
0 new messages