Skip to content

Commit

Permalink
Vungle/6.12.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Sep 18, 2022
1 parent 1cead1c commit 6b929c3
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Vungle/AppLovinMediationVungleAdapter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ s.authors =
'AppLovin Corporation' => '[email protected]'
}
s.name = 'AppLovinMediationVungleAdapter'
s.version = '6.12.0.2'
s.version = '6.12.0.3'
s.platform = :ios, '10.0'
s.summary = 'Vungle 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 Vungle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 6.12.0.3
* Add support for app open ads.

## 6.12.0.2
* Add support for native ads. Note: Contact your Vungle team for access to native format.
* Update COPPA with other privacy settings instead of setting before Vungle SDK initialization.
Expand Down
2 changes: 1 addition & 1 deletion Vungle/VungleAdapter/ALVungleMediationAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface ALVungleMediationAdapter : ALMediationAdapter<MASignalProvider, MAInterstitialAdapter, MARewardedAdapter, MAAdViewAdapter, MANativeAdAdapter>
@interface ALVungleMediationAdapter : ALMediationAdapter<MASignalProvider, MAInterstitialAdapter, /* MAAppOpenAdapter */ MARewardedAdapter, MAAdViewAdapter, MANativeAdAdapter>

@end

Expand Down
125 changes: 115 additions & 10 deletions Vungle/VungleAdapter/ALVungleMediationAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,21 @@
#import <VungleSDK/VungleSDKCreativeTracking.h>
#import <VungleSDK/VungleSDK.h>

#define ADAPTER_VERSION @"6.12.0.2"
#define ADAPTER_VERSION @"6.12.0.3"

// TODO: Remove when SDK with App Open APIs is released
@protocol MAAppOpenAdapterDelegateTemp<MAAdapterDelegate>
- (void)didLoadAppOpenAd;
- (void)didLoadAppOpenAdWithExtraInfo:(nullable NSDictionary<NSString *, id> *)extraInfo;
- (void)didFailToLoadAppOpenAdWithError:(MAAdapterError *)adapterError;
- (void)didDisplayAppOpenAd;
- (void)didDisplayAppOpenAdWithExtraInfo:(nullable NSDictionary<NSString *, id> *)extraInfo;
- (void)didClickAppOpenAd;
- (void)didClickAppOpenAdWithExtraInfo:(nullable NSDictionary<NSString *, id> *)extraInfo;
- (void)didHideAppOpenAd;
- (void)didHideAppOpenAdWithExtraInfo:(nullable NSDictionary<NSString *, id> *)extraInfo;
- (void)didFailToDisplayAppOpenAdWithError:(MAAdapterError *)adapterError;
@end

@interface ALVungleMediationAdapterRouter : ALMediationAdapterRouter<VungleSDKDelegate, VungleSDKCreativeTracking, VungleSDKHBDelegate>
@property (nonatomic, copy, nullable) void(^oldCompletionHandler)(void);
Expand Down Expand Up @@ -77,7 +91,7 @@ - (void)initializeWithParameters:(id<MAAdapterInitializationParameters>)paramete

NSString *appID = [parameters.serverParameters al_stringForKey: @"app_id"];
[self log: @"Initializing Vungle SDK with app id: %@...", appID];

[VungleSDK sharedSDK].delegate = self.router;
[VungleSDK sharedSDK].creativeTrackingDelegate = self.router;
[VungleSDK sharedSDK].sdkHBDelegate = self.router;
Expand Down Expand Up @@ -240,6 +254,97 @@ - (void)showInterstitialAdForParameters:(id<MAAdapterResponseParameters>)paramet
}
}

#pragma mark - MAAppOpenAdapter Methods

- (void)loadAppOpenAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAAppOpenAdapterDelegateTemp>)delegate
{
NSString *bidResponse = parameters.bidResponse;
BOOL isBiddingAd = [bidResponse al_isValidString];
self.placementIdentifier = parameters.thirdPartyAdPlacementIdentifier;
[self log: @"Loading %@app open ad for placement: %@...", ( isBiddingAd ? @"bidding " : @"" ), self.placementIdentifier];

if ( ![[VungleSDK sharedSDK] isInitialized] )
{
[self log: @"Vungle SDK not successfully initialized: failing app open ad load..."];
[delegate didFailToLoadAppOpenAdWithError: MAAdapterError.notInitialized];

return;
}

[self.router addAppOpenAdapter: self
delegate: delegate
forPlacementIdentifier: self.placementIdentifier];

if ( isBiddingAd )
{
if ( [[VungleSDK sharedSDK] isAdCachedForPlacementID: self.placementIdentifier adMarkup: bidResponse] )
{
[self log: @"App open ad loaded"];
[delegate didLoadAppOpenAd];

return;
}
}
else if ( [[VungleSDK sharedSDK] isAdCachedForPlacementID: self.placementIdentifier] )
{
[self log: @"App open ad loaded"];
[delegate didLoadAppOpenAd];

return;
}

NSError *error;
BOOL isLoaded = [self loadAdForParameters: parameters
adFormat: nil // MAAdFormat.appOpen
error: &error];

// The `error` parameter may be populated with a return value of `true`
if ( !isLoaded || error )
{
MAAdapterError *adapterError = [ALVungleMediationAdapter toMaxError: error];
[self log: @"App open failed to load with error: %@", adapterError];
[delegate didFailToDisplayAppOpenAdWithError: adapterError];
}
}

