Skip to content

Commit

Permalink
Prebid plugin render changes (#1068)
Browse files Browse the repository at this point in the history
* feat: ad view custom renderer prototype

* feat: interstitial custom renderer prototype

* feat: introduce PrebidMobileDisplayViewProtocol and PrebidMobileInterstitialControllerProtocol

* feat: send data in ORTB request

* fix: plugin register unit tests

* tests: add request tests

* fix: missing winning ad format

* feat: enhance InternalTestApp examples

* feat: add plugin renderer cases to demo apps

* feat: minor corrections

* feat: unregister plugin renderer

* fix: resolve issues after rebasing

* feat: make universal Renderer protocol

* feat: change data property type  & use default banner view if none provided

* feat: remove isSupportRendering

* feat: store SDK renderer in plugin array & register plugin during SDK initialization

* feat: restore .xcodeproj

* feat: add log message in case default renderer wasn't found in registry
  • Loading branch information
OlenaPostindustria authored Jan 6, 2025
1 parent 41d8758 commit 46e330f
Show file tree
Hide file tree
Showing 84 changed files with 2,851 additions and 811 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,42 @@ public class PrebidAdMobBannerAdapter:
displayView?.interactionDelegate = self
displayView?.loadingDelegate = self

displayView?.displayAd()
displayView?.loadAd()
}

// MARK: - DisplayViewLoadingDelegate

