diff --git a/Vungle/AppLovinMediationVungleAdapter.podspec b/Vungle/AppLovinMediationVungleAdapter.podspec index cd07ee7595..50fb990733 100644 --- a/Vungle/AppLovinMediationVungleAdapter.podspec +++ b/Vungle/AppLovinMediationVungleAdapter.podspec @@ -5,7 +5,7 @@ s.authors = 'AppLovin Corporation' => 'devsupport@applovin.com' } 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" diff --git a/Vungle/CHANGELOG.md b/Vungle/CHANGELOG.md index f7c31fd9d0..bac7b6f60d 100644 --- a/Vungle/CHANGELOG.md +++ b/Vungle/CHANGELOG.md @@ -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. diff --git a/Vungle/VungleAdapter/ALVungleMediationAdapter.h b/Vungle/VungleAdapter/ALVungleMediationAdapter.h index 171176f17a..dfaf545aff 100644 --- a/Vungle/VungleAdapter/ALVungleMediationAdapter.h +++ b/Vungle/VungleAdapter/ALVungleMediationAdapter.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface ALVungleMediationAdapter : ALMediationAdapter +@interface ALVungleMediationAdapter : ALMediationAdapter @end diff --git a/Vungle/VungleAdapter/ALVungleMediationAdapter.m b/Vungle/VungleAdapter/ALVungleMediationAdapter.m index fdf5d57381..caf9134f47 100644 --- a/Vungle/VungleAdapter/ALVungleMediationAdapter.m +++ b/Vungle/VungleAdapter/ALVungleMediationAdapter.m @@ -11,7 +11,21 @@ #import #import -#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 +- (void)didLoadAppOpenAd; +- (void)didLoadAppOpenAdWithExtraInfo:(nullable NSDictionary *)extraInfo; +- (void)didFailToLoadAppOpenAdWithError:(MAAdapterError *)adapterError; +- (void)didDisplayAppOpenAd; +- (void)didDisplayAppOpenAdWithExtraInfo:(nullable NSDictionary *)extraInfo; +- (void)didClickAppOpenAd; +- (void)didClickAppOpenAdWithExtraInfo:(nullable NSDictionary *)extraInfo; +- (void)didHideAppOpenAd; +- (void)didHideAppOpenAdWithExtraInfo:(nullable NSDictionary *)extraInfo; +- (void)didFailToDisplayAppOpenAdWithError:(MAAdapterError *)adapterError; +@end @interface ALVungleMediationAdapterRouter : ALMediationAdapterRouter @property (nonatomic, copy, nullable) void(^oldCompletionHandler)(void); @@ -77,7 +91,7 @@ - (void)initializeWithParameters:(id)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; @@ -240,6 +254,97 @@ - (void)showInterstitialAdForParameters:(id)paramet } } +#pragma mark - MAAppOpenAdapter Methods + +- (void)loadAppOpenAdForParameters:(id)parameters andNotify:(id)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)parameters andNotify:(id)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)parameters andNotify:(id)delegate @@ -485,7 +590,7 @@ - (void)loadNativeAdForParameters:(id)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 @@ -707,7 +812,7 @@ - (void)updateUserPrivacySettingsForParameters:(id)paramete { [[VungleSDK sharedSDK] updateCOPPAStatus: isAgeRestrictedUser.boolValue]; } - + if ( ALSdk.versionCode >= 61100 ) { NSNumber *isDoNotSell = [self privacySettingForSelector: @selector(isDoNotSell) fromParameters: parameters]; @@ -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 }]; @@ -1083,7 +1188,7 @@ - (void)prepareViewForInteraction:(MANativeAdView *)maxNativeAdView } } #pragma clang diagnostic pop - + [nativeAd registerViewForInteraction: maxNativeAdView mediaView: (VungleMediaView *) self.mediaView iconImageView: maxNativeAdView.iconImageView