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
}
|
||||||