i made ios app with my WordPress Web site utilizing Relaxation api to show content material in WkWebView. now what’s need is to show Adsterra community advert after half content material and i’ve written code like this..
let htmlString: String = "<html><head><type kind="textual content/css"> physique {font-family: "SFUIText-Common"; text-align: justify; } img { max-width: 100%; width: auto; peak: auto; } iframe { max-width: auto; width: auto; peak: auto; }</type> </head><physique>" + self.webContent + "</physique></html>"
let halfwayIndex = htmlString.index(htmlString.startIndex, offsetBy: htmlString.depend / 2)
let htmlBeforeAd = String(htmlString.prefix(upTo: halfwayIndex))
let htmlAfterAd = String(htmlString.suffix(from: halfwayIndex))
//Advert Code Right here
let adCode = "<div><script kind="textual content/javascript"> atOptions = { 'key' : '6d9a5a16b8cff8984586ef********', 'format' : 'iframe', 'peak' : 250, 'width' : 300, 'params' : {} }; doc.write('<scr' + 'ipt kind="textual content/javascript" src="//www.profitablecreativeformat.com/6d9a5a16b8cff******ef06b5afd1be/invoke.js"></scr' + 'ipt>'); </script></div>"
let htmlStringWithAd = htmlBeforeAd + adCode + htmlAfterAd
self.webView.loadHTMLString(htmlStringWithAd, baseURL: nil)
when is use
let adCode = "<div>your advert code right here</div>"
`
i can see "your advert code right here" after half content material however not the advert.. can anybody please assist me out ?
i've additionally tried
`<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>`
and this:
```
let webConfiguration = WKWebViewConfiguration()
webConfiguration.preferences.javaScriptEnabled = true
let webView = WKWebView(body: .zero, configuration: webConfiguration)
```