Skip to content

Commit

Permalink
PubMatic/4.2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AppLovin-Mobile-Engineering committed Dec 4, 2024
1 parent 7bc887c commit 8eb3258
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 70 deletions.
2 changes: 1 addition & 1 deletion PubMatic/AppLovinMediationPubMaticAdapter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|

s.authors = 'AppLovin Corporation'
s.name = 'AppLovinMediationPubMaticAdapter'
s.version = '4.2.0.0'
s.version = '4.2.0.1'
s.platform = :ios, '12.0'
s.summary = 'PubMatic adapter used for mediation with the AppLovin MAX SDK'
s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed"
Expand Down
3 changes: 3 additions & 0 deletions PubMatic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 4.2.0.1
* Updated to use bidding specific APIs.

## 4.2.0.0
* Certified with PubMatic SDK 4.2.0.
* Removed redundant log output when initialization was already completed.
Expand Down
80 changes: 11 additions & 69 deletions PubMatic/PubMaticAdapter/ALPubMaticMediationAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "ALPubMaticMediationAdapter.h"
#import <OpenWrapSDK/OpenWrapSDK.h>

#define ADAPTER_VERSION @"4.2.0.0"
#define ADAPTER_VERSION @"4.2.0.1"

@interface ALPubMaticMediationAdapterInterstitialDelegate : NSObject <POBInterstitialDelegate>
@property (nonatomic, weak) ALPubMaticMediationAdapter *parentAdapter;
Expand Down Expand Up @@ -66,8 +66,8 @@ - (void)initializeWithParameters:(id<MAAdapterInitializationParameters>)paramete
{
ALPubMaticInitializationStatus = MAAdapterInitializationStatusInitializing;

NSString *publisherId = [self publisherIdFromParameters: parameters];
NSNumber *profileId = [self profileIdFromParameters: parameters];
NSString *publisherId = [parameters.serverParameters al_stringForKey: @"publisher_id"];
NSNumber *profileId = [parameters.serverParameters al_numberForKey: @"profile_id"];

OpenWrapSDKConfig *config = [[OpenWrapSDKConfig alloc] initWithPublisherId: publisherId andProfileIds: @[profileId]];

Expand Down Expand Up @@ -149,26 +149,19 @@ - (void)collectSignalWithParameters:(id<MASignalCollectionParameters>)parameters

- (void)loadInterstitialAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAInterstitialAdapterDelegate>)delegate
{
NSString *publisherId = [self publisherIdFromParameters: parameters];
NSNumber *profileId = [self profileIdFromParameters: parameters];
NSString *adUnitId = [self adUnitIdFromParameters: parameters];

[self log: @"Loading interstitial ad: %@...", adUnitId];
[self log: @"Loading interstitial ad"];

self.interstitialAdDelegate = [[ALPubMaticMediationAdapterInterstitialDelegate alloc] initWithParentAdapter: self
andNotify: delegate];
self.interstitialAd = [[POBInterstitial alloc] initWithPublisherId: publisherId
profileId: profileId
adUnitId: adUnitId];
self.interstitialAd = [[POBInterstitial alloc] init];
self.interstitialAd.delegate = self.interstitialAdDelegate;

[self.interstitialAd loadAdWithResponse: parameters.bidResponse];
}

- (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAInterstitialAdapterDelegate>)delegate
{
NSString *adUnitId = [self adUnitIdFromParameters: parameters];
[self log: @"Showing interstitial ad: %@...", adUnitId];
[self log: @"Showing interstitial ad"];

if ( ![self.interstitialAd isReady] )
{
Expand All @@ -187,26 +180,19 @@ - (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)paramet

- (void)loadRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate
{
NSString *publisherId = [self publisherIdFromParameters: parameters];
NSNumber *profileId = [self profileIdFromParameters: parameters];
NSString *adUnitId = [self adUnitIdFromParameters: parameters];

[self log: @"Loading rewarded ad: %@...", adUnitId];
[self log: @"Loading rewarded ad"];

self.rewardedAdDelegate = [[ALPubMaticMediationAdapterRewardedDelegate alloc] initWithParentAdapter: self
andNotify: delegate];
self.rewardedAd = [POBRewardedAd rewardedAdWithPublisherId: publisherId
profileId: profileId
adUnitId: adUnitId];
self.rewardedAd = [[POBRewardedAd alloc] init];
self.rewardedAd.delegate = self.rewardedAdDelegate;

[self.rewardedAd loadAdWithResponse: parameters.bidResponse];
}

- (void)showRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate
{
NSString *adUnitId = [self adUnitIdFromParameters: parameters];
[self log: @"Showing rewarded ad: %@...", adUnitId];
[self log: @"Showing rewarded ad"];

if ( ![self.rewardedAd isReady] )
{
Expand All @@ -229,20 +215,12 @@ - (void)loadAdViewAdForParameters:(id<MAAdapterResponseParameters>)parameters
adFormat:(MAAdFormat *)adFormat
andNotify:(id<MAAdViewAdapterDelegate>)delegate
{
NSString *publisherId = [self publisherIdFromParameters: parameters];
NSNumber *profileId = [self profileIdFromParameters: parameters];
NSString *adUnitId = [self adUnitIdFromParameters: parameters];
POBAdSize *adSize = [self POBAdSizeFromAdFormat: adFormat];

[self log: @"Loading %@ ad: %@...", adFormat.label, adUnitId];
[self log: @"Loading %@ ad", adFormat.label];

self.adViewDelegate = [[ALPubMaticMediationAdapterAdViewDelegate alloc] initWithParentAdapter: self
format: adFormat
andNotify: delegate];
self.adView = [[POBBannerView alloc] initWithPublisherId: publisherId
profileId: profileId
adUnitId: adUnitId
adSizes: @[adSize]];
self.adView = [[POBBannerView alloc] init];
self.adView.delegate = self.adViewDelegate;

[self.adView loadAdWithResponse: parameters.bidResponse];
Expand All @@ -251,42 +229,6 @@ - (void)loadAdViewAdForParameters:(id<MAAdapterResponseParameters>)parameters

#pragma mark - Shared Methods

- (NSString *)publisherIdFromParameters:(id<MAAdapterParameters>)parameters
{
return [parameters.serverParameters al_stringForKey: @"publisher_id"];
}

- (NSNumber *)profileIdFromParameters:(id<MAAdapterParameters>)parameters
{
return [parameters.serverParameters al_numberForKey: @"profile_id"];
}

- (NSString *)adUnitIdFromParameters:(id<MAAdapterResponseParameters>)parameters
{
return parameters.thirdPartyAdPlacementIdentifier;
}

- (POBAdSize *)POBAdSizeFromAdFormat:(MAAdFormat *)adFormat
{
if ( adFormat == MAAdFormat.banner )
{
return POBBannerAdSize320x50;
}
else if ( adFormat == MAAdFormat.leader )
{
return POBBannerAdSize768x90;
}
else if ( adFormat == MAAdFormat.mrec )
{
return POBBannerAdSize300x250;
}
else
{
[NSException raise: NSInvalidArgumentException format: @"Invalid ad format: %@", adFormat];
return POBBannerAdSize320x50;
}
}

- (POBAdFormat)POBAdFormatFromAdFormat:(MAAdFormat *)adFormat
{
if ( adFormat == MAAdFormat.banner )
Expand Down

0 comments on commit 8eb3258

Please sign in to comment.