From 98ccf2fe88ecad23d8ec09b1d3d609ec1bc485bf Mon Sep 17 00:00:00 2001 From: crbinsf Date: Thu, 25 Apr 2024 11:46:47 -0700 Subject: [PATCH 1/4] [IOS-6733] Introduces support for media aspect ratio (#14) Adds support for media content aspect ratio. This commit will retrieve the aspect ratio of the media to be presented from the native ad, and then set it as required so that publishers will have access to this data. IOS-6733 --- .../VungleAdapter/ALVungleMediationAdapter.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Vungle/VungleAdapter/ALVungleMediationAdapter.m b/Vungle/VungleAdapter/ALVungleMediationAdapter.m index 3e17e9aa5b..f39bd55642 100644 --- a/Vungle/VungleAdapter/ALVungleMediationAdapter.m +++ b/Vungle/VungleAdapter/ALVungleMediationAdapter.m @@ -1018,6 +1018,9 @@ - (void)nativeAdDidLoad:(VungleNative *)nativeAd [self.parentAdapter log: @"Native %@ ad loaded: %@", self.adFormat, self.placementIdentifier]; + // returns aspect ratio of media to be displayed. Will return 0.0 by default + CGFloat mediaContentAspectRatio = [nativeAd getMediaAspectRatio]; + dispatchOnMainQueue(^{ MediaView *mediaView = [[MediaView alloc] init]; @@ -1035,6 +1038,12 @@ - (void)nativeAdDidLoad:(VungleNative *)nativeAd { [builder performSelector: @selector(setAdvertiser:) withObject: nativeAd.sponsoredText]; } + // Introduced in 11.4.0 + if ( [builder respondsToSelector: @selector(setMediaContentAspectRatio:)] ) + { + [builder performSelector: @selector(setMediaContentAspectRatio:) withObject: @(mediaContentAspectRatio)]; + } + #pragma clang diagnostic pop }]; @@ -1132,6 +1141,9 @@ - (void)nativeAdDidLoad:(VungleNative *)nativeAd [self.parentAdapter log: @"Native ad loaded: %@", self.placementIdentifier]; + // returns aspect ratio of media to be displayed. Will return 0.0 by default + CGFloat mediaContentAspectRatio = [nativeAd getMediaAspectRatio]; + dispatchOnMainQueue(^{ MediaView *mediaView = [[MediaView alloc] init]; @@ -1149,6 +1161,12 @@ - (void)nativeAdDidLoad:(VungleNative *)nativeAd { [builder performSelector: @selector(setAdvertiser:) withObject: nativeAd.sponsoredText]; } + + // Introduced in 11.4.0 + if ( [builder respondsToSelector: @selector(setMediaContentAspectRatio:)] ) + { + [builder performSelector: @selector(setMediaContentAspectRatio:) withObject: @(mediaContentAspectRatio)]; + } #pragma clang diagnostic pop }]; From 17be181eee5bcf0183855842504877243f86cb27 Mon Sep 17 00:00:00 2001 From: Aki Shinagawa Date: Tue, 30 Jul 2024 12:48:38 -0700 Subject: [PATCH 2/4] [IOS-6797] Support in-feed Placement (#17) * Updated adapter to support in-feed placements --- .../VungleAdapter/ALVungleMediationAdapter.m | 130 ++++++++++-------- 1 file changed, 72 insertions(+), 58 deletions(-) diff --git a/Vungle/VungleAdapter/ALVungleMediationAdapter.m b/Vungle/VungleAdapter/ALVungleMediationAdapter.m index f39bd55642..ee73d7880c 100644 --- a/Vungle/VungleAdapter/ALVungleMediationAdapter.m +++ b/Vungle/VungleAdapter/ALVungleMediationAdapter.m @@ -30,11 +30,12 @@ @interface ALVungleMediationAdapterRewardedAdDelegate : NSObject )delegate; @end -@interface ALVungleMediationAdapterAdViewDelegate : NSObject +@interface ALVungleMediationAdapterAdViewDelegate : NSObject @property (nonatomic, weak) ALVungleMediationAdapter *parentAdapter; @property (nonatomic, strong) MAAdFormat *adFormat; @property (nonatomic, strong) id parameters; @property (nonatomic, strong) id delegate; +@property (nonatomic, assign) BOOL isAdloadSuccess; - (instancetype)initWithParentAdapter:(ALVungleMediationAdapter *)parentAdapter format:(MAAdFormat *)adFormat parameters:(id)parameters @@ -84,8 +85,7 @@ @interface ALVungleMediationAdapter () @property (nonatomic, strong) ALVungleMediationAdapterRewardedAdDelegate *rewardedAdDelegate; // AdView -@property (nonatomic, strong) VungleBanner *adView; -@property (nonatomic, strong) UIView *adViewContainer; +@property (nonatomic, strong) VungleBannerView *adView; @property (nonatomic, strong) ALVungleMediationAdapterAdViewDelegate *adViewDelegate; // Native Ad @@ -175,7 +175,6 @@ - (void)destroy self.adView.delegate = nil; self.adView = nil; self.adViewDelegate = nil; - self.adViewContainer = nil; [self.nativeAd unregisterView]; self.nativeAd.delegate = nil; @@ -404,17 +403,13 @@ - (void)loadAdViewAdForParameters:(id)parameters ad } else { - BannerSize adSize = [self adSizeFromAdFormat: adFormat]; - - self.adView = [[VungleBanner alloc] initWithPlacementId: placementIdentifier size: adSize]; + VungleAdSize *adSize = [self adSizeFromAdFormat: adFormat parameters:parameters]; + self.adView = [[VungleBannerView alloc] initWithPlacementId: placementIdentifier vungleAdSize: adSize]; self.adViewDelegate = [[ALVungleMediationAdapterAdViewDelegate alloc] initWithParentAdapter: self format: adFormat parameters: parameters andNotify: delegate]; self.adView.delegate = self.adViewDelegate; - - self.adViewContainer = [[UIView alloc] initWithFrame: (CGRect) { CGPointZero, adFormat.size }]; - [self.adView load: bidResponse]; } } @@ -525,24 +520,32 @@ - (void)loadVungleNativeAdForParameters:(id)paramet return clickableViews; } -- (BannerSize)adSizeFromAdFormat:(MAAdFormat *)adFormat +- (VungleAdSize *)adSizeFromAdFormat:(MAAdFormat *)adFormat + parameters:(id)parameters { - if ( adFormat == MAAdFormat.banner ) + BOOL isAdaptiveBanner = [parameters.localExtraParameters al_boolForKey: @"adaptive_banner"]; + NSNumber *customWidth = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_width"]; + NSNumber *customHight = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_height"]; + + if (!isAdaptiveBanner && customWidth && customHight) { + return [VungleAdSize VungleAdSizeFromCGSize:(CGSizeMake(customWidth.floatValue, customHight.floatValue))]; + } + else if ( adFormat == MAAdFormat.banner ) { - return BannerSizeRegular; + return [VungleAdSize VungleAdSizeBannerRegular]; } else if ( adFormat == MAAdFormat.leader ) { - return BannerSizeLeaderboard; + return [VungleAdSize VungleAdSizeLeaderboard]; } else if ( adFormat == MAAdFormat.mrec ) { - return BannerSizeMrec; + return [VungleAdSize VungleAdSizeMREC]; } else { [NSException raise: NSInvalidArgumentException format: @"Unsupported ad format: %@", adFormat]; - return BannerSizeRegular; + return [VungleAdSize VungleAdSizeBannerRegular]; } } @@ -896,84 +899,95 @@ - (instancetype)initWithParentAdapter:(ALVungleMediationAdapter *)parentAdapter self.adFormat = adFormat; self.parameters = parameters; self.delegate = delegate; + self.isAdloadSuccess = NO; } return self; } -- (void)bannerAdDidLoad:(VungleBanner *)banner +- (void)bannerAdDidLoad:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView loaded: %@", banner.placementId]; - - NSString *creativeIdentifier = banner.creativeId; - if ( [creativeIdentifier al_isValidString] ) + [self.parentAdapter log: @"AdView loaded: %@", bannerView.placementId]; + + self.isAdloadSuccess = YES; + + if ( ALSdk.versionCode >= 6150000 ) { - [self.delegate didLoadAdForAdView: self.parentAdapter.adViewContainer withExtraInfo: @{@"creative_id" : creativeIdentifier}]; + NSMutableDictionary *extraInfo = [NSMutableDictionary dictionaryWithCapacity: 3]; + + NSString *creativeIdentifier = bannerView.creativeId; + if ( [creativeIdentifier al_isValidString] ) + { + extraInfo[@"creative_id"] = creativeIdentifier; + + } + + CGSize adSize = [bannerView getBannerSize]; + if ( !CGSizeEqualToSize(CGSizeZero, adSize) ) + { + extraInfo[@"ad_width"] = @(adSize.width); + extraInfo[@"ad_height"] = @(adSize.height); + + } + + [self.delegate performSelector: @selector(didLoadAdForAdView:withExtraInfo:) + withObject: bannerView + withObject: extraInfo]; } - else - { - [self.delegate didLoadAdForAdView: self.parentAdapter.adViewContainer]; + else { + [self.delegate didLoadAdForAdView: bannerView]; } - - if ( [banner canPlayAd] ) +} + +- (void)bannerAdDidFail:(VungleBannerView *)bannerView withError:(NSError *)error +{ + MAAdapterError *adapterError = [ALVungleMediationAdapter toMaxError: error isAdPresentError: self.isAdloadSuccess]; + if ( self.isAdloadSuccess ) { - [banner presentOn: self.parentAdapter.adViewContainer]; + [self.parentAdapter log: @"AdView failed to display with error: %@", adapterError]; + [self.delegate didFailToDisplayAdViewAdWithError: adapterError]; } else { - [self.parentAdapter log: @"Failed to load ad view ad: ad not ready"]; - [self.delegate didFailToLoadAdViewAdWithError: MAAdapterError.adNotReady]; + [self.parentAdapter log: @"AdView failed to load with error: %@", adapterError]; + [self.delegate didFailToLoadAdViewAdWithError: adapterError]; } } -- (void)bannerAdDidFailToLoad:(VungleBanner *)banner withError:(NSError *)error +- (void)bannerAdWillPresent:(VungleBannerView *)bannerView { - MAAdapterError *adapterError = [ALVungleMediationAdapter toMaxError: error isAdPresentError: NO]; - [self.parentAdapter log: @"AdView failed to load with error: %@", adapterError]; - [self.delegate didFailToLoadAdViewAdWithError: adapterError]; -} - -- (void)bannerAdWillPresent:(VungleBanner *)banner -{ - [self.parentAdapter log: @"AdView ad will present %@", banner.placementId]; + [self.parentAdapter log: @"AdView ad will present %@", bannerView.placementId]; } -- (void)bannerAdDidPresent:(VungleBanner *)banner +- (void)bannerAdDidPresent:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView ad shown %@", banner.placementId]; + [self.parentAdapter log: @"AdView ad shown %@", bannerView.placementId]; } -- (void)bannerAdDidTrackImpression:(VungleBanner *)banner +- (void)bannerAdDidTrackImpression:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView ad impression tracked %@", banner.placementId]; + [self.parentAdapter log: @"AdView ad impression tracked %@", bannerView.placementId]; [self.delegate didDisplayAdViewAd]; } -- (void)bannerAdDidClick:(VungleBanner *)banner +- (void)bannerAdDidClick:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView ad clicked %@", banner.placementId]; + [self.parentAdapter log: @"AdView ad clicked %@", bannerView.placementId]; [self.delegate didClickAdViewAd]; } -- (void)bannerAdWillLeaveApplication:(VungleBanner *)banner +- (void)bannerAdWillLeaveApplication:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView ad will leave application %@", banner.placementId]; -} - -- (void)bannerAdDidFailToPresent:(VungleBanner *)banner withError:(NSError *)error -{ - MAAdapterError *adapterError = [ALVungleMediationAdapter toMaxError: error isAdPresentError: YES]; - [self.parentAdapter log: @"AdView ad failed to present with error: %@", adapterError]; - [self.delegate didFailToDisplayAdViewAdWithError: adapterError]; + [self.parentAdapter log: @"AdView ad will leave application %@", bannerView.placementId]; } -- (void)bannerAdWillClose:(VungleBanner *)banner +- (void)bannerAdWillClose:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView ad will close %@", banner.placementId]; + [self.parentAdapter log: @"AdView ad will close %@", bannerView.placementId]; } -- (void)bannerAdDidClose:(VungleBanner *)banner +- (void)bannerAdDidClose:(VungleBannerView *)bannerView { - [self.parentAdapter log: @"AdView ad hidden %@", banner.placementId]; + [self.parentAdapter log: @"AdView ad hidden %@", bannerView.placementId]; [self.delegate didHideAdViewAd]; } From 73d049e6fdc60af9967811cf94638805166489b0 Mon Sep 17 00:00:00 2001 From: Aki Shinagawa Date: Wed, 31 Jul 2024 12:53:37 -0700 Subject: [PATCH 3/4] Updated to support Adaptive case (#19) Updated to support Adaptive case and Custom case properly --- Vungle/VungleAdapter/ALVungleMediationAdapter.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Vungle/VungleAdapter/ALVungleMediationAdapter.m b/Vungle/VungleAdapter/ALVungleMediationAdapter.m index ee73d7880c..99f5849998 100644 --- a/Vungle/VungleAdapter/ALVungleMediationAdapter.m +++ b/Vungle/VungleAdapter/ALVungleMediationAdapter.m @@ -523,12 +523,14 @@ - (void)loadVungleNativeAdForParameters:(id)paramet - (VungleAdSize *)adSizeFromAdFormat:(MAAdFormat *)adFormat parameters:(id)parameters { - BOOL isAdaptiveBanner = [parameters.localExtraParameters al_boolForKey: @"adaptive_banner"]; - NSNumber *customWidth = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_width"]; - NSNumber *customHight = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_height"]; - - if (!isAdaptiveBanner && customWidth && customHight) { - return [VungleAdSize VungleAdSizeFromCGSize:(CGSizeMake(customWidth.floatValue, customHight.floatValue))]; + if ([parameters.localExtraParameters al_boolForKey: @"adaptive_banner"]) { + NSNumber *customWidth = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_width"]; + // Need to check `customHeight` to determine if the request is for Custom or Adaptive. + NSNumber *customHeight = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_height"]; + if (!customHeight) { + customHeight = 0; + } + return [VungleAdSize VungleAdSizeFromCGSize:(CGSizeMake(customWidth.floatValue, customHeight.floatValue))]; } else if ( adFormat == MAAdFormat.banner ) { From c06463688b067c45da5cebfd6b0fd2646a5666c5 Mon Sep 17 00:00:00 2001 From: ManojBudumuru-vungle <63756359+ManojBudumuru-vungle@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:48:13 -0700 Subject: [PATCH 4/4] ConfigLess Update. (#20) This commit will remove temp fix placed in adapter for init failure cases. IOS-7001 --- Vungle/VungleAdapter/ALVungleMediationAdapter.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Vungle/VungleAdapter/ALVungleMediationAdapter.m b/Vungle/VungleAdapter/ALVungleMediationAdapter.m index 99f5849998..ce57d16056 100644 --- a/Vungle/VungleAdapter/ALVungleMediationAdapter.m +++ b/Vungle/VungleAdapter/ALVungleMediationAdapter.m @@ -9,7 +9,7 @@ #import "ALVungleMediationAdapter.h" #import -#define ADAPTER_VERSION @"7.4.0.0" +#define ADAPTER_VERSION @"7.4.1.0" @interface ALVungleMediationAdapterInterstitialAdDelegate : NSObject @property (nonatomic, weak) ALVungleMediationAdapter *parentAdapter; @@ -124,8 +124,6 @@ - (void)initializeWithParameters:(id)paramete [VungleAds initWithAppId: appID completion:^(NSError * _Nullable error) { if ( error ) { - [ALVungleInitialized set: NO]; - [self log: @"Vungle SDK failed to initialize with error: %@", error]; ALVungleIntializationStatus = MAAdapterInitializationStatusInitializedFailure;