public func displayViewDidLoadAd(_ displayView: PBMDisplayView) {
public func displayViewDidLoadAd(_ displayViewManager: UIView) {
if let handler = completionHandler {
delegate = handler(self, nil)
}
}

public func displayView(_ displayView: PBMDisplayView, didFailWithError error: Error) {
public func displayView(_ displayViewManager: UIView, didFailWithError error: Error) {
if let handler = completionHandler {
delegate = handler(nil, error)
}
}

// MARK: - PBMDisplayViewInteractionDelegate

public func trackImpression(forDisplayView: PBMDisplayView) {
public func trackImpression(forDisplayView: UIView) {
delegate?.reportImpression()
}

public func viewControllerForModalPresentation(fromDisplayView: PBMDisplayView) -> UIViewController? {
public func viewControllerForModalPresentation(fromDisplayView: UIView) -> UIViewController? {
return adConfiguration?.topViewController ?? UIApplication.shared.windows.first?.rootViewController
}

public func didLeaveApp(from displayView: PBMDisplayView) {
public func didLeaveApp(from displayView: UIView) {
delegate?.reportClick()
}

public func willPresentModal(from displayView: PBMDisplayView) {
public func willPresentModal(from displayView: UIView) {
delegate?.willPresentFullScreenView()
}

public func didDismissModal(from displayView: PBMDisplayView) {
public func didDismissModal(from displayView: UIView) {
delegate?.willDismissFullScreenView()
delegate?.didDismissFullScreenView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ public class PrebidAdMobInterstitialAdapter:

// MARK: - InterstitialControllerLoadingDelegate

public func interstitialControllerDidLoadAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidLoadAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
adAvailable = true

if let handler = completionHandler {
delegate = handler(self, nil)
}
}

public func interstitialController(_ interstitialController: InterstitialController, didFailWithError error: Error) {
public func interstitialController(
_ interstitialController: PrebidMobileInterstitialControllerProtocol,
didFailWithError error: Error
) {
adAvailable = false

if let handler = completionHandler {
Expand All @@ -113,28 +116,29 @@ public class PrebidAdMobInterstitialAdapter:

// MARK: - InterstitialControllerInteractionDelegate

public func trackImpression(forInterstitialController: InterstitialController) {
public func trackImpression(forInterstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.reportImpression()
}

public func viewControllerForModalPresentation(fromInterstitialController: InterstitialController) -> UIViewController? {
public func viewControllerForModalPresentation(
fromInterstitialController: PrebidMobileInterstitialControllerProtocol
) -> UIViewController? {
rootViewController
}

public func interstitialControllerDidClickAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidClickAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.reportClick()
}

public func interstitialControllerDidCloseAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidCloseAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.willDismissFullScreenView()
delegate?.didDismissFullScreenView()
}

public func interstitialControllerDidDisplay(_ interstitialController: InterstitialController) {
public func interstitialControllerDidDisplay(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.willPresentFullScreenView()
}

public func interstitialControllerDidComplete(_ interstitialController: InterstitialController) {}

public func interstitialControllerDidLeaveApp(_ interstitialController: InterstitialController) {}
public func interstitialControllerDidComplete(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {}
public func interstitialControllerDidLeaveApp(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,54 +113,54 @@ public class PrebidAdMobRewardedAdapter:

// MARK: - InterstitialControllerLoadingDelegate

public func interstitialControllerDidLoadAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidLoadAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
adAvailable = true

if let handler = completionHandler {
delegate = handler(self, nil)
}
}

public func interstitialController(_ interstitialController: InterstitialController, didFailWithError error: Error) {
public func interstitialController(_ interstitialController: PrebidMobileInterstitialControllerProtocol, didFailWithError error: Error) {
adAvailable = false
}

// MARK: - InterstitialControllerInteractionDelegate

public func trackImpression(forInterstitialController: InterstitialController) {
public func trackImpression(forInterstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.reportImpression()
}

public func trackUserReward(_ interstitialController: InterstitialController, _ reward: PrebidReward) {
public func trackUserReward(_ interstitialController: PrebidMobileInterstitialControllerProtocol, _ reward: PrebidReward) {
delegate?.didRewardUser()
}

public func interstitialControllerDidClickAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidClickAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.reportClick()
}

public func interstitialControllerDidCloseAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidCloseAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
adAvailable = false
delegate?.willDismissFullScreenView()
delegate?.didDismissFullScreenView()
}

public func interstitialControllerDidDisplay(_ interstitialController: InterstitialController) {
public func interstitialControllerDidDisplay(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.willPresentFullScreenView()
delegate?.didStartVideo()
delegate?.didEndVideo()
}

public func interstitialControllerDidComplete(_ interstitialController: InterstitialController) {
public func interstitialControllerDidComplete(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
adAvailable = false
rootViewController = nil

delegate?.didRewardUser()
}

public func viewControllerForModalPresentation(fromInterstitialController: InterstitialController) -> UIViewController? {
public func viewControllerForModalPresentation(fromInterstitialController: PrebidMobileInterstitialControllerProtocol) -> UIViewController? {
rootViewController
}

public func interstitialControllerDidLeaveApp(_ interstitialController: InterstitialController) {}
public func interstitialControllerDidLeaveApp(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ public class PrebidAdMobVideoInterstitialAdapter:

// MARK: - InterstitialControllerLoadingDelegate

public func interstitialControllerDidLoadAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidLoadAd(
_ interstitialController: PrebidMobileInterstitialControllerProtocol
) {
adAvailable = true

if let handler = completionHandler {
delegate = handler(self, nil)
}
}

public func interstitialController(_ interstitialController: InterstitialController, didFailWithError error: Error) {
public func interstitialController(
_ interstitialController: PrebidMobileInterstitialControllerProtocol,
didFailWithError error: Error
) {
adAvailable = false

if let handler = completionHandler {
Expand All @@ -121,28 +126,29 @@ public class PrebidAdMobVideoInterstitialAdapter:

// MARK: - InterstitialControllerInteractionDelegate

public func trackImpression(forInterstitialController: InterstitialController) {
public func trackImpression(forInterstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.reportImpression()
}

public func viewControllerForModalPresentation(fromInterstitialController: InterstitialController) -> UIViewController? {
public func viewControllerForModalPresentation(
fromInterstitialController: PrebidMobileInterstitialControllerProtocol
) -> UIViewController? {
rootViewController
}

public func interstitialControllerDidClickAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidClickAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.reportClick()
}

public func interstitialControllerDidCloseAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidCloseAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.willDismissFullScreenView()
delegate?.didDismissFullScreenView()
}

public func interstitialControllerDidDisplay(_ interstitialController: InterstitialController) {
public func interstitialControllerDidDisplay(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
delegate?.willPresentFullScreenView()
}

public func interstitialControllerDidLeaveApp(_ interstitialController: InterstitialController) {}

public func interstitialControllerDidComplete(_ interstitialController: InterstitialController) {}
public func interstitialControllerDidLeaveApp(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {}
public func interstitialControllerDidComplete(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import Foundation
import PrebidMobile
import AppLovinSDK

extension PrebidMAXMediationAdapter: MAAdViewAdapter, DisplayViewLoadingDelegate, DisplayViewInteractionDelegate {
extension PrebidMAXMediationAdapter:
MAAdViewAdapter,
DisplayViewLoadingDelegate,
DisplayViewInteractionDelegate {

// MARK: - MAAdViewAdapter

Expand Down Expand Up @@ -59,41 +62,36 @@ extension PrebidMAXMediationAdapter: MAAdViewAdapter, DisplayViewLoadingDelegate
displayView?.interactionDelegate = self
displayView?.loadingDelegate = self

displayView?.displayAd()
displayView?.loadAd()
}

// MARK: - DisplayViewLoadingDelegate

public func displayViewDidLoadAd(_ displayView: PBMDisplayView) {
public func displayViewDidLoadAd(_ displayView: UIView) {
bannerDelegate?.didLoadAd(forAdView: displayView)
}

public func displayView(_ displayView: PBMDisplayView, didFailWithError error: Error) {
public func displayView(_ displayView: UIView, didFailWithError error: Error) {
let maError = MAAdapterError(nsError: error)
bannerDelegate?.didFailToLoadAdViewAdWithError(maError)
}

// MARK: DisplayViewInteractionDelegate

public func trackImpression(forDisplayView: PBMDisplayView) {

}

public func viewControllerForModalPresentation(fromDisplayView: PBMDisplayView) -> UIViewController? {
public func viewControllerForModalPresentation(fromDisplayView: UIView) -> UIViewController? {
return UIApplication.shared.windows.first?.rootViewController
}

public func didLeaveApp(from displayView: PBMDisplayView) {

}

public func willPresentModal(from displayView: PBMDisplayView) {
public func willPresentModal(from displayView: UIView) {
bannerDelegate?.didClickAdViewAd()
bannerDelegate?.didExpandAdViewAd()
}

public func didDismissModal(from displayView: PBMDisplayView) {
public func didDismissModal(from displayView: UIView) {
bannerDelegate?.didHideAdViewAd()
bannerDelegate?.didCollapseAdViewAd()
}

public func trackImpression(forDisplayView: UIView) {}
public func didLeaveApp(from displayView: UIView) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ extension PrebidMAXMediationAdapter: MAInterstitialAdapter,

// MARK: - InterstitialControllerLoadingDelegate

public func interstitialControllerDidLoadAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidLoadAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
interstitialAdAvailable = true
interstitialDelegate?.didLoadInterstitialAd()
rewardedDelegate?.didLoadRewardedAd()
}

public func interstitialController(_ interstitialController: InterstitialController, didFailWithError error: Error) {
public func interstitialController(
_ interstitialController: PrebidMobileInterstitialControllerProtocol,
didFailWithError error: Error
) {
interstitialAdAvailable = false
let maError = MAAdapterError(nsError: error)
interstitialDelegate?.didFailToLoadInterstitialAdWithError(maError)
Expand All @@ -136,45 +139,32 @@ extension PrebidMAXMediationAdapter: MAInterstitialAdapter,

// MARK: - InterstitialControllerInteractionDelegate

public func trackImpression(forInterstitialController: InterstitialController) {}

public func interstitialControllerDidClickAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidClickAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
interstitialDelegate?.didClickInterstitialAd()
rewardedDelegate?.didClickRewardedAd()
}

public func interstitialControllerDidCloseAd(_ interstitialController: InterstitialController) {
public func interstitialControllerDidCloseAd(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
interstitialDelegate?.didHideInterstitialAd()
rewardedDelegate?.didHideRewardedAd()
}

public func interstitialControllerDidLeaveApp(_ interstitialController: InterstitialController) {}

public func interstitialControllerDidDisplay(_ interstitialController: InterstitialController) {
public func interstitialControllerDidDisplay(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
interstitialDelegate?.didDisplayInterstitialAd()
rewardedDelegate?.didDisplayRewardedAd()
}

public func interstitialControllerDidComplete(_ interstitialController: InterstitialController) {
public func interstitialControllerDidComplete(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {
interstitialAdAvailable = false
rewardedDelegate?.didRewardUser(with: MAReward())
}

public func viewControllerForModalPresentation(
fromInterstitialController: InterstitialController
fromInterstitialController: PrebidMobileInterstitialControllerProtocol
) -> UIViewController? {
return UIApplication.shared.windows.first?.rootViewController
}

public func trackUserReward(
_ interstitialController: InterstitialController,
_ reward: PrebidReward
) {
let reward = MAReward(
amount: reward.count?.intValue ?? 0,
label: reward.type ?? ""
)

rewardedDelegate?.didRewardUser(with: reward)
}
public func trackImpression(forInterstitialController: PrebidMobileInterstitialControllerProtocol) {}
public func interstitialControllerDidLeaveApp(_ interstitialController: PrebidMobileInterstitialControllerProtocol) {}
}
Loading

0 comments on commit 46e330f

Please sign in to comment.