- (void)showAppOpenAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MAAppOpenAdapterDelegateTemp>)delegate
{
NSString *bidResponse = parameters.bidResponse;
BOOL isBiddingAd = [bidResponse al_isValidString];
NSString *placementIdentifier = parameters.thirdPartyAdPlacementIdentifier;
[self log: @"Showing %@app open ad for placement: %@...", ( isBiddingAd ? @"bidding " : @"" ), placementIdentifier];

[self.router addShowingAdapter: self];

NSError *error;
BOOL willShow = NO;
if ( isBiddingAd )
{
if ( [[VungleSDK sharedSDK] isAdCachedForPlacementID: placementIdentifier adMarkup: bidResponse] )
{
willShow = [self showFullscreenAdForParameters: parameters error: &error];
}
}
else if ( [[VungleSDK sharedSDK] isAdCachedForPlacementID: placementIdentifier] )
{
willShow = [self showFullscreenAdForParameters: parameters error: &error];
}

if ( !willShow || error )
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
MAAdapterError *adapterError = [MAAdapterError errorWithCode: -4205
errorString: @"Ad Display Failed"
thirdPartySdkErrorCode: error.code
thirdPartySdkErrorMessage: error.localizedDescription];
#pragma clang diagnostic pop

[self log: @"App open ad failed to display with error: %@", adapterError];
[self.router didFailToDisplayAdForPlacementIdentifier: placementIdentifier error: adapterError];
}
}

#pragma mark - MARewardedAdapter Methods

- (void)loadRewardedAdForParameters:(id<MAAdapterResponseParameters>)parameters andNotify:(id<MARewardedAdapterDelegate>)delegate
Expand Down Expand Up @@ -485,7 +590,7 @@ - (void)loadNativeAdForParameters:(id<MAAdapterResponseParameters>)parameters an
[self log: @"Loading %@native ad for placement: %@...", ( isBiddingAd ? @"bidding " : @"" ), self.placementIdentifier];

[self.router updateUserPrivacySettingsForParameters: parameters consentDialogState: self.sdk.configuration.consentDialogState];

self.nativeAd = [[VungleNativeAd alloc] initWithPlacementID: self.placementIdentifier];
self.nativeAdDelegate = [[ALVungleMediationAdapterNativeAdDelegate alloc] initWithParentAdapter: self
parameters: parameters
Expand Down Expand Up @@ -707,7 +812,7 @@ - (void)updateUserPrivacySettingsForParameters:(id<MAAdapterParameters>)paramete
{
[[VungleSDK sharedSDK] updateCOPPAStatus: isAgeRestrictedUser.boolValue];
}

if ( ALSdk.versionCode >= 61100 )
{
NSNumber *isDoNotSell = [self privacySettingForSelector: @selector(isDoNotSell) fromParameters: parameters];
Expand Down Expand Up @@ -994,11 +1099,11 @@ - (void)nativeAdDidLoad:(VungleNativeAd *)nativeAd

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
// Introduced in 10.4.0
if ( [builder respondsToSelector: @selector(setAdvertiser:)] )
{
[builder performSelector: @selector(setAdvertiser:) withObject: nativeAd.sponsoredText];
}
// Introduced in 10.4.0
if ( [builder respondsToSelector: @selector(setAdvertiser:)] )
{
[builder performSelector: @selector(setAdvertiser:) withObject: nativeAd.sponsoredText];
}
#pragma clang diagnostic pop
}];

Expand Down Expand Up @@ -1083,7 +1188,7 @@ - (void)prepareViewForInteraction:(MANativeAdView *)maxNativeAdView
}
}
#pragma clang diagnostic pop

[nativeAd registerViewForInteraction: maxNativeAdView
mediaView: (VungleMediaView *) self.mediaView
iconImageView: maxNativeAdView.iconImageView
Expand Down

0 comments on commit 6b929c3

Please sign in to comment.