Skip to content

Commit

Permalink
Use manual rendering helper (#121)
Browse files Browse the repository at this point in the history
* use new manual rendering helpers to show blocking ad
  • Loading branch information
standa-dev authored Jan 15, 2025
1 parent 0b251eb commit 961194f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions Application/Sources/Test/TestRenderAdViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ final class TestRenderAdViewController: UIViewController {
fatalError("init(coder:) has not been implemented")
}

static func showBlocking(from: UIViewController, ad: NimbusAd) {
let adView = NimbusAdView(adPresentingViewController: from)
adView.showsSKOverlay = ad.extensions?.skAdNetwork != nil
let controller = NimbusAdViewController(adView: adView, ad: ad, companionAd: nil)
controller.modalPresentationStyle = .fullScreen

adView.adPresentingViewController = controller
adView.isBlocking = true

from.present(controller, animated: true) {
controller.renderAndStart()
static func showBlocking(from: UIViewController, ad: NimbusAd) -> AdController? {
do {
return try Nimbus.loadBlocking(
ad: ad,
presentingViewController: from,
delegate: nil,
isRewarded: false
)
} catch {
Nimbus.shared.logger.log("\(#file) failed to render blocking ad, error: \(error)", level: .error)
}

return nil
}

override func viewDidLoad() {
Expand Down
2 changes: 1 addition & 1 deletion Application/Sources/Test/TestRenderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class TestRenderViewController: DemoViewController {
let ad = getAdFromMarkup(adMarkup: adMarkup)

if isBlocking {
TestRenderAdViewController.showBlocking(from: self, ad: ad)
TestRenderAdViewController.showBlocking(from: self, ad: ad)?.start()
} else {
navigationController?.pushViewController(
TestRenderAdViewController(ad: ad),
Expand Down

0 comments on commit 961194f

Please sign in to comment.