-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IOS-6797] Support in-feed Placement #17
Changes from 9 commits
d5d1f77
1475488
6f54398
2c814a1
ce03586
954f58c
c3afe40
a1aac8f
b00540b
d505852
cdbcfef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
#import "ALVungleMediationAdapter.h" | ||
#import <VungleAdsSDK/VungleAdsSDK.h> | ||
|
||
#define ADAPTER_VERSION @"7.3.1.0" | ||
#define ADAPTER_VERSION @"7.4.0.0" | ||
|
||
@interface ALVungleMediationAdapterInterstitialAdDelegate : NSObject <VungleInterstitialDelegate> | ||
@property (nonatomic, weak) ALVungleMediationAdapter *parentAdapter; | ||
|
@@ -30,11 +30,12 @@ @interface ALVungleMediationAdapterRewardedAdDelegate : NSObject <VungleRewarded | |
- (instancetype)initWithParentAdapter:(ALVungleMediationAdapter *)parentAdapter andNotify:(id<MARewardedAdapterDelegate>)delegate; | ||
@end | ||
|
||
@interface ALVungleMediationAdapterAdViewDelegate : NSObject <VungleBannerDelegate> | ||
@interface ALVungleMediationAdapterAdViewDelegate : NSObject <VungleBannerViewDelegate> | ||
@property (nonatomic, weak) ALVungleMediationAdapter *parentAdapter; | ||
@property (nonatomic, strong) MAAdFormat *adFormat; | ||
@property (nonatomic, strong) id<MAAdapterResponseParameters> parameters; | ||
@property (nonatomic, strong) id<MAAdViewAdapterDelegate> delegate; | ||
@property (nonatomic, assign) BOOL isAdloadSuccess; | ||
- (instancetype)initWithParentAdapter:(ALVungleMediationAdapter *)parentAdapter | ||
format:(MAAdFormat *)adFormat | ||
parameters:(id<MAAdapterResponseParameters>)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 | ||
|
@@ -173,7 +173,6 @@ - (void)destroy | |
self.adView.delegate = nil; | ||
self.adView = nil; | ||
self.adViewDelegate = nil; | ||
self.adViewContainer = nil; | ||
|
||
[self.nativeAd unregisterView]; | ||
self.nativeAd.delegate = nil; | ||
|
@@ -402,17 +401,14 @@ - (void)loadAdViewAdForParameters:(id<MAAdapterResponseParameters>)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]; | ||
} | ||
} | ||
|
@@ -518,24 +514,32 @@ - (void)loadVungleNativeAdForParameters:(id<MAAdapterResponseParameters>)paramet | |
return clickableViews; | ||
} | ||
|
||
- (BannerSize)adSizeFromAdFormat:(MAAdFormat *)adFormat | ||
- (VungleAdSize *)adSizeFromAdFormat:(MAAdFormat *)adFormat | ||
parameters:(id<MAAdapterParameters>)parameters | ||
{ | ||
if ( adFormat == MAAdFormat.banner ) | ||
BOOL isAdaptiveBanner = [parameters.localExtraParameters al_boolForKey: @"adaptive_banner"]; | ||
NSNumber *customWidth = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_width"] ? : 0; | ||
NSNumber *customHight = [parameters.localExtraParameters al_numberForKey: @"adaptive_banner_height"] ? : 0; | ||
|
||
if (!isAdaptiveBanner && customWidth && customWidth) { | ||
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]; | ||
} | ||
} | ||
|
||
|
@@ -889,84 +893,92 @@ - (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; | ||
[self.parentAdapter log: @"AdView loaded: %@", bannerView.placementId]; | ||
|
||
self.isAdloadSuccess = YES; | ||
NSMutableDictionary *extraInfo = [NSMutableDictionary dictionaryWithCapacity: 3]; | ||
BOOL isExtraInfo = NO; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think MAX will comment on this. Check for ALSdk.versionCode >= 6150000 for if else. Thanks @ashinagawa There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
NSString *creativeIdentifier = bannerView.creativeId; | ||
if ( [creativeIdentifier al_isValidString] ) | ||
{ | ||
[self.delegate didLoadAdForAdView: self.parentAdapter.adViewContainer withExtraInfo: @{@"creative_id" : creativeIdentifier}]; | ||
extraInfo[@"creative_id"] = creativeIdentifier; | ||
isExtraInfo = YES; | ||
} | ||
else | ||
|
||
CGSize adSize = [bannerView getBannerSize]; | ||
if ( !CGSizeEqualToSize(CGSizeZero, adSize) ) | ||
{ | ||
[self.delegate didLoadAdForAdView: self.parentAdapter.adViewContainer]; | ||
ashinagawa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extraInfo[@"ad_width"] = @(adSize.width); | ||
extraInfo[@"ad_height"] = @(adSize.height); | ||
ashinagawa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
isExtraInfo = YES; | ||
} | ||
|
||
if ( [banner canPlayAd] ) | ||
{ | ||
[banner presentOn: self.parentAdapter.adViewContainer]; | ||
} | ||
else | ||
{ | ||
[self.parentAdapter log: @"Failed to load ad view ad: ad not ready"]; | ||
[self.delegate didFailToLoadAdViewAdWithError: MAAdapterError.adNotReady]; | ||
if (isExtraInfo) { | ||
[self.delegate performSelector: @selector(didLoadAdForAdView:withExtraInfo:) | ||
withObject: bannerView | ||
withObject: extraInfo]; | ||
} else { | ||
[self.delegate didLoadAdForAdView: bannerView]; | ||
} | ||
} | ||
|
||
- (void)bannerAdDidFailToLoad:(VungleBanner *)banner withError:(NSError *)error | ||
- (void)bannerAdDidFail:(VungleBannerView *)bannerView withError:(NSError *)error | ||
{ | ||
MAAdapterError *adapterError = [ALVungleMediationAdapter toMaxError: error isAdPresentError: NO]; | ||
[self.parentAdapter log: @"AdView failed to load with error: %@", adapterError]; | ||
[self.delegate didFailToLoadAdViewAdWithError: adapterError]; | ||
if ( self.isAdloadSuccess ) | ||
{ | ||
[self.parentAdapter log: @"AdView failed to display with error: %@", adapterError]; | ||
[self.delegate didFailToDisplayAdViewAdWithError: adapterError]; | ||
} | ||
else | ||
{ | ||
[self.parentAdapter log: @"AdView failed to load with error: %@", adapterError]; | ||
[self.delegate didFailToLoadAdViewAdWithError: adapterError]; | ||
} | ||
} | ||
|
||
- (void)bannerAdWillPresent:(VungleBanner *)banner | ||
- (void)bannerAdWillPresent:(VungleBannerView *)bannerView | ||
{ | ||
[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 | ||
{ | ||
[self.parentAdapter log: @"AdView ad will leave application %@", banner.placementId]; | ||
} | ||
|
||
- (void)bannerAdDidFailToPresent:(VungleBanner *)banner withError:(NSError *)error | ||
- (void)bannerAdWillLeaveApplication:(VungleBannerView *)bannerView | ||
{ | ||
MAAdapterError *adapterError = [ALVungleMediationAdapter toMaxError: error isAdPresentError: YES]; | ||
[self.parentAdapter log: @"AdView ad failed to present with error: %@", adapterError]; | ||
[self.delegate didFailToDisplayAdViewAdWithError: adapterError]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will not notify any ad presenting error to the mediation, right? or Might we move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The callback method here has been changed from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, it's taken care at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. u need to move this logic into bannerAdDidFail: callback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have below in
Do you know if we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its based on present error or load error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
[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]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the toMaxError line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The callback method here has been changed from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, it's taken care at |
||
} | ||
|
||
- (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]; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can u move the line 521 and 522 inside here. and since u ave a default value as 0 which our sdk support u dont need to check customWidth && customWidth in if block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Thanks!
Updated.