iOS Integration
On iOS you can render the offerwall inside a WKWebView, or hand it to
SFSafariViewController if you prefer the system browser chrome.
URL
GET
http://adplusmedia.com/app/iframe/[APP_ID]/[USER_ID]
WKWebView example
swift
import UIKit
import WebKit
class OfferwallViewController: UIViewController {
private var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
webView = WKWebView(frame: view.bounds, configuration: config)
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(webView)
let appId = "1042"
let userId = currentUserId.addingPercentEncoding(
withAllowedCharacters: .urlPathAllowed
) ?? ""
let urlString = "http://adplusmedia.com/app/iframe/\(appId)/\(userId)"
if let url = URL(string: urlString) {
webView.load(URLRequest(url: url))
}
}
}
swift
import SwiftUI
import WebKit
struct OfferwallView: UIViewRepresentable {
let appId: String
let userId: String
func makeUIView(context: Context) -> WKWebView {
WKWebView()
}
func updateUIView(_ webView: WKWebView, context: Context) {
let encoded = userId.addingPercentEncoding(
withAllowedCharacters: .urlPathAllowed
) ?? ""
guard let url = URL(
string: "http://adplusmedia.com/app/iframe/\(appId)/\(encoded)"
) else { return }
webView.load(URLRequest(url: url))
}
}
SFSafariViewController
The simplest option, at the cost of leaving your app's visual context:
swift
import SafariServices
let urlString = "http://adplusmedia.com/app/iframe/[APP_ID]/[USER_ID]"
if let url = URL(string: urlString) {
let safari = SFSafariViewController(url: url)
present(safari, animated: true)
}
Replace [APP_ID] with your placement ID and [USER_ID] with the unique identifier of the user viewing the wall. Percent-encode the user ID before building the URL.
App Store redirects
CPI offers send the user to the App Store. In a WKWebView you must allow those navigations
to leave the web view:
swift
func webView(_ webView: WKWebView,
decidePolicyFor navigationAction: WKNavigationAction,
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if let url = navigationAction.request.url,
url.host?.contains("apps.apple.com") == true ||
url.scheme == "itms-apps" {
UIApplication.shared.open(url)
decisionHandler(.cancel)
return
}
decisionHandler(.allow)
}
If App Store links are blocked inside the web view, installs never complete and your users will not be credited. Test at least one CPI offer end to end before going live.