Skip to content

Commit

Permalink
Chartboost/9.7.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AppLovin-Mobile-Engineering committed Aug 19, 2024
1 parent 7573c9e commit 1272478
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Chartboost/AppLovinMediationChartboostAdapter.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 = 'AppLovinMediationChartboostAdapter'
s.version = '9.7.0.0'
s.version = '9.7.0.1'
s.platform = :ios, '11.0'
s.summary = 'Chartboost 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
8 changes: 8 additions & 0 deletions Chartboost/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 9.7.0.1
* Add bidding support for banners, leaders, MRECs, interstitial and rewarded ads.
* Add COPPA support.
* Updated minimum Xcode requirement to 15.0.
* Remove deprecated callbacks `didStartRewardedAdVideo` and `didCompleteRewardedAdVideo`.
* Update error code mapping.
* Remove deprecated API usages.

## 9.7.0.0
* Certified with Chartboost SDK 9.7.0.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

#import <AppLovinSDK/AppLovinSDK.h>

@interface ALChartboostMediationAdapter : ALMediationAdapter <MAInterstitialAdapter, MARewardedAdapter, MAAdViewAdapter>
@interface ALChartboostMediationAdapter : ALMediationAdapter <MASignalProvider, MAInterstitialAdapter, MARewardedAdapter, MAAdViewAdapter>

@end
70 changes: 54 additions & 16 deletions Chartboost/ChartboostAdapter/ALChartboostMediationAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "ALChartboostMediationAdapter.h"
#import <ChartboostSDK/ChartboostSDK.h>

#define ADAPTER_VERSION @"9.7.0.0"
#define ADAPTER_VERSION @"9.7.0.1"

@interface ALChartboostInterstitialDelegate : NSObject <CHBInterstitialDelegate>
@property (nonatomic, weak) ALChartboostMediationAdapter *parentAdapter;
Expand Down Expand Up @@ -134,21 +134,39 @@ - (void)destroy
self.adViewDelegate = nil;
}

#pragma mark - MASignalProvider Methods

- (void)collectSignalWithParameters:(id<MASignalCollectionParameters>)parameters andNotify:(id<MASignalCollectionDelegate>)delegate
{
[self log: @"Collecting signal..."];

NSString *signal = [Chartboost bidderToken];
[delegate didCollectSignal: signal];
}

#pragma mark - MAInterstitialAdapter Methods

- (void)loadInterstitialAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAInterstitialAdapterDelegate>)delegate
{
// Determine placement
NSString *location = [self locationFromParameters: parameters];

[self log: @"Loading interstitial ad for location \"%@\"...", location];
NSString *bidResponse = parameters.bidResponse;
BOOL isBidding = [bidResponse al_isValidString];
[self log: @"Loading %@interstitial ad for location \"%@\"...", isBidding ? @"bidding " : @"", location];

[self updateUserConsentForParameters: parameters];

self.interstitialDelegate = [[ALChartboostInterstitialDelegate alloc] initWithParentAdapter: self andNotify: delegate];
self.interstitialAd = [[CHBInterstitial alloc] initWithLocation: location mediation: self.mediationInfo delegate: self.interstitialDelegate];

[self.interstitialAd cache];
if ( isBidding )
{
[self.interstitialAd cacheBidResponse: bidResponse];
}
else
{
[self.interstitialAd cache];
}
}

- (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAInterstitialAdapterDelegate>)delegate
Expand Down Expand Up @@ -188,14 +206,23 @@ - (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)paramet
- (void)loadRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate
{
NSString *location = [self locationFromParameters: parameters];
[self log: @"Loading rewarded ad for location \"%@\"...", location];
NSString *bidResponse = parameters.bidResponse;
BOOL isBidding = [bidResponse al_isValidString];
[self log: @"Loading %@rewarded ad for location \"%@\"...", isBidding ? @"bidding " : @"", location];

[self updateUserConsentForParameters: parameters];

self.rewardedDelegate = [[ALChartboostRewardedDelegate alloc] initWithParentAdapter: self andNotify: delegate];
self.rewardedAd = [[CHBRewarded alloc] initWithLocation: location mediation: self.mediationInfo delegate: self.rewardedDelegate];

[self.rewardedAd cache];
if ( isBidding )
{
[self.rewardedAd cacheBidResponse: bidResponse];
}
else
{
[self.rewardedAd cache];
}
}

