Android - SDK-dokumentation för att tjäna pengar på appar

⌘K
  1. Android - Tjäna pengar på app SD...
  2. Använd manual
  3. Initialiseringstyper
  4. WebView Initialization

WebView Initialization

Hur fungerar det?

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

 

Vad behövs?

  1. Kom igång genom att skapa ett konto hos oss. Kontakta oss för att initiera processen och tillhandahålla all nödvändig information som listas nedan.
  2. Lägg till initialiseringskoden.
  3. Follow This Guide
  4. Your web-app is now prepared for monetization with us.

 

Information vi behöver om din app

 

Exempel

I slutet av exemplet kan du hitta en mall för produktion här.

Om du är i felsökningsläge, lägg till dessa rader före något av exemplen. Att markera SDK som Felsökning kommer att få SDK att använda ConfigBuilder ID och data.

R89SDK.shared.setLogLevel(level: LogLevels.debug)
R89SDK.shared.setDebug(getLocalFakeData: true, 
                       forceCMP: true, 
                       useProductionAuctionServer: false)

Exemplet i demon

Den envärde flaggan är inställd på falskt. Use RaffinaderiAnnonsfabrik att skapa och placera annonserna i en UIView.

@IBOutlet var wkWebView: WKWebView!
R89SDK.shared.initialize( publisherId: "TestRefinery89ID",
                          appId: "TestAppId",
                          singleLine: false,
                          publisherInitializationEvents: nil)
let url = "https://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)

Mall


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)

Initiering

För att initialisera SDK:t, anropa R89SDK.shared.initialisera metod och skicka utgivarId och 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://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 annonsbehållare.

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://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)
    }
}

Observera att du inte behöver vänta på SDK-initialisering, annonser kan användas direkt efter att du har anropat R89SDK.shared.initialisera metod.

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

Hur kan vi hjälpa till?