SDK - Offerwall
Offerwall Integration
1. Display the Offerwall
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) {}
}2. (Optional) Customize Toolbar Title
Last updated