How Does It Work?
We configure your webview to create a channel between our web header script and the Native SDK, this enables better privacy compliance and targeting.
With this in place you can use loadUrlWithConsentDataOrWait to load the URL with consent data
What Is Needed?
- Get started by creating an account with us. Contact us to initiate the process and provide all the necessary information listed below.
- Add the Initialization code.
- Follow This Guide
- Your web-app is now prepared for monetization with us.
Information we require about your app
- Store Link (Google o Apple one).
- Domain of the app. E.g.: www.refinery89.com.
Examples
At the end of the example, you can find a template for production here.
If you are in Debug mode, please add these lines before any of the examples. Marking the SDK as Debug will make the SDK use ConfigBuilder IDs and data.
R89SDK.shared.setLogLevel(level: LogLevels.debug)
R89SDK.shared.setDebug(getLocalFakeData: true,
forceCMP: true,
useProductionAuctionServer: false)
The example in the demo
The singleLine flag is set to false. Use the RefineryAdFactory to create and place the ADs in a UIView.
@IBOutlet var wkWebView: WKWebView!
R89SDK.shared.initialize( publisherId: "TestRefinery89ID",
appId: "TestAppId",
singleLine: false,
publisherInitializationEvents: nil)
let url = "https://wp.refinery89.com/"
wkWebView.navigationDelegate = self
let userAgent = R89SDK.shared.getUserAgent(webView: wkWebView, siteName: "WebViewDemo")
R89SDK.shared.configureWebView(webView: wkWebView, userAgent: userAgent)
R89SDK.shared.loadUrlWithConsentDataOrWait(webView: wkWebView, url: url)
Template
R89SDK.shared.initialize(publisherId: <YOUR PUBLISHER ID>,
appId: <YOUR APP ID>,
singleLine: false,
publisherInitializationEvents: nil)
let url = <YOUR URL>
wkWebView.navigationDelegate = self
let userAgent = R89SDK.shared.getUserAgent(webView: wkWebView, siteName: "WebViewDemo")
R89SDK.shared.configureWebView(webView: wkWebView, userAgent: userAgent)
R89SDK.shared.loadUrlWithConsentDataOrWait(webView: wkWebView, url: url)
Initialization
To initialize the SDK call R89SDK.shared.initialize method and pass the publisherId y appId.
class MainViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
R89SDK.shared.initialize(publisherId: "TestRefinery89ID",
appId: "TestConfigDemoApp",
singleLine: false,
publisherInitializationEvents: nil)
}
}
After initilization you can configure your WebView using R89SDK.shared.configureWebView. You will also need to create userAgent for your webView, you can do so with R89SDK.shared.getUserAgent.
class MainViewController: UIViewController {
@IBOutlet var adContainer:UIView! = nil
override func viewDidLoad() {
super.viewDidLoad()
R89SDK.shared.initialize(publisherId: <YOUR PUBLISHER ID>,
appId: <YOUR APP ID>,
singleLine: false,
publisherInitializationEvents: nil)
let url = "https://wp.refinery89.com/"
wkWebView.navigationDelegate = self
let userAgent = R89SDK.shared.getUserAgent(webView: wkWebView, siteName: "WebViewDemo")
R89SDK.shared.configureWebView(webView: wkWebView, userAgent: userAgent)
R89SDK.shared.loadUrlWithConsentDataOrWait(webView: wkWebView, url: url)
}
}
At this point, the advertisements can be displayed. To place a simple banner Ad add RefineryAdFactory.shared.createBanner like in the example below. The SDK will put the advertisement inside the provided adContainer.
class MainViewController: UIViewController {
@IBOutlet var adContainer:UIView! = nil
override func viewDidLoad() {
super.viewDidLoad()
R89SDK.shared.initialize(publisherId: <YOUR PUBLISHER ID>,
appId: <YOUR APP ID>,
singleLine: false,
publisherInitializationEvents: nil)
let url = "https://wp.refinery89.com/"
wkWebView.navigationDelegate = self
let userAgent = R89SDK.shared.getUserAgent(webView: wkWebView, siteName: "WebViewDemo")
R89SDK.shared.configureWebView(webView: wkWebView, userAgent: userAgent)
R89SDK.shared.loadUrlWithConsentDataOrWait(webView: wkWebView, url: url)
RefineryAdFactory.shared.createBanner(configurationId: <CONFIGURATION ID>, wrapper: adContainer, lifecycleCallbacks: nil)
}
}
Note that no need to await for SDK initialization, advertisements can be used right after calling the R89SDK.shared.initialize method.
If your webPage, that you want to load in a webView, already has CMP and you dont want for both CMPs ro show, you can use R89SDK.shared.addScriptToNotShowCMPInWebView to add script to webView and disable web CMP.
func webView(_ webView: WKWebView) {
R89SDK.shared.addScriptToNotShowCMPInWebView(webView: webView)
}