-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNimbusUnityAdRenderer.swift
65 lines (56 loc) · 1.88 KB
/
NimbusUnityAdRenderer.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// NimbusUnityAdRenderer.swift
// NimbusUnityKit
//
// Created on 6/2/21.
// Copyright © 2021 Nimbus Advertising Solutions Inc. All rights reserved.
//
@_exported import NimbusRenderKit
import UIKit
public final class NimbusUnityAdRenderer: AdRenderer {
public init() {}
public func render(
ad: NimbusAd,
companionAd: NimbusCompanionAd?,
container: UIView,
adPresentingViewController: UIViewController?,
delegate: (any AdControllerDelegate)?
) -> AdController {
let adController = NimbusUnityAdController(
ad: ad,
container: container,
logger: Nimbus.shared.logger,
delegate: delegate,
isBlocking: false,
isRewarded: false,
adPresentingViewController: adPresentingViewController
)
// Ensure that the ad load begins AFTER the publisher has had a chance to retrieve the ad controller
DispatchQueue.main.async {
adController.load()
}
return adController
}
public func renderBlocking(
ad: NimbusAd,
isRewarded: Bool,
companionAd: NimbusCompanionAd?,
adPresentingViewController: UIViewController,
delegate: (any AdControllerDelegate)?
) -> AdController {
let adController = NimbusUnityAdController(
ad: ad,
container: adPresentingViewController.nimbusContainer,
logger: Nimbus.shared.logger,
delegate: delegate,
isBlocking: true,
isRewarded: isRewarded,
adPresentingViewController: adPresentingViewController
)
// Ensure that the ad load begins AFTER the publisher has had a chance to retrieve the ad controller
DispatchQueue.main.async {
adController.load()
}
return adController
}
}