...
Do iOS Get Started all the way until finishing step 35
Step
...
summary
Add The initialization code.
Create the Channel between web and native with
R89SDK.shared.configureWebView()
method.Use
R89SDK.shared.loadUrlWithConsentDataOrWait()
to load your urls URLs into the webviewweb view.Test everything is working.
Change everything to production codcode.
Your app is now prepared for monetization with us.
...
Note |
---|
We require the SDK to be initialized only once as early as possible so for this purpose using the UIApplicationDelegate’s didFinishLaunchingWithOptions method or the first UIViewController’s viewDidLoad method is recomended. |
Override the didFinishLaunchingWithOptions
delegate method inside your UIApplicationDelegate
class UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:)
method.
Code Block | ||
---|---|---|
| ||
import UIKit import R89SDK @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // This is for testing purposes, remove it on prod R89SDK.shared.setLogLevel(level: LogLevels.debug) // This is for testing purposes, remove it on prod R89SDK.shared.setDebug() // This is for testing purposes, remove it on prod // publisherId and appId are for testing purposes, remove it on prod R89SDK.shared.initialize( publisherId: "TestRefinery89ID", /* This is for testing purposes, change it on prod */ appId: "TestDemoApp", /* This is for testing purposes, change it on prod */ singleLine: false, publisherInitializationEvents: nil ) return true } } |
...
Info |
---|
If you want to have native ads to be triggered from the webview we recommend using the manual configuration alongside some kind of javascript interface implemented in the web side to trigger native code, although first finish this whole guide and then go to the manual |
Create the
...
channel
Right after Initialization, you should use the following methods
Code Block | ||
---|---|---|
| ||
import UIKit import R89SDK import WebKit class ViewController: UIViewController, WKNavigationDelegate { @IBOutlet var wkWebView: WKWebView! ... override func viewDidLoad() { super.viewDidLoad() ... let url = <YOUR-URL> wkWebView.navigationDelegate = self // This helps the channel to identify this as an app let userAgent = R89SDK.shared.getUserAgent( webView: wkWebView, siteName: <YOUR-SITE-NAME>) R89SDK.shared.configureWebView(webView: wkWebView, userAgent: userAgent) ... } } |
...
Use the following method to replace any webview.load()
methods method usages you might have
Code Block | ||
---|---|---|
| ||
R89SDK.shared.loadUrlWithConsentDataOrWait(webView: wkWebView, url: url) |
Note |
---|
This url must only be the urls related to you content, or own. Other urls can be loaded normally. with |
Go into production
Remove the methods
R89SDK.shared.setDebug()
.Change the Google app ID
GADApplicationIdentifier
in the manifestinfo.plist
for the production one.Change the
appId
andpublisherId
in the initialization method for the production ones.Change the
r89ConfigId
in the formats for the production ones.it’s also recommended to remove
R89SDK.shared.setLogLevel(level: LogLevels.DEBUGdebug)
but not needed.
How does it work?
Works by creating a channel linking our SDK to your current in-web monetization solutions. This channel just makes sure that the ad units on the web know that the current environment is app and also sends the consent data so you get the same consent on both sides complying with privacy policies.
...