From 063a1ac4a9e691d7baa8452a4ef78e946c57ca3f Mon Sep 17 00:00:00 2001 From: AppLovin-Mobile-Engineering Date: Thu, 24 Oct 2024 12:04:37 -0700 Subject: [PATCH] OguryPresage/5.0.0.0 --- ...pLovinMediationOguryPresageAdapter.podspec | 6 +- OguryPresage/CHANGELOG.md | 5 + .../project.pbxproj | 4 +- .../ALOguryPresageMediationAdapter.m | 195 +++++++++--------- 4 files changed, 108 insertions(+), 102 deletions(-) diff --git a/OguryPresage/AppLovinMediationOguryPresageAdapter.podspec b/OguryPresage/AppLovinMediationOguryPresageAdapter.podspec index 03ef47fce0..b8fd9cea7d 100644 --- a/OguryPresage/AppLovinMediationOguryPresageAdapter.podspec +++ b/OguryPresage/AppLovinMediationOguryPresageAdapter.podspec @@ -2,8 +2,8 @@ Pod::Spec.new do |s| s.authors = 'AppLovin Corporation' s.name = 'AppLovinMediationOguryPresageAdapter' -s.version = '4.4.2.0' -s.platform = :ios, '11.0' +s.version = '5.0.0.0' +s.platform = :ios, '12.0' s.summary = 'Ogury (Presage) adapter used for mediation with the AppLovin MAX SDK' s.homepage = "https://github.com/CocoaPods/Specs/search?o=desc&q=#{s.name}&s=indexed" s.license = @@ -26,7 +26,7 @@ s.source = s.vendored_frameworks = "#{s.name}-#{s.version}/#{s.name}.xcframework" -s.dependency 'OgurySdk', '= 4.4.2' +s.dependency 'OgurySdk', '= 5.0.0' s.dependency 'AppLovinSDK' s.swift_version = '5.0' diff --git a/OguryPresage/CHANGELOG.md b/OguryPresage/CHANGELOG.md index 3bedb1c618..3c2c0c7fee 100644 --- a/OguryPresage/CHANGELOG.md +++ b/OguryPresage/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 5.0.0.0 +* Certified with OguryPresage SDK 5.0.0. +* Updated minimum iOS version to 12.0 to match OguryPresage SDK. +* Updated minimum Xcode requirement to 15.3 to match OguryPresage SDK. + ## 4.4.2.0 * Certified with OguryPresage SDK 4.4.2. diff --git a/OguryPresage/OguryPresageAdapter.xcodeproj/project.pbxproj b/OguryPresage/OguryPresageAdapter.xcodeproj/project.pbxproj index 18b73216b3..9cc093e543 100644 --- a/OguryPresage/OguryPresageAdapter.xcodeproj/project.pbxproj +++ b/OguryPresage/OguryPresageAdapter.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/OguryCore\"/**", "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/OgurySdk\"/**", ); - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -390,7 +390,7 @@ "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/OguryCore\"/**", "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/OgurySdk\"/**", ); - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "$(inherited)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/OguryPresage/OguryPresageAdapter/ALOguryPresageMediationAdapter.m b/OguryPresage/OguryPresageAdapter/ALOguryPresageMediationAdapter.m index f4cbfa7971..8769509bad 100644 --- a/OguryPresage/OguryPresageAdapter/ALOguryPresageMediationAdapter.m +++ b/OguryPresage/OguryPresageAdapter/ALOguryPresageMediationAdapter.m @@ -9,9 +9,8 @@ #import "ALOguryPresageMediationAdapter.h" #import #import -#import -#define ADAPTER_VERSION @"4.4.2.0" +#define ADAPTER_VERSION @"5.0.0.0" @interface ALOguryPresageMediationAdapterInterstitialDelegate : NSObject @property (nonatomic, weak) ALOguryPresageMediationAdapter *parentAdapter; @@ -20,7 +19,7 @@ @interface ALOguryPresageMediationAdapterInterstitialDelegate : NSObject )delegate; @end -@interface ALOguryPresageMediationAdapterRewardedAdDelegate : NSObject +@interface ALOguryPresageMediationAdapterRewardedAdDelegate : NSObject @property (nonatomic, weak) ALOguryPresageMediationAdapter *parentAdapter; @property (nonatomic, copy) NSString *placementIdentifier; @property (nonatomic, strong) id delegate; @@ -28,7 +27,7 @@ @interface ALOguryPresageMediationAdapterRewardedAdDelegate : NSObject )delegate; @end -@interface ALOguryPresageMediationAdapterAdViewDelegate : NSObject +@interface ALOguryPresageMediationAdapterAdViewDelegate : NSObject @property (nonatomic, weak) ALOguryPresageMediationAdapter *parentAdapter; @property (nonatomic, copy) NSString *placementIdentifier; @property (nonatomic, strong) id delegate; @@ -42,16 +41,13 @@ @interface ALOguryPresageMediationAdapter () @property (nonatomic, strong) ALOguryPresageMediationAdapterInterstitialDelegate *interstitialDelegate; // Rewarded -@property (nonatomic, strong) OguryOptinVideoAd *rewardedAd; +@property (nonatomic, strong) OguryRewardedAd *rewardedAd; @property (nonatomic, strong) ALOguryPresageMediationAdapterRewardedAdDelegate *rewardedAdDelegate; // Ad View -@property (nonatomic, strong) OguryBannerAd *adView; +@property (nonatomic, strong) OguryBannerAdView *adView; @property (nonatomic, strong) ALOguryPresageMediationAdapterAdViewDelegate *adViewDelegate; -// State to track if ad load finished. Unfortunately, Ogury's SDK's onAdError(...) callback is invoked on ad load and ad display errors (including ad expiration) -@property (nonatomic, assign, getter=isFinishedLoading) BOOL finishedLoading; - @end @implementation ALOguryPresageMediationAdapter @@ -76,21 +72,31 @@ - (void)initializeWithParameters:(id)paramete NSString *assetKey = [parameters.serverParameters al_stringForKey: @"asset_key"]; [self log: @"Initializing Ogury with asset key: %@...", assetKey]; - OguryConfigurationBuilder *configurationBuilder = [[OguryConfigurationBuilder alloc] initWithAssetKey: assetKey]; - [Ogury startWithConfiguration: [configurationBuilder build]]; - - [self log: @"Ogury setup successful"]; - - ALOguryPresageInitializationStatus = MAAdapterInitializationStatusInitializedUnknown; + [Ogury startWith: assetKey completionHandler:^(BOOL success, OguryError *_Nullable error) { + + if ( error ) + { + [self log: @"Ogury SDK failed to initialize with error: %@", error]; + ALOguryPresageInitializationStatus = MAAdapterInitializationStatusInitializedFailure; + completionHandler(ALOguryPresageInitializationStatus, nil); + return; + } + + [self log: @"Ogury SDK initialized"]; + ALOguryPresageInitializationStatus = MAAdapterInitializationStatusInitializedSuccess; + completionHandler(ALOguryPresageInitializationStatus, nil); + }]; + } + else + { + completionHandler(ALOguryPresageInitializationStatus, nil); } - - completionHandler(ALOguryPresageInitializationStatus, nil); } // Return version of the main Ogury SDK. Previous version of the adapater returned version of the Ogury Ads SDK. - (NSString *)SDKVersion { - return [Ogury getSdkVersion]; + return [Ogury sdkVersion]; } - (NSString *)adapterVersion @@ -122,9 +128,18 @@ - (void)destroy - (void)collectSignalWithParameters:(id)parameters andNotify:(id)delegate { [self log: @"Collecting signal..."]; - - NSString *signal = [OguryTokenService getBidderToken]; - [delegate didCollectSignal: signal]; + [OguryBidTokenService bidToken:^(NSString *_Nullable signal, OguryError *_Nullable error) { + + if ( error ) + { + [self log: @"Signal collection failed with error code %ld and description: %@", error.code, error.localizedDescription]; + [delegate didFailToCollectSignalWithErrorMessage: error.localizedDescription]; + return; + } + + [self log: @"Signal collection successful"]; + [delegate didCollectSignal: signal]; + }]; } #pragma mark - MAInterstitialAdapter Methods @@ -135,8 +150,11 @@ - (void)loadInterstitialAdForParameters:(id)paramet NSString *bidResponse = parameters.bidResponse; [self log: @"Loading %@interstitial ad \"%@\"...", [bidResponse al_isValidString] ? @"bidding " : @"", placementIdentifier]; - self.interstitialAd = [[OguryInterstitialAd alloc] initWithAdUnitId: placementIdentifier mediation: [[OguryMediation alloc] initWithName: @"AppLovin MAX" version: ALSdk.version]]; - self.interstitialDelegate = [[ALOguryPresageMediationAdapterInterstitialDelegate alloc] initWithParentAdapter: self placementIdentifier: placementIdentifier andNotify: delegate]; + self.interstitialAd = [[OguryInterstitialAd alloc] initWithAdUnitId: placementIdentifier + mediation: [[OguryMediation alloc] initWithName: @"AppLovin MAX" version: ALSdk.version]]; + self.interstitialDelegate = [[ALOguryPresageMediationAdapterInterstitialDelegate alloc] initWithParentAdapter: self + placementIdentifier: placementIdentifier + andNotify: delegate]; self.interstitialAd.delegate = self.interstitialDelegate; if ( [self.interstitialAd isLoaded] ) @@ -164,8 +182,6 @@ - (void)showInterstitialAdForParameters:(id)paramet if ( [self.interstitialAd isLoaded] ) { - self.finishedLoading = YES; - UIViewController *presentingViewController; if ( ALSdk.versionCode >= 11020199 ) { @@ -200,8 +216,11 @@ - (void)loadRewardedAdForParameters:(id)parameters NSString *bidResponse = parameters.bidResponse; [self log: @"Loading %@rewarded ad: %@...", [bidResponse al_isValidString] ? @"bidding " : @"", placementIdentifier]; - self.rewardedAd = [[OguryOptinVideoAd alloc] initWithAdUnitId: placementIdentifier mediation: [[OguryMediation alloc] initWithName: @"AppLovin MAX" version: ALSdk.version]]; - self.rewardedAdDelegate = [[ALOguryPresageMediationAdapterRewardedAdDelegate alloc] initWithParentAdapter: self placementIdentifier: placementIdentifier andNotify: delegate]; + self.rewardedAd = [[OguryRewardedAd alloc] initWithAdUnitId: placementIdentifier + mediation: [[OguryMediation alloc] initWithName: @"AppLovin MAX" version: ALSdk.version]]; + self.rewardedAdDelegate = [[ALOguryPresageMediationAdapterRewardedAdDelegate alloc] initWithParentAdapter: self + placementIdentifier: placementIdentifier + andNotify: delegate]; self.rewardedAd.delegate = self.rewardedAdDelegate; if ( [self.rewardedAd isLoaded] ) @@ -232,8 +251,6 @@ - (void)showRewardedAdForParameters:(id)parameters // Configure userReward from server [self configureRewardForParameters: parameters]; - self.finishedLoading = YES; - UIViewController *presentingViewController; if ( ALSdk.versionCode >= 11020199 ) { @@ -268,8 +285,12 @@ - (void)loadAdViewAdForParameters:(id)parameters ad NSString *bidResponse = parameters.bidResponse; [self log: @"Loading %@%@ ad: %@...", [bidResponse al_isValidString] ? @"bidding " : @"", adFormat.label, placementIdentifier]; - self.adView = [[OguryBannerAd alloc] initWithAdUnitId: placementIdentifier mediation: [[OguryMediation alloc] initWithName: @"AppLovin MAX" version: ALSdk.version]]; - self.adViewDelegate = [[ALOguryPresageMediationAdapterAdViewDelegate alloc] initWithParentAdapter: self placementIdentifier: placementIdentifier andNotify: delegate]; + self.adView = [[OguryBannerAdView alloc] initWithAdUnitId: placementIdentifier + size: [self sizeFromAdFormat: adFormat] + mediation: [[OguryMediation alloc] initWithName: @"AppLovin MAX" version: ALSdk.version]]; + self.adViewDelegate = [[ALOguryPresageMediationAdapterAdViewDelegate alloc] initWithParentAdapter: self + placementIdentifier: placementIdentifier + andNotify: delegate]; self.adView.delegate = self.adViewDelegate; if ( [self.adView isLoaded] ) @@ -281,11 +302,11 @@ - (void)loadAdViewAdForParameters:(id)parameters ad { if ( [bidResponse al_isValidString] ) { - [self.adView loadWithAdMarkup: bidResponse size: [self sizeFromAdFormat: adFormat]]; + [self.adView loadWithAdMarkup: bidResponse]; } else { - [self.adView loadWithSize: [self sizeFromAdFormat: adFormat]]; + [self.adView load]; } } } @@ -301,40 +322,34 @@ + (MAAdapterError *)toMaxError:(OguryError *)oguryError // Error messages copied from https://ogury-ltd.gitbook.io/ios/ad-formats/interstitial-ad#error-codes switch ( oguryError.code ) { - case OguryAdsNotLoadedError: + case OguryLoadErrorCodeAdDisabledUnspecifiedReason: // We are not sure what kind of load error it is - may be misconfigured ad unit id, et al... adapterError = MAAdapterError.unspecified; break; - case OguryCoreErrorTypeNoInternetConnection: + case OguryLoadErrorCodeNoActiveInternetConnection: adapterError = MAAdapterError.noConnection; break; - case OguryAdsAdDisabledError: + case OguryLoadErrorCodeAdDisabledCountryNotOpened: + case OguryLoadErrorCodeAdDisabledConsentDenied: + case OguryLoadErrorCodeAdDisabledConsentMissing: + case OguryLoadErrorCodeInvalidConfiguration: adapterError = MAAdapterError.invalidConfiguration; break; - case OguryAdsProfigNotSyncedError: - adapterError = MAAdapterError.invalidConfiguration; - break; - case OguryAdsAdExpiredError: - adapterError = MAAdapterError.adExpiredError; - break; - case OguryAdsSdkInitNotCalledError: + case OguryLoadErrorCodeSDKNotStarted: + case OguryLoadErrorCodeSDKNotProperlyInitialized: adapterError = MAAdapterError.notInitialized; break; - case OguryAdsAnotherAdAlreadyDisplayedError: - adapterError = MAAdapterError.invalidLoadState; + case OguryLoadErrorCodeAdRequestFailed: + adapterError = MAAdapterError.serverError; break; - case OguryAdsCantShowAdsInPresentingViewControllerError: + case OguryLoadErrorCodeAdParsingFailed: + case OguryLoadErrorCodeAdPrecachingFailed: + case OguryLoadErrorCodeAdPrecachingTimeout: adapterError = MAAdapterError.internalError; break; - case OguryAdsAssetKeyNotValidError: - adapterError = MAAdapterError.invalidConfiguration; - break; - case OguryAdsNotAvailableError: + case OguryLoadErrorCodeNoFill: adapterError = MAAdapterError.noFill; break; - case OguryAdsUnknownError: - adapterError = MAAdapterError.unspecified; - break; } #pragma clang diagnostic push @@ -346,20 +361,22 @@ + (MAAdapterError *)toMaxError:(OguryError *)oguryError #pragma clang diagnostic pop } -- (OguryAdsBannerSize *)sizeFromAdFormat:(MAAdFormat *)adFormat + + +- (OguryBannerAdSize *)sizeFromAdFormat:(MAAdFormat *)adFormat { if ( adFormat == MAAdFormat.banner || adFormat == MAAdFormat.leader ) { - return OguryAdsBannerSize.small_banner_320x50; + return OguryBannerAdSize.small_banner_320x50; } else if ( adFormat == MAAdFormat.mrec ) { - return OguryAdsBannerSize.mpu_300x250; + return OguryBannerAdSize.mrec_300x250; } else { [NSException raise: NSInvalidArgumentException format: @"Invalid ad format: %@", adFormat]; - return OguryAdsBannerSize.small_banner_320x50; + return OguryBannerAdSize.small_banner_320x50; } } @@ -380,39 +397,34 @@ - (instancetype)initWithParentAdapter:(ALOguryPresageMediationAdapter *)parentAd } return self; } - -- (void)didLoadOguryInterstitialAd:(OguryInterstitialAd *)interstitial + +- (void)interstitialAdDidLoad:(OguryInterstitialAd *)interstitial { [self.parentAdapter log: @"Interstitial loaded: %@", self.placementIdentifier]; [self.delegate didLoadInterstitialAd]; } -- (void)didDisplayOguryInterstitialAd:(OguryInterstitialAd *)interstitial -{ - [self.parentAdapter log: @"Interstitial shown: %@", self.placementIdentifier]; -} - -- (void)didTriggerImpressionOguryInterstitialAd:(OguryInterstitialAd *)interstitial +- (void)interstitialAdDidTriggerImpression:(OguryInterstitialAd *)interstitial { [self.parentAdapter log: @"Interstitial triggered impression: %@", self.placementIdentifier]; [self.delegate didDisplayInterstitialAd]; } -- (void)didClickOguryInterstitialAd:(OguryInterstitialAd *)interstitial +- (void)interstitialAdDidClick:(OguryInterstitialAd *)interstitial { [self.parentAdapter log: @"Interstitial clicked: %@", self.placementIdentifier]; [self.delegate didClickInterstitialAd]; } -- (void)didCloseOguryInterstitialAd:(OguryInterstitialAd *)interstitial +- (void)interstitialAdDidClose:(OguryInterstitialAd *)interstitial { [self.parentAdapter log: @"Interstitial hidden: %@", self.placementIdentifier]; [self.delegate didHideInterstitialAd]; } -- (void)didFailOguryInterstitialAdWithError:(OguryError *)error forAd:(OguryInterstitialAd *)interstitial +- (void)interstitialAd:(OguryInterstitialAd *)interstitial didFailWithError:(OguryAdError *)error { - if ( [self.parentAdapter isFinishedLoading] ) + if ( error.type == OguryAdErrorTypeShow ) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -451,31 +463,26 @@ - (instancetype)initWithParentAdapter:(ALOguryPresageMediationAdapter *)parentAd return self; } -- (void)didLoadOguryOptinVideoAd:(OguryOptinVideoAd *)optinVideo +- (void)rewardedAdDidLoad:(OguryRewardedAd *)rewardedAd { [self.parentAdapter log: @"Rewarded ad loaded: %@", self.placementIdentifier]; [self.delegate didLoadRewardedAd]; } -- (void)didDisplayOguryOptinVideoAd:(OguryOptinVideoAd *)optinVideo -{ - [self.parentAdapter log: @"Rewarded ad shown: %@", self.placementIdentifier]; -} - -- (void)didTriggerImpressionOguryOptinVideoAd:(OguryOptinVideoAd *)optinVideo +- (void)rewardedAdDidTriggerImpression:(OguryRewardedAd *)rewardedAd { [self.parentAdapter log: @"Rewarded ad triggered impression: %@", self.placementIdentifier]; [self.delegate didDisplayRewardedAd]; } -- (void)didClickOguryOptinVideoAd:(OguryOptinVideoAd *)optinVideo +- (void)rewardedAdDidClick:(OguryRewardedAd *)rewardedAd { [self.parentAdapter log: @"Rewarded ad clicked: %@", self.placementIdentifier]; [self.delegate didClickRewardedAd]; } -- (void)didCloseOguryOptinVideoAd:(OguryOptinVideoAd *)optinVideo -{ +- (void)rewardedAdDidClose:(OguryRewardedAd *)rewardedAd +{ if ( [self hasGrantedReward] || [self.parentAdapter shouldAlwaysRewardUser] ) { MAReward *reward = [self.parentAdapter reward]; @@ -487,15 +494,15 @@ - (void)didCloseOguryOptinVideoAd:(OguryOptinVideoAd *)optinVideo [self.delegate didHideRewardedAd]; } -- (void)didRewardOguryOptinVideoAdWithItem:(OGARewardItem *)item forAd:(OguryOptinVideoAd *)optinVideo +- (void)rewardedAd:(OguryRewardedAd *)rewardedAd didReceiveReward:(OguryReward *)reward { - [self.parentAdapter log: @"Rewarded ad (%@) granted reward with rewardName: %@, rewardValue: %@", self.placementIdentifier, item.rewardName, item.rewardValue]; + [self.parentAdapter log: @"Rewarded ad (%@) granted reward with rewardName: %@, rewardValue: %@", self.placementIdentifier, reward.rewardName, reward.rewardValue]; self.grantedReward = YES; } -- (void)didFailOguryOptinVideoAdWithError:(OguryError *)error forAd:(OguryOptinVideoAd *)optinVideo +- (void)rewardedAd:(OguryRewardedAd *)rewardedAd didFailWithError:(OguryAdError *)error { - if ( [self.parentAdapter isFinishedLoading] ) + if ( error.type == OguryAdErrorTypeShow ) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -531,39 +538,33 @@ - (instancetype)initWithParentAdapter:(ALOguryPresageMediationAdapter *)parentAd } return self; } - -- (void)didLoadOguryBannerAd:(OguryBannerAd *)banner + +- (void)bannerAdViewDidLoad:(OguryBannerAdView *)banner { [self.parentAdapter log: @"AdView loaded: %@", self.placementIdentifier]; - self.parentAdapter.finishedLoading = YES; [self.delegate didLoadAdForAdView: banner]; } -- (void)didDisplayOguryBannerAd:(OguryBannerAd *)banner -{ - [self.parentAdapter log: @"AdView shown: %@", self.placementIdentifier]; -} - -- (void)didTriggerImpressionOguryBannerAd:(OguryBannerAd *)banner +- (void)bannerAdViewDidTriggerImpression:(OguryBannerAdView *)banner { [self.parentAdapter log: @"AdView triggered impression: %@", self.placementIdentifier]; [self.delegate didDisplayAdViewAd]; } -- (void)didClickOguryBannerAd:(OguryBannerAd *)banner +- (void)bannerAdViewDidClick:(OguryBannerAdView *)banner { [self.parentAdapter log: @"AdView clicked: %@", self.placementIdentifier]; [self.delegate didClickAdViewAd]; } -- (void)didCloseOguryBannerAd:(OguryBannerAd *)banner +- (void)bannerAdViewDidClose:(OguryBannerAdView *)banner { [self.parentAdapter log: @"AdView closed: %@", self.placementIdentifier]; } -- (void)didFailOguryBannerAdWithError:(OguryError *)error forAd:(OguryBannerAd *)banner +- (void)bannerAdView:(OguryBannerAdView *)banner didFailWithError:(OguryAdError *)error { - if ( [self.parentAdapter isFinishedLoading] ) + if ( error.type == OguryAdErrorTypeShow ) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -586,7 +587,7 @@ - (void)didFailOguryBannerAdWithError:(OguryError *)error forAd:(OguryBannerAd * // This allows clicks on banners using modal view controller (Ex: banner ads using mediation debugger) // (https://ogury-ltd.gitbook.io/ios/ad-formats/banner-ad#using-modal-view-controller) -- (UIViewController *)presentingViewControllerForOguryAdsBannerAd:(OguryBannerAd *)banner +- (UIViewController *)presentingViewControllerForBannerAdView:(OguryBannerAdView *)banner { return [ALUtils topViewControllerFromKeyWindow]; }