Skip to content

Commit

Permalink
feat: unregister plugin renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
OlenaPostindustria committed Dec 5, 2024
1 parent d3b3e83 commit f5f4fc1
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Example/PrebidDemo/PrebidDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
53514C9F2CFF988E00A480C0 /* SampleInterstitialController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514C9B2CFF988E00A480C0 /* SampleInterstitialController.swift */; };
53514CA02CFF988E00A480C0 /* SampleAdViewRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514C992CFF988E00A480C0 /* SampleAdViewRenderer.swift */; };
53514CA12CFF988E00A480C0 /* SampleInterstitialRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514C9A2CFF988E00A480C0 /* SampleInterstitialRenderer.swift */; };
53514CA32CFF9DD000A480C0 /* InAppDisplayInterstitialPluginInterstitialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514CA22CFF9DD000A480C0 /* InAppDisplayInterstitialPluginInterstitialViewController.swift */; };
53514CA32CFF9DD000A480C0 /* InAppDisplayInterstitialPluginRendererViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514CA22CFF9DD000A480C0 /* InAppDisplayInterstitialPluginRendererViewController.swift */; };
53514CA72CFFA52A00A480C0 /* SampleAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53514CA62CFFA52A00A480C0 /* SampleAdView.m */; };
53514CAA2CFFA62700A480C0 /* SampleAdViewRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 53514CA92CFFA62700A480C0 /* SampleAdViewRenderer.m */; };
53514CAD2CFFA99200A480C0 /* InAppDisplayBannerPluginRendererViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53514CAC2CFFA99200A480C0 /* InAppDisplayBannerPluginRendererViewController.m */; };
Expand Down Expand Up @@ -291,7 +291,7 @@
53514C992CFF988E00A480C0 /* SampleAdViewRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleAdViewRenderer.swift; sourceTree = "<group>"; };
53514C9A2CFF988E00A480C0 /* SampleInterstitialRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleInterstitialRenderer.swift; sourceTree = "<group>"; };
53514C9B2CFF988E00A480C0 /* SampleInterstitialController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleInterstitialController.swift; sourceTree = "<group>"; };
53514CA22CFF9DD000A480C0 /* InAppDisplayInterstitialPluginInterstitialViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppDisplayInterstitialPluginInterstitialViewController.swift; sourceTree = "<group>"; };
53514CA22CFF9DD000A480C0 /* InAppDisplayInterstitialPluginRendererViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppDisplayInterstitialPluginRendererViewController.swift; sourceTree = "<group>"; };
53514CA52CFFA52A00A480C0 /* SampleAdView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SampleAdView.h; sourceTree = "<group>"; };
53514CA62CFFA52A00A480C0 /* SampleAdView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SampleAdView.m; sourceTree = "<group>"; };
53514CA82CFFA62700A480C0 /* SampleAdViewRenderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SampleAdViewRenderer.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -566,7 +566,7 @@
53072B7629226CFE00228462 /* InAppDisplayBannerViewController.swift */,
53514C952CFF97DB00A480C0 /* InAppDisplayBannerPluginRendererViewController.swift */,
53072B7A292270EE00228462 /* InAppDisplayInterstitialViewController.swift */,
53514CA22CFF9DD000A480C0 /* InAppDisplayInterstitialPluginInterstitialViewController.swift */,
53514CA22CFF9DD000A480C0 /* InAppDisplayInterstitialPluginRendererViewController.swift */,
5344E69E2922796000A1F582 /* InAppNativeViewController.swift */,
53072B7829226EF400228462 /* InAppVideoBannerViewController.swift */,
53072B802922753D00228462 /* InAppVideoInterstitialLandscapeViewController.swift */,
Expand Down Expand Up @@ -1544,7 +1544,7 @@
53B03D8C291A6562000117E1 /* ExamplesViewController.swift in Sources */,
5344E6C32922AAE500A1F582 /* MAXVideoRewardedViewController.swift in Sources */,
53072B6929217D1800228462 /* GAMOriginalAPIVideoInstreamViewController.swift in Sources */,
53514CA32CFF9DD000A480C0 /* InAppDisplayInterstitialPluginInterstitialViewController.swift in Sources */,
53514CA32CFF9DD000A480C0 /* InAppDisplayInterstitialPluginRendererViewController.swift in Sources */,
5344E6A92922815000A1F582 /* GAMVideoRewardedViewController.swift in Sources */,
53072B7B292270EE00228462 /* InAppDisplayInterstitialViewController.swift in Sources */,
53514C9E2CFF988E00A480C0 /* SampleAdView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @interface InAppDisplayBannerPluginRendererViewController ()

// Prebid
@property (nonatomic) BannerView * prebidBannerView;
@property (nonatomic, strong) SampleAdViewRenderer * samplePluginRenderer;

@end

Expand All @@ -34,12 +35,17 @@ - (void)loadView {
[self createAd];
}

- (void)dealloc {
// Unregister plugin when you no longer needed
[Prebid unregisterPluginRenderer:self.samplePluginRenderer];
}

- (void)createAd {
// 1. Create a plugin renderer
SampleAdViewRenderer * samplePluginRenderer = [SampleAdViewRenderer new];
self.samplePluginRenderer = [SampleAdViewRenderer new];

// 2. Register the plugin renderer
[Prebid registerPluginRenderer:samplePluginRenderer];
[Prebid registerPluginRenderer:self.samplePluginRenderer];

// 3. Create a BannerView
self.prebidBannerView = [[BannerView alloc] initWithFrame:CGRectMake(0, 0, self.adSize.width, self.adSize.height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @interface InAppDisplayInterstitialPluginRendererViewController ()

// Prebid
@property (nonatomic) InterstitialRenderingAdUnit * renderingInterstitial;
@property (nonatomic, strong) SampleInterstitialRenderer * samplePluginRenderer;

@end

Expand All @@ -34,12 +35,17 @@ - (void)loadView {
[self createAd];
}

- (void)dealloc {
// Unregister plugin when you no longer needed
[Prebid unregisterPluginRenderer:self.samplePluginRenderer];
}

- (void)createAd {
// 1. Create a plugin renderer
SampleInterstitialRenderer * samplePluginRenderer = [SampleInterstitialRenderer new];
self.samplePluginRenderer = [SampleInterstitialRenderer new];

// 2. Register the plugin renderer
[Prebid registerPluginRenderer:samplePluginRenderer];
[Prebid registerPluginRenderer:self.samplePluginRenderer];

// 3. Create a InterstitialRenderingAdUnit
self.renderingInterstitial = [[InterstitialRenderingAdUnit alloc] initWithConfigID:storedImpDisplayInterstitialPluginRendererInApp];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,45 @@ import PrebidMobile

fileprivate let storedImpDisplayBanner = "prebid-demo-display-banner-320-50-custom-ad-view-renderer"

class InAppDisplayBannerPluginRendererViewController: BannerBaseViewController, BannerViewDelegate {
class InAppDisplayBannerPluginRendererViewController:
BannerBaseViewController,
BannerViewDelegate {

// Prebid
private var prebidBannerView: BannerView!
private let samplePluginRenderer = SampleAdViewRenderer()

override func loadView() {
super.loadView()

createAd()
}

deinit {
// Unregister plugin when you no longer needed
Prebid.unregisterPluginRenderer(samplePluginRenderer)
}

func createAd() {
// 1. Create a plugin renderer
let samplePluginRenderer = SampleAdViewRenderer()

// 2. Register the plugin renderer
// 1. Register the plugin renderer
Prebid.registerPluginRenderer(samplePluginRenderer)

// 3. Create a BannerView
// 2. Create a BannerView
prebidBannerView = BannerView(
frame: CGRect(origin: .zero, size: adSize),
configID: storedImpDisplayBanner,
adSize: adSize
)

// 4. Configure the BannerView
// 3. Configure the BannerView
prebidBannerView.delegate = self
prebidBannerView.adFormat = .banner
prebidBannerView.videoParameters.placement = .InBanner

// Add Prebid banner view to the app UI
bannerView.addSubview(prebidBannerView)

// 5. Load the banner ad
// 4. Load the banner ad
prebidBannerView.loadAd()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,37 @@ import PrebidMobile

fileprivate let storedImpDisplayInterstitial = "prebid-demo-display-interstitial-320-480-custom-interstitial-renderer"

class InAppDisplayInterstitialPluginInterstitialViewController:
class InAppDisplayInterstitialPluginRendererViewController:
UIViewController,
InterstitialAdUnitDelegate {

// Prebid
private var renderingInterstitial: InterstitialRenderingAdUnit!
private let samplePluginRenderer = SampleInterstitialRenderer()

override func loadView() {
super.loadView()

createAd()
}

deinit {
// Unregister plugin when you no longer needed
Prebid.unregisterPluginRenderer(samplePluginRenderer)
}

func createAd() {
// 1. Create a plugin renderer
let samplePluginRenderer = SampleInterstitialRenderer()

// 2. Register the plugin renderer
// 1. Register the plugin renderer
Prebid.registerPluginRenderer(samplePluginRenderer)

// 3. Create a InterstitialRenderingAdUnit
// 2. Create a InterstitialRenderingAdUnit
renderingInterstitial = InterstitialRenderingAdUnit(configID: storedImpDisplayInterstitial)

// 4. Configure the InterstitialRenderingAdUnit
// 3. Configure the InterstitialRenderingAdUnit
renderingInterstitial.adFormats = [.banner]
renderingInterstitial.delegate = self

// 5. Load the interstitial ad
// 4. Load the interstitial ad
renderingInterstitial.loadAd()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct IntegrationCaseManager {
integrationKind: .inApp,
adFormat: .displayInterstitial,
configurationClosure: {
InAppDisplayInterstitialPluginInterstitialViewController()
InAppDisplayInterstitialPluginRendererViewController()
}
),

Expand Down

0 comments on commit f5f4fc1

Please sign in to comment.