Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid plugin render changes #1068

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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