SDK - Offerwall
Offerwall Integration
Prerequisite: Complete the SDK Installation first.
The Offerwall displays a full-screen WebView with all available campaigns. The SDK manages the entire UI — you just present it.
1. Display the Offerwall
The SDK ships MCWebViewController, a UIViewController subclass you can push onto a UINavigationController (UIKit) or wrap with UIViewControllerRepresentable (SwiftUI).
First, wrap MCWebViewController so SwiftUI can host it:
import SwiftUI
import MyChipsSdk
// Definition of the WebViewWrapper struct.
// UIViewControllerRepresentable allows integrating a UIViewController into a SwiftUI interface.
struct WebViewWrapper: UIViewControllerRepresentable {
// Property for the ad unit identifier, passed during initialization.
let adunitId: String
// Access to the SwiftUI environment to manage presentation mode.
// @Environment provides access to shared values throughout the app.
@Environment(\.presentationMode) var presentationMode
// Creates and configures the UIViewController (required by UIViewControllerRepresentable).
func makeUIViewController(context: Context) -> UINavigationController {
// Initialize the custom MCWebViewController with the adunitId.
let webVC = MCWebViewController(
adunitId: adunitId,
// Closure defining the behavior when the webViewController is closed.
// This dismisses the view controller using presentationMode.
onClose: {
presentationMode.wrappedValue.dismiss()
}
)
// Wrap the webViewController inside a UINavigationController.
// This allows navigation functionality if required.
return UINavigationController(rootViewController: webVC)
}
// Method to update the existing UIViewController with new data (required by UIViewControllerRepresentable).
// Not implemented here as no updates are needed for this functionality.
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {}
}Then use it inside a NavigationStack / NavigationView:
That's it. If you want to open the offerwall on a button press, you can just add a button and invoke the showOfferwall method:
Replace
AD_UNIT_IDwith your Ad unit ID from the Developer Portal.
2. (Optional) Customize Toolbar Title
If no title is set, the toolbar remains blank.
Last updated