- (void)showRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate
Expand Down Expand Up @@ -240,7 +267,9 @@ - (void)loadAdViewAdForParameters:(id<MAAdapterResponseParameters>)parameters
andNotify:(id<MAAdViewAdapterDelegate>)delegate
{
NSString *location = [self locationFromParameters: parameters];
[self log: @"Loading %@ ad for location \"%@\"...", adFormat.label, location];
NSString *bidResponse = parameters.bidResponse;
BOOL isBidding = [bidResponse al_isValidString];
[self log: @"Loading %@%@ ad for location \"%@\"...", isBidding ? @"bidding " : @"", adFormat.label, location];

[self updateUserConsentForParameters: parameters];

Expand All @@ -250,7 +279,14 @@ - (void)loadAdViewAdForParameters:(id<MAAdapterResponseParameters>)parameters
mediation: self.mediationInfo
delegate: self.adViewDelegate];

[self.adView cache];
if ( isBidding )
{
[self.adView cacheBidResponse: bidResponse];
}
else
{
[self.adView cache];
}
}

#pragma mark - GDPR
Expand All @@ -270,6 +306,12 @@ - (void)updateUserConsentForParameters:(id<MAAdapterParameters>)parameters
CHBCCPAConsent ccpaConsent = isDoNotSell.boolValue ? CHBCCPAConsentOptOutSale : CHBCCPAConsentOptInSale;
[Chartboost addDataUseConsent: [CHBCCPADataUseConsent ccpaConsent: ccpaConsent]];
}

NSNumber *isAgeRestrictedUser = [parameters isAgeRestrictedUser];
if ( isAgeRestrictedUser != nil )
{
[Chartboost addDataUseConsent: [CHBCOPPADataUseConsent isChildDirected: isAgeRestrictedUser.boolValue]];
}
}

#pragma mark - Helper Methods
Expand Down Expand Up @@ -333,6 +375,7 @@ - (MAAdapterError *)toMaxErrorFromCHBShowError:(CHBShowError *)chartBoostShowErr
{
case CHBShowErrorCodeInternalError:
case CHBShowErrorCodePresentationFailure:
case CHBShowErrorCodeAssetsFailure:
adapterError = MAAdapterError.internalError;
break;
case CHBShowErrorCodeSessionNotStarted:
Expand All @@ -347,6 +390,9 @@ - (MAAdapterError *)toMaxErrorFromCHBShowError:(CHBShowError *)chartBoostShowErr
case CHBShowErrorCodeNoViewController:
adapterError = MAAdapterError.missingViewController;
break;
case CHBShowErrorCodeNoAdInstance:
adapterError = MAAdapterError.invalidConfiguration;
break;
}

#pragma clang diagnostic push
Expand Down Expand Up @@ -548,8 +594,6 @@ - (void)didShowAd:(CHBShowEvent *)event error:(CHBShowError *)error
else
{
[self.parentAdapter log: @"Rewarded shown: %@", event.ad.location];

[self.delegate didStartRewardedAdVideo];
}
}

Expand Down Expand Up @@ -585,7 +629,6 @@ - (void)didClickAd:(CHBClickEvent *)event error:(CHBClickError *)error
- (void)didEarnReward:(CHBRewardEvent *)event
{
[self.parentAdapter log: @"Rewarded complete \"%@\" with reward: %d", event.ad.location, event.reward];
[self.delegate didCompleteRewardedAdVideo];

self.grantedReward = YES;
}
Expand Down Expand Up @@ -709,9 +752,4 @@ - (void)didClickAd:(CHBClickEvent *)event error:(CHBClickError *)error
}
}

- (void)didFinishHandlingClick:(CHBClickEvent *)event error:(CHBClickError *)error
{
[self.parentAdapter log: @"%@ ad did finish handling click: %@", self.adFormat.label, event.ad.location];
}

@end

0 comments on commit 1272478

Please sign in to comment.