iOS AdMob Adding “keywords” 'cust_params' section of the ad calls

179 views
Skip to first unread message

Chris Vanderhorst

unread,
Apr 29, 2021, 12:03:42 AM4/29/21
to Google Mobile Ads SDK Developers

When trying to dynamically add keywords to the below function it's not successfully being added to the ad request. But when hardcoded seems to be working fine


func reloadAdd(googleBannerView: DFPBannerView, siteArea: String, delegate: AnyObject, orientation: UIInterfaceOrientation, adPosition: Int ? = 1, adConfig : AdConfig ? = nil, keywords : String ? = "one,two") { var defaultDict: [AnyHashable: Any] = [: ] defaultDict = [ "position": "\(adPosition ?? 1)", "keyword": siteArea, "excl_cat": !UserDefaults.isOver18() ? "Gambling" : "" ] if let _keywords = keywords { //This cis not working defaultDict["keywords"] = _keywords.split(separator: ",").compactMap({ String($0) }) // Below is the working // defaultDict["keywords"] = ["one", "two"] } defaultDict = defaultDict.merge(dict: extraAdCallInfo) request.customTargeting = defaultDict }

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 29, 2021, 4:49:12 AM4/29/21
to chris.va...@pulselive.com, google-adm...@googlegroups.com
Hi Chris,

Thank you for reaching out to us.

As per checking with the code that you provided, I didn't see anything wrong with it. The only thing that I could think of the the method compactMap() that you're using. Could you please try to use the map() or flatMap() instead, then let me know how it goes?

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2GIWZ9:ref

Chris Vanderhorst

unread,
May 10, 2021, 5:42:21 PM5/10/21
to Google Mobile Ads SDK Developers
Hi Teejay,
Thanks for the response. We have tried with compactMap() and also map() without success. Previously we have also tried other methods functions to iterate the variables again without success.
What if request.customTargeting  is set by multiple functions threads at once what would be the expected behaviour? would only the last request work or would all be sent successfully?
Does it have its own internal queues?

Regards
Chris

Mobile Ads SDK Forum Advisor Prod

unread,
May 11, 2021, 2:12:16 AM5/11/21
to chris.va...@pulselive.com, google-adm...@googlegroups.com
Hi Chris,

With regard to your concern, if request.customTargeting  is set by multiple functions threads at once, then the last request will only work. As per the dynamically add keywords, it appears that this is iOS implementation centric rather than anything specific to Mobile Ads SDK. With this, we would recommend checking out developer help forums (such as StackOverflow) for further guidance on this.
Reply all
Reply to author
Forward
0 new messages