From e67d5161460d225a003466aab005bcca8b118507 Mon Sep 17 00:00:00 2001 From: yinliming Date: Tue, 1 Dec 2020 19:30:05 +0800 Subject: [PATCH] Add CrossPromotion Ad --- Adapters/AdColonyAdapter/OMAdColonyAdapter.m | 21 -- .../AdColonyAdapter/OMAdColonyRewardedVideo.m | 18 +- Adapters/AdTimingAdapter/OMAdTimingAdapter.m | 4 +- Adapters/AdTimingAdapter/OMAdTimingClass.h | 10 +- Adapters/AdmobAdapter/OMAdMobAdapter.m | 29 +- Adapters/AppLovinAdapter/OMAppLovinAdapter.m | 30 +- Adapters/AppLovinAdapter/OMAppLovinBanner.m | 6 +- .../AppLovinAdapter/OMAppLovinInterstitial.m | 2 +- .../AppLovinAdapter/OMAppLovinRewardedVideo.m | 2 +- .../ChartboostAdapter/OMChartboostAdapter.m | 23 +- .../OMChartboostInterstitial.m | 18 +- .../OMChartboostRewardedVideo.m | 22 +- .../OMChartboostBidAdapter.h | 11 +- .../OMChartboostBidAdapter.m | 9 +- .../OMChartboostBidClass.h | 9 +- .../OMChartboostBidInterstitial.h | 9 +- .../OMChartboostBidInterstitial.m | 23 +- .../OMChartboostBidRewardedVideo.h | 9 +- .../OMChartboostBidRewardedVideo.m | 23 +- .../OMChartboostBidRouter.h | 9 +- .../OMChartboostBidRouter.m | 11 +- Adapters/FacebookAdapter/OMFacebookAdapter.h | 2 +- .../FacebookAdapter/OMFacebookRewardedVideo.m | 1 + .../IronSourceAdapter/OMIronSourceAdapter.h | 2 +- .../IronSourceAdapter/OMIronSourceAdapter.m | 36 +- .../IronSourceAdapter/OMIronSourceBanner.m | 9 +- .../IronSourceAdapter/OMIronSourceClass.h | 22 +- .../OMIronSourceInterstitial.h | 3 +- .../OMIronSourceInterstitial.m | 106 +++++- .../OMIronSourceRewardedVideo.h | 3 +- .../OMIronSourceRewardedVideo.m | 123 +++++-- .../IronSourceAdapter/OMIronSourceRouter.m | 30 +- .../OMMintegralInterstitial.h | 1 - .../OMMintegralInterstitial.m | 5 +- .../OMMintegralRewardedVideo.m | 1 + Adapters/MintegralAdapter/OMMintegralRouter.m | 4 + Adapters/MoPubAdapter/OMMopubAdapter.h | 2 +- Adapters/MoPubAdapter/OMMopubAdapter.m | 28 +- Adapters/MoPubAdapter/OMMopubBanner.m | 12 +- Adapters/MoPubAdapter/OMMopubNativeView.m | 2 +- Adapters/MoPubAdapter/OMMopubRewardedVideo.m | 4 +- Adapters/MyTargetAdapter/OMMyTargetAdapter.m | 22 -- Adapters/TapjoyAdapter/OMTapjoyAdapter.m | 27 +- .../TencentAdAdapter/OMTencentAdAdapter.m | 22 -- Adapters/TencentAdAdapter/OMTencentAdBanner.m | 10 +- .../OMTencentAdInterstitial.m | 10 +- Adapters/TencentAdAdapter/OMTencentAdNative.m | 10 +- .../TencentAdAdapter/OMTencentAdNativeView.m | 4 +- .../OMTencentAdRewardedVideo.m | 6 +- Adapters/TikTokAdapter/OMTikTokAdapter.h | 3 +- Adapters/TikTokAdapter/OMTikTokAdapter.m | 26 +- Adapters/TikTokAdapter/OMTikTokBanner.m | 8 +- Adapters/TikTokAdapter/OMTikTokInterstitial.h | 3 +- Adapters/TikTokAdapter/OMTikTokInterstitial.m | 74 +++- .../TikTokAdapter/OMTikTokInterstitialClass.h | 148 ++++++++ .../TikTokAdapter/OMTikTokRewardedVideo.h | 3 +- .../TikTokAdapter/OMTikTokRewardedVideo.m | 98 +++++- .../OMTikTokRewardedVideoClass.h | 167 +++++++++ Adapters/UnityAdapter/OMUnityAdapter.m | 21 -- Adapters/UnityAdapter/OMUnityBanner.m | 8 +- Adapters/VungleAdapter/OMVungleAdapter.h | 2 +- Adapters/VungleAdapter/OMVungleAdapter.m | 44 +-- Adapters/VungleAdapter/OMVungleBid.h | 15 + Adapters/VungleAdapter/OMVungleBid.m | 18 + Adapters/VungleAdapter/OMVungleBidClass.h | 60 ++++ .../VungleAdapter/OMVungleRewardedVideo.m | 6 +- Adapters/VungleAdapter/OMVungleRouter.h | 3 +- Adapters/VungleAdapter/OMVungleRouter.m | 24 ++ OpenMediation.podspec | 2 +- OpenMediation.xcodeproj/project.pbxproj | 257 +++++++++++++- OpenMediation/Info.plist | 2 +- .../OpenMediaitonSegments/OMAdBase.m | 56 ++-- .../OpenMediaitonSegments/OMAudience.m | 2 +- OpenMediation/OpenMediaitonSegments/OMLoad.h | 1 + .../OpenMediaitonSegments/OMMediations.m | 20 +- .../OpenMediaitonSegments/OMSmartLoad.m | 26 +- OpenMediation/OpenMediation.h | 10 +- OpenMediation/OpenMediation.m | 43 ++- OpenMediation/OpenMediationAdFormats.h | 1 + OpenMediation/OpenMediationBid/OMBid.m | 9 + .../OpenMediationBid/OMBidResponse.h | 1 + .../OpenMediationBid/OMBidResponse.m | 4 + OpenMediation/OpenMediationConstant.h | 3 +- .../OMCrossPromotion.h | 47 +++ .../OMCrossPromotion.m | 192 +++++++++++ .../OMCrossPromotionAd.h | 30 ++ .../OMCrossPromotionAd.m | 122 +++++++ .../OMCrossPromotionAdDelegate.h | 30 ++ .../OMCrossPromotionDelegate.h | 30 ++ .../OMBannerCustomEvent.h | 2 + .../OMCrossPromotionCustomEvent.h | 30 ++ .../OMInterstitialCustomEvent.h | 2 + .../OMNativeCustomEvent.h | 2 + .../OMRewardedVideoCustomEvent.h | 2 + .../OMSplashCustomEvent.h | 2 + OpenMediation/OpenMediationModel/OMConfig.h | 6 +- OpenMediation/OpenMediationModel/OMConfig.m | 8 +- OpenMediation/OpenMediationModel/OMScene.m | 1 - OpenMediation/OpenMediationNative/OMNative.m | 1 + .../OpenMediationNetwork/OMBaseRequest.m | 8 +- .../OpenMediationNetwork/OMCDRequest.h | 16 + .../OpenMediationNetwork/OMCDRequest.m | 40 +++ .../OpenMediationNetwork/OMInitRequest.h | 2 +- .../OpenMediationNetwork/OMInitRequest.m | 6 +- .../OpenMediationNetwork/OMLrRequest.m | 4 +- .../OpenMediationNetwork/OMNetworkUmbrella.h | 1 + .../OpenMediationNetwork/OMRequest.m | 6 +- .../OpenMediationNetwork/OMWaterfallRequest.m | 4 +- .../OMCrossPromotionBanner.h | 22 ++ .../OMCrossPromotionBanner.m | 249 ++++++++++++++ .../OMCrossPromotionBid.h | 12 + .../OMCrossPromotionBid.m | 58 ++++ .../OMCrossPromotionCP.h | 24 ++ .../OMCrossPromotionCP.m | 231 +++++++++++++ .../OMCrossPromotionCacheFile.h | 15 + .../OMCrossPromotionCacheFile.m | 44 +++ .../OMCrossPromotionCampaign.h | 64 ++++ .../OMCrossPromotionCampaign.m | 316 ++++++++++++++++++ .../OMCrossPromotionCampaignManager.h | 37 ++ .../OMCrossPromotionCampaignManager.m | 157 +++++++++ .../OMCrossPromotionCampaignModel.h | 35 ++ .../OMCrossPromotionCampaignModel.m | 70 ++++ .../OMCrossPromotionClRequest.h | 16 + .../OMCrossPromotionClRequest.m | 53 +++ .../OMCrossPromotionClickHandler.h | 38 +++ .../OMCrossPromotionClickHandler.m | 175 ++++++++++ .../OMCrossPromotionDownloadManager.h | 27 ++ .../OMCrossPromotionDownloadManager.m | 162 +++++++++ .../OMCrossPromotionDownloader.h | 33 ++ .../OMCrossPromotionDownloader.m | 198 +++++++++++ .../OMCrossPromotionExposureMonitor.h | 16 + .../OMCrossPromotionExposureMonitor.m | 115 +++++++ .../OMCrossPromotionHTTPCacheControl.h | 29 ++ .../OMCrossPromotionHTTPCacheControl.m | 174 ++++++++++ .../OMCrossPromotionJSBridge.h | 54 +++ .../OMCrossPromotionJSBridge.m | 193 +++++++++++ .../OMCrossPromotionNative.h | 21 ++ .../OMCrossPromotionNative.m | 86 +++++ .../OMCrossPromotionNativeAd.h | 35 ++ .../OMCrossPromotionNativeAd.m | 26 ++ .../OMCrossPromotionNativeMediaView.h | 15 + .../OMCrossPromotionNativeMediaView.m | 30 ++ .../OMCrossPromotionNativeView.h | 24 ++ .../OMCrossPromotionNativeView.m | 118 +++++++ .../OMCrossPromotionRewardedVideo.h | 24 ++ .../OMCrossPromotionRewardedVideo.m | 142 ++++++++ .../OMCrossPromotionVideoController.h | 37 ++ .../OMCrossPromotionVideoController.m | 247 ++++++++++++++ .../OMCrossPromotionWebController.h | 27 ++ .../OMCrossPromotionWebController.m | 150 +++++++++ .../OMPromotionConfig.h | 24 ++ .../OMPromotionConfig.m | 35 ++ .../OpenMediationPromotion/OMPromotionUnit.h | 23 ++ .../OpenMediationPromotion/OMPromotionUnit.m | 21 ++ .../OpenMediationTool/NSData+OMGzip.h | 3 +- .../OpenMediationTool/NSData+OMGzip.m | 84 +++++ .../OpenMediationTool/UIDevice+OMExtension.h | 4 + .../OpenMediationTool/UIDevice+OMExtension.m | 19 ++ OpenMediation/OpenMediationUmbrella.h | 3 + OpenMediationDemo/AppDelegate.m | 3 +- .../CrossPromotionViewController.h | 13 + .../CrossPromotionViewController.m | 70 ++++ OpenMediationDemo/Info.plist | 2 +- OpenMediationDemo/MainViewController.m | 30 +- Podfile | 42 +-- README.md | 4 +- 166 files changed, 5895 insertions(+), 651 deletions(-) create mode 100644 Adapters/VungleAdapter/OMVungleBid.h create mode 100644 Adapters/VungleAdapter/OMVungleBid.m create mode 100644 Adapters/VungleAdapter/OMVungleBidClass.h create mode 100644 OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.h create mode 100644 OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.m create mode 100644 OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.h create mode 100644 OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.m create mode 100644 OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAdDelegate.h create mode 100644 OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionDelegate.h create mode 100644 OpenMediation/OpenMediationCustomEvent/OMCrossPromotionCustomEvent.h create mode 100644 OpenMediation/OpenMediationNetwork/OMCDRequest.h create mode 100644 OpenMediation/OpenMediationNetwork/OMCDRequest.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.m create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.h create mode 100644 OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.m create mode 100644 OpenMediation/OpenMediationPromotion/OMPromotionConfig.h create mode 100644 OpenMediation/OpenMediationPromotion/OMPromotionConfig.m create mode 100644 OpenMediation/OpenMediationPromotion/OMPromotionUnit.h create mode 100644 OpenMediation/OpenMediationPromotion/OMPromotionUnit.m create mode 100644 OpenMediationDemo/CrossPromotionViewController.h create mode 100644 OpenMediationDemo/CrossPromotionViewController.m diff --git a/Adapters/AdColonyAdapter/OMAdColonyAdapter.m b/Adapters/AdColonyAdapter/OMAdColonyAdapter.m index 54ad458..bd8dd7d 100644 --- a/Adapters/AdColonyAdapter/OMAdColonyAdapter.m +++ b/Adapters/AdColonyAdapter/OMAdColonyAdapter.m @@ -14,19 +14,6 @@ + (NSString*)adapterVerison { return AdColonyAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"AdColony"); - if (sdkClass && [sdkClass respondsToSelector:@selector(getSDKVersion)]) { - sdkVersion = [sdkClass getSDKVersion]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"3.3.6"; -} - + (void)setConsent:(BOOL)consent { gdprConsentString = (consent?@"1":@"0"); } @@ -61,14 +48,6 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.adcolonyadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - if (adColonyClass && [adColonyClass respondsToSelector:@selector(configureWithAppID:zoneIDs:options:completion:)]) { AdColonyAppOptions *options = [NSClassFromString(@"AdColonyAppOptions") new]; if (gdprConsentString) { diff --git a/Adapters/AdColonyAdapter/OMAdColonyRewardedVideo.m b/Adapters/AdColonyAdapter/OMAdColonyRewardedVideo.m index 8e14494..76088be 100644 --- a/Adapters/AdColonyAdapter/OMAdColonyRewardedVideo.m +++ b/Adapters/AdColonyAdapter/OMAdColonyRewardedVideo.m @@ -16,7 +16,7 @@ - (instancetype)initWithParameter:(NSDictionary*)adParameter{ - (void)loadAd { Class adColonyClass = NSClassFromString(@"AdColony"); - if(adColonyClass && [adColonyClass respondsToSelector:@selector(requestInterstitialInZone:options:andDelegate:)]){ + if(adColonyClass && [adColonyClass respondsToSelector:@selector(requestInterstitialInZone:options:andDelegate:)]) { AdColonyAdOptions *options = [NSClassFromString(@"AdColonyAdOptions") new]; @@ -59,7 +59,7 @@ - (void)show:(UIViewController *)vc { // Store a reference to the returned interstitial object - (void)adColonyInterstitialDidLoad:(AdColonyInterstitial *)interstitial { - if(self.delegate && [self.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [self.delegate customEvent:self didLoadAd:nil]; } self.adColonyAd = interstitial; @@ -67,31 +67,31 @@ - (void)adColonyInterstitialDidLoad:(AdColonyInterstitial *)interstitial { // Handle loading error - (void)adColonyInterstitialDidFailToLoad:(AdColonyAdRequestError *)error { - if(self.delegate && [self.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [self.delegate customEvent:self didFailToLoadWithError:error]; } } - (void)adColonyInterstitialWillOpen:(AdColonyInterstitial *)interstitial { - if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { [self.delegate rewardedVideoCustomEventDidOpen:self]; } - if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { [self.delegate rewardedVideoCustomEventVideoStart:self]; } } - (void)adColonyInterstitialDidClose:(AdColonyInterstitial *)interstitial { - if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { [self.delegate rewardedVideoCustomEventVideoEnd:self]; } - if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { [self.delegate rewardedVideoCustomEventDidReceiveReward:self]; } - if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { [self.delegate rewardedVideoCustomEventDidClose:self]; } @@ -102,7 +102,7 @@ - (void)adColonyInterstitialWillLeaveApplication:(AdColonyInterstitial *)interst } - (void)adColonyInterstitialDidReceiveClick:(AdColonyInterstitial *)interstitial { - if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { [self.delegate rewardedVideoCustomEventDidClick:self]; } } diff --git a/Adapters/AdTimingAdapter/OMAdTimingAdapter.m b/Adapters/AdTimingAdapter/OMAdTimingAdapter.m index 98a3b4b..f8ed8cc 100644 --- a/Adapters/AdTimingAdapter/OMAdTimingAdapter.m +++ b/Adapters/AdTimingAdapter/OMAdTimingAdapter.m @@ -13,8 +13,8 @@ + (NSString *)adapterVerison { + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler { NSString *key = [configuration objectForKey:@"appKey"]; Class adtimingClass = NSClassFromString(@"AdTiming"); - if (adtimingClass && [adtimingClass respondsToSelector:@selector(initWithAppKey:)]) { - [adtimingClass initWithAppKey:key]; + if (adtimingClass && [adtimingClass respondsToSelector:@selector(initWithAppKey:adType:)]) { + [adtimingClass initWithAppKey:key adType:0]; completionHandler(nil); } else { NSError *error = [[NSError alloc] initWithDomain:@"com.om.mediation" code:400 userInfo:@{NSLocalizedDescriptionKey:@"Failed,check init method and key"}]; diff --git a/Adapters/AdTimingAdapter/OMAdTimingClass.h b/Adapters/AdTimingAdapter/OMAdTimingClass.h index 5433c1a..2f3c99a 100644 --- a/Adapters/AdTimingAdapter/OMAdTimingClass.h +++ b/Adapters/AdTimingAdapter/OMAdTimingClass.h @@ -4,9 +4,17 @@ #ifndef OMAdTimingClass_h #define OMAdTimingClass_h +typedef NS_ENUM(NSInteger, AdTimingAdType) { + AdTimingAdTypeBanner = (1 << 0), + AdTimingAdTypeNative = (1 << 1), + AdTimingAdTypeRewardedVideo = (1 << 2), + AdTimingAdTypeInteractive = (1 << 3), + AdTimingAdTypeInterstitial = (1 << 4), +}; + @interface AdTiming : NSObject + (NSString *)SDKVersion; -+ (void)initWithAppKey:(NSString*)appKey; ++ (void)initWithAppKey:(NSString *)appKey adType:(AdTimingAdType)initAdTypes; + (NSString*)bidderToken; + (void)setGDPRConsent:(BOOL)consent; + (void)setUSPrivacyLimit:(BOOL)privacyLimit; diff --git a/Adapters/AdmobAdapter/OMAdMobAdapter.m b/Adapters/AdmobAdapter/OMAdMobAdapter.m index 51af542..b897c11 100644 --- a/Adapters/AdmobAdapter/OMAdMobAdapter.m +++ b/Adapters/AdmobAdapter/OMAdMobAdapter.m @@ -13,23 +13,6 @@ + (NSString*)adapterVerison { return AdmobAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class admobClass = NSClassFromString(@"GADMobileAds"); - if (admobClass && [admobClass respondsToSelector:@selector(sharedInstance)]) { - GADMobileAds *admob = [admobClass sharedInstance]; - if(admob && [admob respondsToSelector:@selector(sdkVersion)]){ - sdkVersion = [admob sdkVersion]; - } - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"afma-sdk-i-v7.42.0"; -} - - + (void)setConsent:(BOOL)consent { admobNpaAd = !consent; } @@ -53,20 +36,12 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.admobadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - NSString *key = [configuration objectForKey:@"appKey"]; - if([key length] == [@"ca-app-pub-8080140584266451~7053247990" length]){//admob key 长度有限制,格式错误崩溃 + if([key length] == [@"ca-app-pub-8080140584266451~7053247990" length]) {//admob key 长度有限制,格式错误崩溃 [[NSBundle mainBundle].infoDictionary setValue:key forKey:@"GADApplicationIdentifier"]; } Class admobClass = NSClassFromString(@"GADMobileAds"); - if(admobClass && [admobClass respondsToSelector:@selector(sharedInstance)]){ + if(admobClass && [admobClass respondsToSelector:@selector(sharedInstance)]) { GADMobileAds *ac = [admobClass sharedInstance]; if (ac && [ac respondsToSelector:@selector(startWithCompletionHandler:)]) { [ac startWithCompletionHandler:nil]; diff --git a/Adapters/AppLovinAdapter/OMAppLovinAdapter.m b/Adapters/AppLovinAdapter/OMAppLovinAdapter.m index 9602310..f0816c0 100644 --- a/Adapters/AppLovinAdapter/OMAppLovinAdapter.m +++ b/Adapters/AppLovinAdapter/OMAppLovinAdapter.m @@ -10,20 +10,6 @@ + (NSString*)adapterVerison { return AppLovinAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"ALSdk"); - if (sdkClass && [sdkClass respondsToSelector:@selector(versionCode)]) { - sdkVersion = [NSString stringWithFormat:@"%zd",[sdkClass versionCode]]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"6.1.1"; -} - - + (void)setConsent:(BOOL)consent { Class privacySettings = NSClassFromString(@"ALPrivacySettings"); @@ -53,15 +39,7 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.applovinadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - - if(applovinClass && [applovinClass respondsToSelector:@selector(sharedWithKey:)]){ + if(applovinClass && [applovinClass respondsToSelector:@selector(sharedWithKey:)]) { alShareSDK = [applovinClass sharedWithKey:key]; completionHandler(nil); }else{ @@ -78,10 +56,10 @@ + (ALSdk*)alShareSdk{ + (UIWindow *)currentWindow{ UIWindow * window = [[UIApplication sharedApplication] keyWindow]; - if (window.windowLevel != UIWindowLevelNormal){ + if (window.windowLevel != UIWindowLevelNormal) { NSArray *windows = [[UIApplication sharedApplication] windows]; - for(UIWindow * tmpWin in windows){ - if (tmpWin.windowLevel == UIWindowLevelNormal){ + for(UIWindow * tmpWin in windows) { + if (tmpWin.windowLevel == UIWindowLevelNormal) { window = tmpWin; break; } diff --git a/Adapters/AppLovinAdapter/OMAppLovinBanner.m b/Adapters/AppLovinAdapter/OMAppLovinBanner.m index 83537e7..6cd3c3b 100644 --- a/Adapters/AppLovinAdapter/OMAppLovinBanner.m +++ b/Adapters/AppLovinAdapter/OMAppLovinBanner.m @@ -43,14 +43,14 @@ - (void)loadAd{ - (void)adService:(ALAdService *)adService didLoadAd:(ALAd *)ad { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } } - (void)adService:(ALAdService *)adService didFailToLoadAdWithError:(int)code { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:[NSError errorWithDomain:@"com.applovin.ads" code:code userInfo:nil]]; } } @@ -69,7 +69,7 @@ - (void)ad:(ALAd *)ad wasHiddenIn:(UIView *)view - (void)ad:(ALAd *)ad wasClickedIn:(UIView *)view { - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { [_delegate bannerCustomEventDidClick:self]; } } diff --git a/Adapters/AppLovinAdapter/OMAppLovinInterstitial.m b/Adapters/AppLovinAdapter/OMAppLovinInterstitial.m index c2bd7ed..a6e67ad 100644 --- a/Adapters/AppLovinAdapter/OMAppLovinInterstitial.m +++ b/Adapters/AppLovinAdapter/OMAppLovinInterstitial.m @@ -36,7 +36,7 @@ - (BOOL)isReady { } - (void)show:(UIViewController*)vc { - if(self.alAd && _appLovinInterstitial && [_appLovinInterstitial respondsToSelector:@selector(showAd:)]){ + if(self.alAd && _appLovinInterstitial && [_appLovinInterstitial respondsToSelector:@selector(showAd:)]) { [_appLovinInterstitial showAd:self.alAd]; } _ready = NO; diff --git a/Adapters/AppLovinAdapter/OMAppLovinRewardedVideo.m b/Adapters/AppLovinAdapter/OMAppLovinRewardedVideo.m index 397dbfd..0771ac6 100644 --- a/Adapters/AppLovinAdapter/OMAppLovinRewardedVideo.m +++ b/Adapters/AppLovinAdapter/OMAppLovinRewardedVideo.m @@ -36,7 +36,7 @@ - (BOOL)isReady { } - (void)show:(UIViewController*)vc { - if(_alAd && [_alAd respondsToSelector:@selector(showAd:andNotify:)] && _ad){ + if(_alAd && [_alAd respondsToSelector:@selector(showAd:andNotify:)] && _ad) { [_alAd showAd:_ad andNotify:nil]; } } diff --git a/Adapters/ChartboostAdapter/OMChartboostAdapter.m b/Adapters/ChartboostAdapter/OMChartboostAdapter.m index bc5a865..0d77a55 100644 --- a/Adapters/ChartboostAdapter/OMChartboostAdapter.m +++ b/Adapters/ChartboostAdapter/OMChartboostAdapter.m @@ -18,19 +18,6 @@ + (NSString*)adapterVerison { return ChartboostAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"Chartboost"); - if (sdkClass && [sdkClass respondsToSelector:@selector(getSDKVersion)]) { - sdkVersion = [sdkClass getSDKVersion]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"7.2.0"; -} - + (void)setConsent:(BOOL)consent { Class chartboostClass = NSClassFromString(@"Chartboost"); Class CHBGDPRDataUseConsentClass = NSClassFromString(@"CHBGDPRDataUseConsent"); @@ -60,15 +47,7 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.chartboostadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - - if(chartboostClass && [chartboostClass respondsToSelector:@selector(startWithAppId:appSignature:completion:)] && keys.count > 1){ + if(chartboostClass && [chartboostClass respondsToSelector:@selector(startWithAppId:appSignature:completion:)] && keys.count > 1) { [chartboostClass startWithAppId:keys[0] appSignature:keys[1] completion:^(BOOL success) { diff --git a/Adapters/ChartboostAdapter/OMChartboostInterstitial.m b/Adapters/ChartboostAdapter/OMChartboostInterstitial.m index 0167e99..57f7460 100644 --- a/Adapters/ChartboostAdapter/OMChartboostInterstitial.m +++ b/Adapters/ChartboostAdapter/OMChartboostInterstitial.m @@ -23,7 +23,7 @@ - (void)loadAd { - (BOOL)isReady { BOOL isReady = NO; - if(_chbInterstitial && [_chbInterstitial respondsToSelector:@selector(isCached)]){ + if(_chbInterstitial && [_chbInterstitial respondsToSelector:@selector(isCached)]) { isReady = _chbInterstitial.isCached; } return isReady; @@ -31,19 +31,19 @@ - (BOOL)isReady { - (void)show:(UIViewController *)vc { if ([self isReady]) { - if(_chbInterstitial && [_chbInterstitial respondsToSelector:@selector(showFromViewController:)]){ + if(_chbInterstitial && [_chbInterstitial respondsToSelector:@selector(showFromViewController:)]) { [_chbInterstitial showFromViewController:vc]; } } } - (void)didCacheAd:(CHBCacheEvent *)event error:(nullable CHBCacheError *)error{ - if([self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if([self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } if (error) { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.charboost.ads" code:error.code userInfo:@{@"msg":@"There are no ads fill"}]; [_delegate customEvent:self didFailToLoadWithError:cerror]; } @@ -51,15 +51,15 @@ - (void)didCacheAd:(CHBCacheEvent *)event error:(nullable CHBCacheError *)error{ } - (void)didShowAd:(CHBShowEvent *)event error:(nullable CHBShowError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]) { [_delegate interstitialCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]) { [_delegate interstitialCustomEventDidShow:self]; } if (error) { - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.charboost.ads" code:error.code userInfo:@{@"msg":@"The ad failed to show"}]; [_delegate interstitialCustomEventDidFailToShow:self error:cerror]; } @@ -67,13 +67,13 @@ - (void)didShowAd:(CHBShowEvent *)event error:(nullable CHBShowError *)error{ } - (void)didClickAd:(CHBClickEvent *)event error:(nullable CHBClickError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]) { [_delegate interstitialCustomEventDidClick:self]; } } - (void)didDismissAd:(CHBDismissEvent *)event{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]) { [_delegate interstitialCustomEventDidClose:self]; } } diff --git a/Adapters/ChartboostAdapter/OMChartboostRewardedVideo.m b/Adapters/ChartboostAdapter/OMChartboostRewardedVideo.m index c086042..d62f666 100644 --- a/Adapters/ChartboostAdapter/OMChartboostRewardedVideo.m +++ b/Adapters/ChartboostAdapter/OMChartboostRewardedVideo.m @@ -26,7 +26,7 @@ - (void)loadAd { - (BOOL)isReady { BOOL isReady = NO; - if(_chbRewarded && [_chbRewarded respondsToSelector:@selector(isCached)]){ + if(_chbRewarded && [_chbRewarded respondsToSelector:@selector(isCached)]) { isReady = _chbRewarded.isCached; } return isReady; @@ -34,18 +34,18 @@ - (BOOL)isReady { - (void)show:(UIViewController *)vc { if ([self isReady]) { - if(_chbRewarded && [_chbRewarded respondsToSelector:@selector(showFromViewController:)]){ + if(_chbRewarded && [_chbRewarded respondsToSelector:@selector(showFromViewController:)]) { [_chbRewarded showFromViewController:vc]; } } } - (void)didCacheAd:(CHBCacheEvent *)event error:(nullable CHBCacheError *)error{ - if([self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if([self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } - if(error && _delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(error && _delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.charboost.ads" code:error.code userInfo:@{@"msg":@"There are no ads fill"}]; [_delegate customEvent:self didFailToLoadWithError:cerror]; } @@ -53,14 +53,14 @@ - (void)didCacheAd:(CHBCacheEvent *)event error:(nullable CHBCacheError *)error{ - (void)didShowAd:(CHBShowEvent *)event error:(nullable CHBShowError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { [_delegate rewardedVideoCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { [_delegate rewardedVideoCustomEventVideoStart:self]; } - if(error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]){ + if(error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.charboost.ads" code:error.code userInfo:@{@"msg":@"The ad failed to show"}]; [_delegate rewardedVideoCustomEventDidFailToShow:self withError:cerror]; } @@ -69,25 +69,25 @@ - (void)didShowAd:(CHBShowEvent *)event error:(nullable CHBShowError *)error{ } - (void)didClickAd:(CHBClickEvent *)event error:(nullable CHBClickError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { [_delegate rewardedVideoCustomEventDidClick:self]; } } - (void)chartboostVideoEnd { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { [_delegate rewardedVideoCustomEventVideoEnd:self]; } } - (void)didDismissAd:(CHBDismissEvent *)event{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { [_delegate rewardedVideoCustomEventDidClose:self]; } } - (void)didEarnReward:(CHBRewardEvent *)event{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { [_delegate rewardedVideoCustomEventDidReceiveReward:self]; } } diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.h b/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.h index 521fd6f..46d757b 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.h +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.h @@ -1,17 +1,12 @@ -// -// OMChartboostBidAdapter.h -// AdTimingHeliumAdapter -// -// Created by ylm on 2020/6/17. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import #import "OMMediationAdapter.h" #import "OMChartboostBidClass.h" NS_ASSUME_NONNULL_BEGIN -static NSString * const HeliumAdapterVersion = @"3.1.0"; +static NSString * const HeliumAdapterVersion = @"3.1.1"; @interface OMChartboostBidAdapter : NSObject diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.m b/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.m index d817f15..583a533 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.m +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidAdapter.m @@ -1,10 +1,5 @@ -// -// OMChartboostBidAdapter.m -// AdTimingHeliumAdapter -// -// Created by ylm on 2020/6/17. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import "OMChartboostBidAdapter.h" diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidClass.h b/Adapters/ChartboostBidAdapter/OMChartboostBidClass.h index 8238ea5..de34047 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidClass.h +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidClass.h @@ -1,10 +1,5 @@ -// -// OMChartboostBidClass.h -// AdTiming -// -// Created by ylm on 2020/6/18. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #ifndef OMChartboostBidClass_h #define OMChartboostBidClass_h diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.h b/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.h index 65f470d..a06cea9 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.h +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.h @@ -1,10 +1,5 @@ -// -// OMChartboostBidInterstitial.h -// AdTimingHeliumAdapter -// -// Created by ylm on 2020/6/18. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import #import "OMChartboostBidRouter.h" diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.m b/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.m index 3b9421f..4d3cf23 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.m +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidInterstitial.m @@ -1,10 +1,5 @@ -// -// OMChartboostBidInterstitial.m -// AdTimingHeliumAdapter -// -// Created by ylm on 2020/6/18. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import "OMChartboostBidInterstitial.h" @@ -41,11 +36,11 @@ - (void)show:(UIViewController *)vc { - (void)omChartboostBiDdidLoadWithError:(nullable HeliumError *)error { - if(!error && [self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(!error && [self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } else if (error) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.helium.ads" code:error.errorCode userInfo:@{@"msg":error.errorDescription}]; - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:cerror]; } if (_bidDelegate && [_bidDelegate respondsToSelector:@selector(bidReseponse:bid:error:)]) { @@ -56,28 +51,28 @@ - (void)omChartboostBiDdidLoadWithError:(nullable HeliumError *)error { - (void)omChartboostBidDidShowWithError:(HeliumError *)error { if (error) { - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.charboost.bid" code:error.errorCode userInfo:@{@"msg":error.errorDescription}]; [_delegate interstitialCustomEventDidFailToShow:self error:cerror]; } } else { - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]) { [_delegate interstitialCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]) { [_delegate interstitialCustomEventDidShow:self]; } } } - (void)omChartboostBidDidClickWithError:(HeliumError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]) { [_delegate interstitialCustomEventDidClick:self]; } } - (void)omChartboostBidDidCloseWithError:(HeliumError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]) { [_delegate interstitialCustomEventDidClose:self]; } } diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.h b/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.h index 9b6a346..c759c62 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.h +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.h @@ -1,10 +1,5 @@ -// -// OMChartboostBidRewardedVideo.h -// AdTimingHeliumAdapter -// -// Created by ylm on 2020/6/18. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import #import "OMChartboostBidRouter.h" diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.m b/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.m index d68a9e8..97c211c 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.m +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidRewardedVideo.m @@ -1,10 +1,5 @@ -// -// OMChartboostBidRewardedVideo.m -// AdTimingHeliumAdapter -// -// Created by ylm on 2020/6/18. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import "OMChartboostBidRewardedVideo.h" @@ -58,22 +53,22 @@ - (void)omChartboostBiDdidLoadWithError:(nullable HeliumError *)error { - (void)omChartboostBidDidShowWithError:(HeliumError *)error { if (error) { - if(error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]){ + if(error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { NSError *cerror = [[NSError alloc] initWithDomain:@"com.helium.bid" code:error.errorCode userInfo:@{@"msg":@"The ad failed to show"}]; [_delegate rewardedVideoCustomEventDidFailToShow:self withError:cerror]; } } else { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { [_delegate rewardedVideoCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { [_delegate rewardedVideoCustomEventVideoStart:self]; } } } - (void)omChartboostBidDidClickWithError:(HeliumError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { [_delegate rewardedVideoCustomEventDidClick:self]; } @@ -81,17 +76,17 @@ - (void)omChartboostBidDidClickWithError:(HeliumError *)error { - (void)omChartboostBidDidCloseWithError:(HeliumError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { [_delegate rewardedVideoCustomEventVideoEnd:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { [_delegate rewardedVideoCustomEventDidClose:self]; } } - (void)omChartboostBidDidGetReward:(NSInteger)reward { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { [_delegate rewardedVideoCustomEventDidReceiveReward:self]; } } diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.h b/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.h index 1d203c2..409b243 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.h +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.h @@ -1,10 +1,5 @@ -// -// OMChartboostBidRouter.h -// AdTimingChartboostBidAdapter -// -// Created by ylm on 2020/6/30. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import #import "OMChartboostBidClass.h" diff --git a/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.m b/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.m index e29666b..634c06e 100644 --- a/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.m +++ b/Adapters/ChartboostBidAdapter/OMChartboostBidRouter.m @@ -1,10 +1,5 @@ -// -// OMChartboostBidRouter.m -// AdTimingChartboostBidAdapter -// -// Created by ylm on 2020/6/30. -// Copyright © 2020 AdTiming. All rights reserved. -// +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 #import "OMChartboostBidRouter.h" @@ -74,7 +69,7 @@ - (BOOL)isReady:(NSString *)pid { - (void)showAd:(NSString *)pid withVC:(UIViewController*)vc { if ([self isReady:pid]) { id heliumInterstitial = [_placementAdMap objectForKey:pid]; - if(heliumInterstitial && [heliumInterstitial respondsToSelector:@selector(showAdWithViewController:)]){ + if(heliumInterstitial && [heliumInterstitial respondsToSelector:@selector(showAdWithViewController:)]) { [heliumInterstitial showAdWithViewController:vc]; } } diff --git a/Adapters/FacebookAdapter/OMFacebookAdapter.h b/Adapters/FacebookAdapter/OMFacebookAdapter.h index e3814b3..1f4e05b 100644 --- a/Adapters/FacebookAdapter/OMFacebookAdapter.h +++ b/Adapters/FacebookAdapter/OMFacebookAdapter.h @@ -4,7 +4,7 @@ #import #import "OMMediationAdapter.h" -static NSString * const FacebookAdapterVersion = @"3.1.1"; +static NSString * const FacebookAdapterVersion = @"3.1.2"; @interface OMFacebookAdapter : NSObject diff --git a/Adapters/FacebookAdapter/OMFacebookRewardedVideo.m b/Adapters/FacebookAdapter/OMFacebookRewardedVideo.m index b38e7c1..921beac 100644 --- a/Adapters/FacebookAdapter/OMFacebookRewardedVideo.m +++ b/Adapters/FacebookAdapter/OMFacebookRewardedVideo.m @@ -89,6 +89,7 @@ - (void)rewardedVideoAdDidClose:(FBRewardedVideoAd *)rewardedVideoAd { if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { [_delegate rewardedVideoCustomEventDidClose:self]; } + _faceBookPlacement = nil; } @end diff --git a/Adapters/IronSourceAdapter/OMIronSourceAdapter.h b/Adapters/IronSourceAdapter/OMIronSourceAdapter.h index 7a10283..834ecc1 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceAdapter.h +++ b/Adapters/IronSourceAdapter/OMIronSourceAdapter.h @@ -7,9 +7,9 @@ NS_ASSUME_NONNULL_BEGIN -static NSString * const IronSourceAdapterVersion = @"3.1.0"; @interface OMIronSourceAdapter : NSObject +@property (class, nonatomic) BOOL mediationAPI; + (NSString*)adapterVerison; + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler; + (void)setConsent:(BOOL)consent; diff --git a/Adapters/IronSourceAdapter/OMIronSourceAdapter.m b/Adapters/IronSourceAdapter/OMIronSourceAdapter.m index 8f96c68..6348283 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceAdapter.m +++ b/Adapters/IronSourceAdapter/OMIronSourceAdapter.m @@ -3,26 +3,23 @@ #import "OMIronSourceAdapter.h" +static NSString * const IronSourceAdapterVersion = @"3.1.2"; +static BOOL _mediationAPI = NO; + @implementation OMIronSourceAdapter + (NSString *)adapterVerison{ return IronSourceAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"IronSource"); - if (sdkClass && [sdkClass respondsToSelector:@selector(sdkVersion)]) { - sdkVersion = [sdkClass sdkVersion]; - } - return sdkVersion; ++ (BOOL)mediationAPI { + return _mediationAPI; } -+ (NSString*)minimumSupportVersion { - return @"6.15.0"; ++ (void)setMediationAPI:(BOOL)mediationAPI { + _mediationAPI = mediationAPI; } - + (void)setConsent:(BOOL)consent { Class ironsourceClass = NSClassFromString(@"IronSource"); if (ironsourceClass && [ironsourceClass respondsToSelector:@selector(setConsent:)]) { @@ -49,7 +46,7 @@ + (void)setUserGender:(NSInteger)userGender { if (ironsourceClass && [ironsourceClass respondsToSelector:@selector(setGender:)]) { if (userGender == 0) { [ironsourceClass setGender:IRONSOURCE_USER_UNKNOWN]; - }else if (userGender == 1){ + }else if (userGender == 1) { [ironsourceClass setGender:IRONSOURCE_USER_MALE]; }else{ [ironsourceClass setGender:IRONSOURCE_USER_FEMALE]; @@ -68,17 +65,12 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.ironsourceadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - - if(ironsourceClass && [ironsourceClass respondsToSelector:@selector(initISDemandOnly:adUnits:)]){ - [ironsourceClass initISDemandOnly:key adUnits:@[IS_REWARDED_VIDEO,IS_INTERSTITIAL]]; - //[ironsourceClass initWithAppKey:key adUnits:@[IS_BANNER]]; // Banner + if(ironsourceClass && [ironsourceClass respondsToSelector:@selector(initISDemandOnly:adUnits:)]) { + if ([OMIronSourceAdapter mediationAPI]) { + [ironsourceClass initWithAppKey:key adUnits:@[IS_BANNER,IS_REWARDED_VIDEO,IS_INTERSTITIAL]]; + } else { + [ironsourceClass initISDemandOnly:key adUnits:@[IS_REWARDED_VIDEO,IS_INTERSTITIAL]]; + } completionHandler(nil); }else{ NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.ironsourceadapter" diff --git a/Adapters/IronSourceAdapter/OMIronSourceBanner.m b/Adapters/IronSourceAdapter/OMIronSourceBanner.m index 03fcc5e..aa052b8 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceBanner.m +++ b/Adapters/IronSourceAdapter/OMIronSourceBanner.m @@ -9,7 +9,6 @@ - (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParame if (self = [super initWithFrame:frame]) { Class IronSourceClass = NSClassFromString(@"IronSource"); if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(initWithAppKey:)] && [IronSourceClass respondsToSelector:@selector(setBannerDelegate:)]) { - [IronSourceClass initWithAppKey:[adParameter objectForKey:@"appKey"]]; [IronSourceClass setBannerDelegate:self]; self.showVC = rootViewController; } @@ -21,10 +20,8 @@ - (void)loadAd{ dispatch_async(dispatch_get_main_queue(), ^{ Class IronSourceClass = NSClassFromString(@"IronSource"); - if (self.bannerView) { [IronSourceClass destroyBanner:self.bannerView]; self.bannerView = nil; - } if (self.showVC && IronSourceClass && [IronSourceClass respondsToSelector:@selector(loadBannerWithViewController:size:)]) { [IronSourceClass loadBannerWithViewController:self.showVC size:[self convertWithSize:self.frame.size]]; } @@ -55,20 +52,20 @@ - (void)bannerDidLoad:(ISBannerView *)bannerView { [self addSubview:self.bannerView]; }); - if(self.delegate && [self.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(self.delegate && [self.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [self.delegate customEvent:self didLoadAd:nil]; } } - (void)bannerDidFailToLoadWithError:(NSError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:error]; } } - (void)didClickBanner { - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { [_delegate bannerCustomEventDidClick:self]; } } diff --git a/Adapters/IronSourceAdapter/OMIronSourceClass.h b/Adapters/IronSourceAdapter/OMIronSourceClass.h index de56575..fa45c25 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceClass.h +++ b/Adapters/IronSourceAdapter/OMIronSourceClass.h @@ -11,15 +11,25 @@ NS_ASSUME_NONNULL_BEGIN @class ISSegment; @class ISPlacementInfo; -#define ISBannerSize_BANNER [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:@"BANNER"] -#define ISBannerSize_LARGE [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:@"LARGE"] -#define ISBannerSize_RECTANGLE [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:@"RECTANGLE"] -#define ISBannerSize_SMART [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:@"SMART"] +static NSString * const kSizeBanner = @"BANNER"; +static NSString * const kSizeLarge = @"LARGE"; +static NSString * const kSizeRectangle = @"RECTANGLE"; +static NSString * const kSizeLeaderboard = @"LEADERBOARD"; +static NSString * const kSizeSmart = @"SMART"; +static NSString * const kSizeCustom = @"CUSTOM"; + +#define ISBannerSize_BANNER [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:kSizeBanner width:320 height:50] +#define ISBannerSize_LARGE [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:kSizeLarge width:320 height:90] +#define ISBannerSize_RECTANGLE [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:kSizeRectangle width:300 height:250] +#define ISBannerSize_SMART [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:kSizeSmart width:0 height:0] @interface ISBannerSize : NSObject +#define ISBannerSize_LEADERBOARD [[NSClassFromString(@"ISBannerSize") alloc] initWithDescription:kSizeSmart width:728 height:90] + - (instancetype)initWithWidth:(NSInteger)width andHeight:(NSInteger)height; -- (instancetype)initWithDescription:(NSString *)description; +- (instancetype)initWithDescription:(NSString *)description width:(NSInteger)width height:(NSInteger)height; +- (BOOL)isSmart; @property (readonly) NSString* sizeDescription; @property (readonly) NSInteger width; @@ -27,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN @end +static NSString * const kBannerWillMoveToSuperView = @"ISBANNER_WILL_MOVE_TO_SUPERVIEW"; + @interface ISBannerView : UIView { } diff --git a/Adapters/IronSourceAdapter/OMIronSourceInterstitial.h b/Adapters/IronSourceAdapter/OMIronSourceInterstitial.h index 4080328..3e01060 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceInterstitial.h +++ b/Adapters/IronSourceAdapter/OMIronSourceInterstitial.h @@ -7,10 +7,9 @@ NS_ASSUME_NONNULL_BEGIN -@interface OMIronSourceInterstitial : NSObject +@interface OMIronSourceInterstitial : NSObject @property (nonatomic, copy) NSString *pid; -@property (nonatomic, copy) NSString *appID; @property (nonatomic, weak) id delegate; - (instancetype)initWithParameter:(NSDictionary*)adParameter; diff --git a/Adapters/IronSourceAdapter/OMIronSourceInterstitial.m b/Adapters/IronSourceAdapter/OMIronSourceInterstitial.m index 58c0aa8..9efe8e7 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceInterstitial.m +++ b/Adapters/IronSourceAdapter/OMIronSourceInterstitial.m @@ -1,6 +1,7 @@ // Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED // Licensed under the GNU Lesser General Public License Version 3 +#import "OMIronSourceAdapter.h" #import "OMIronSourceInterstitial.h" @implementation OMIronSourceInterstitial @@ -8,10 +9,17 @@ @implementation OMIronSourceInterstitial - (instancetype)initWithParameter:(NSDictionary*)adParameter { if (self = [super init]) { - if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]){ + if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { _pid = [adParameter objectForKey:@"pid"]; - _appID = @""; - [[OMIronSourceRouter sharedInstance] registerPidDelegate:_pid delegate:self]; + if ([OMIronSourceAdapter mediationAPI]) { + Class IronSourceClass = NSClassFromString(@"IronSource"); + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(setInterstitialDelegate:)]) { + [IronSourceClass setInterstitialDelegate:self]; + } + } else { + [[OMIronSourceRouter sharedInstance] registerPidDelegate:_pid delegate:self]; + } + } } return self; @@ -20,59 +28,83 @@ - (instancetype)initWithParameter:(NSDictionary*)adParameter -(void)loadAd { Class IronSourceClass = NSClassFromString(@"IronSource"); - if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(loadISDemandOnlyInterstitial:)]){ - [IronSourceClass loadISDemandOnlyInterstitial:_pid]; + if ([OMIronSourceAdapter mediationAPI]) { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(loadInterstitial)]) { + [IronSourceClass loadInterstitial]; + } + } else { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(loadISDemandOnlyInterstitial:)]) { + [IronSourceClass loadISDemandOnlyInterstitial:_pid]; + } } + } -(BOOL)isReady { BOOL isReady = NO; Class IronSourceClass = NSClassFromString(@"IronSource"); - if(IronSourceClass && [IronSourceClass respondsToSelector:@selector(hasISDemandOnlyInterstitial:)]){ - isReady = [IronSourceClass hasISDemandOnlyInterstitial:_pid]; + if ([OMIronSourceAdapter mediationAPI]) { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(hasInterstitial)]) { + isReady = [IronSourceClass hasInterstitial]; + } + } else { + if(IronSourceClass && [IronSourceClass respondsToSelector:@selector(hasISDemandOnlyInterstitial:)]) { + isReady = [IronSourceClass hasISDemandOnlyInterstitial:_pid]; + } } + return isReady; } - (void)show:(UIViewController *)vc { Class IronSourceClass = NSClassFromString(@"IronSource"); - if ([self isReady] && IronSourceClass && [IronSourceClass respondsToSelector:@selector(showISDemandOnlyInterstitial:instanceId:)]) { - [IronSourceClass showISDemandOnlyInterstitial:vc instanceId:_pid]; + if ([self isReady]) { + if ([OMIronSourceAdapter mediationAPI]) { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(showInterstitialWithViewController:placement:)]) { + [IronSourceClass showInterstitialWithViewController:vc placement:_pid]; + } + } else { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(showISDemandOnlyInterstitial:instanceId:)]) { + [IronSourceClass showISDemandOnlyInterstitial:vc instanceId:_pid]; + } + } + } } +#pragma mark - DemandOnlyEvent - (void)OMIronSourceDidload { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } } - (void)OMIronSourceDidFailToLoad:(nonnull NSError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:error]; } } - (void)OMIronSourceDidStart { - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]) { [_delegate interstitialCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]) { [_delegate interstitialCustomEventDidShow:self]; } } - (void)OMIronSourceDidClick{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]) { [_delegate interstitialCustomEventDidClick:self]; } } - (void)OMIronSourceDidFinish{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]) { [_delegate interstitialCustomEventDidClose:self]; } } @@ -87,10 +119,52 @@ - (void)OMIronSourceVideoEnd { } - (void)OMIronSourceDidFailToShow:(NSError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]) { [_delegate interstitialCustomEventDidFailToShow:self error:error]; } } +#pragma mark - ISInterstitialDelegate + +-(void)interstitialDidLoad { + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [_delegate customEvent:self didLoadAd:nil]; + } +} + +-(void)interstitialDidShow { + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]) { + [_delegate interstitialCustomEventDidShow:self]; + } +} +-(void)interstitialDidFailToShowWithError:(NSError *)error { + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]) { + [_delegate interstitialCustomEventDidFailToShow:self error:error]; + } +} + +-(void)didClickInterstitial { + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]) { + [_delegate interstitialCustomEventDidClick:self]; + } +} + +-(void)interstitialDidClose { + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]) { + [_delegate interstitialCustomEventDidClose:self]; + } +} + +-(void)interstitialDidOpen { + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]) { + [_delegate interstitialCustomEventDidOpen:self]; + } +} + +-(void)interstitialDidFailToLoadWithError:(NSError *)error { + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [_delegate customEvent:self didFailToLoadWithError:error]; + } +} @end diff --git a/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.h b/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.h index 9524e5d..665bd6a 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.h +++ b/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.h @@ -7,9 +7,8 @@ NS_ASSUME_NONNULL_BEGIN -@interface OMIronSourceRewardedVideo : NSObject +@interface OMIronSourceRewardedVideo : NSObject @property (nonatomic, copy) NSString *pid; -@property (nonatomic, copy) NSString *appID; @property (nonatomic, weak) id delegate; - (instancetype)initWithParameter:(NSDictionary*)adParameter; diff --git a/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.m b/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.m index 8ceb017..8639384 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.m +++ b/Adapters/IronSourceAdapter/OMIronSourceRewardedVideo.m @@ -8,10 +8,16 @@ @implementation OMIronSourceRewardedVideo - (instancetype)initWithParameter:(NSDictionary*)adParameter { if (self = [super init]) { - if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]){ + if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { _pid = [adParameter objectForKey:@"pid"]; - _appID = @""; - [[OMIronSourceRouter sharedInstance] registerPidDelegate:_pid delegate:self]; + if ([OMIronSourceAdapter mediationAPI]) { + Class IronSourceClass = NSClassFromString(@"IronSource"); + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(setRewardedVideoDelegate:)]) { + [IronSourceClass setRewardedVideoDelegate:self]; + } + } else { + [[OMIronSourceRouter sharedInstance] registerPidDelegate:_pid delegate:self]; + } } } return self; @@ -19,80 +25,159 @@ - (instancetype)initWithParameter:(NSDictionary*)adParameter -(void)loadAd { - Class IronSourceClass = NSClassFromString(@"IronSource"); - if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(loadISDemandOnlyRewardedVideo:)]){ - [IronSourceClass loadISDemandOnlyRewardedVideo:_pid]; + if ([OMIronSourceAdapter mediationAPI]) { + if ([self isReady]) { + [self rewardedVideoHasChangedAvailability:YES]; + } + } else { + Class IronSourceClass = NSClassFromString(@"IronSource"); + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(loadISDemandOnlyRewardedVideo:)]) { + [IronSourceClass loadISDemandOnlyRewardedVideo:_pid]; + } } + } -(BOOL)isReady { BOOL isReady = NO; Class IronSourceClass = NSClassFromString(@"IronSource"); - if(IronSourceClass && [IronSourceClass respondsToSelector:@selector(hasISDemandOnlyRewardedVideo:)]){ - isReady = [IronSourceClass hasISDemandOnlyRewardedVideo:_pid]; + if ([OMIronSourceAdapter mediationAPI]) { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(hasRewardedVideo)]) { + isReady = [IronSourceClass hasRewardedVideo]; + } + } else { + if(IronSourceClass && [IronSourceClass respondsToSelector:@selector(hasISDemandOnlyRewardedVideo:)]) { + isReady = [IronSourceClass hasISDemandOnlyRewardedVideo:_pid]; + } } + return isReady; } - (void)show:(UIViewController *)vc { Class IronSourceClass = NSClassFromString(@"IronSource"); - if ([self isReady] && IronSourceClass && [IronSourceClass respondsToSelector:@selector(showISDemandOnlyRewardedVideo:instanceId:)]) { - [IronSourceClass showISDemandOnlyRewardedVideo:vc instanceId:_pid]; + if ([self isReady]) { + if ([OMIronSourceAdapter mediationAPI]) { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(showRewardedVideoWithViewController:placement:)]) { + [IronSourceClass showRewardedVideoWithViewController:vc placement:_pid]; + } + } else if (![OMIronSourceAdapter mediationAPI]) { + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(showISDemandOnlyRewardedVideo:instanceId:)]) { + [IronSourceClass showISDemandOnlyRewardedVideo:vc instanceId:_pid]; + } + } } } +#pragma mark - DemandOnlyEvent - (void)OMIronSourceDidload { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } } - (void)OMIronSourceDidFailToLoad:(nonnull NSError *)error { - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:error]; } } - (void)OMIronSourceDidStart { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { [_delegate rewardedVideoCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { [_delegate rewardedVideoCustomEventVideoStart:self]; } } - (void)OMIronSourceDidClick{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { [_delegate rewardedVideoCustomEventDidClick:self]; } } - (void)OMIronSourceVideoEnd { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { [_delegate rewardedVideoCustomEventVideoEnd:self]; } } - (void)OMIronSourceDidReceiveReward { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { [_delegate rewardedVideoCustomEventDidReceiveReward:self]; } } - (void)OMIronSourceDidFinish { - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { [_delegate rewardedVideoCustomEventDidClose:self]; } } - (void)OMIronSourceDidFailToShow:(NSError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { [_delegate rewardedVideoCustomEventDidFailToShow:self withError:error]; } } +#pragma mark - ISRewardedVideoDelegate + +- (void)rewardedVideoHasChangedAvailability:(BOOL)available { + if (available) { + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [_delegate customEvent:self didLoadAd:nil]; + } + } +} + +- (void)didReceiveRewardForPlacement:(ISPlacementInfo *)placementInfo { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { + [_delegate rewardedVideoCustomEventDidReceiveReward:self]; + } +} + +- (void)rewardedVideoDidFailToShowWithError:(NSError *)error { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { + [_delegate rewardedVideoCustomEventDidFailToShow:self withError:error]; + } +} + +- (void)rewardedVideoDidOpen { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { + [_delegate rewardedVideoCustomEventDidOpen:self]; + } + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { + [_delegate rewardedVideoCustomEventVideoStart:self]; + } + +} + +- (void)rewardedVideoDidClose { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { + [_delegate rewardedVideoCustomEventVideoEnd:self]; + } + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { + [_delegate rewardedVideoCustomEventDidClose:self]; + } +} + +- (void)didClickRewardedVideo:(ISPlacementInfo *)placementInfo{ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { + [_delegate rewardedVideoCustomEventDidClick:self]; + } +} + +- (void)rewardedVideoDidStart { + +} + +- (void)rewardedVideoDidEnd { + +} + + @end diff --git a/Adapters/IronSourceAdapter/OMIronSourceRouter.m b/Adapters/IronSourceAdapter/OMIronSourceRouter.m index f9e7caa..c095fd9 100644 --- a/Adapters/IronSourceAdapter/OMIronSourceRouter.m +++ b/Adapters/IronSourceAdapter/OMIronSourceRouter.m @@ -17,7 +17,7 @@ + (instancetype)sharedInstance{ - (instancetype)init{ if (self = [super init]) { Class IronSourceClass = NSClassFromString(@"IronSource"); - if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(setISDemandOnlyInterstitialDelegate:)] && [IronSourceClass respondsToSelector:@selector(setISDemandOnlyRewardedVideoDelegate:)]){ + if (IronSourceClass && [IronSourceClass respondsToSelector:@selector(setISDemandOnlyInterstitialDelegate:)] && [IronSourceClass respondsToSelector:@selector(setISDemandOnlyRewardedVideoDelegate:)]) { [IronSourceClass setISDemandOnlyInterstitialDelegate:self]; [IronSourceClass setISDemandOnlyRewardedVideoDelegate:self]; } @@ -38,7 +38,7 @@ - (void)registerPidDelegate:(NSString*)pid delegate:(id)delegate { */ - (void)interstitialDidLoad:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidload)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidload)]) { [delegate OMIronSourceDidload]; } } @@ -50,7 +50,7 @@ - (void)interstitialDidLoad:(NSString *)instanceId{ */ - (void)interstitialDidFailToLoadWithError:(NSError *)error instanceId:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToLoad:)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToLoad:)]) { [delegate OMIronSourceDidFailToLoad:error]; } } @@ -60,7 +60,7 @@ - (void)interstitialDidFailToLoadWithError:(NSError *)error instanceId:(NSString */ - (void)interstitialDidOpen:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidStart)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidStart)]) { [delegate OMIronSourceDidStart]; } } @@ -70,7 +70,7 @@ - (void)interstitialDidOpen:(NSString *)instanceId{ */ - (void)interstitialDidClose:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFinish)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFinish)]) { [delegate OMIronSourceDidFinish]; } } @@ -82,7 +82,7 @@ - (void)interstitialDidClose:(NSString *)instanceId{ */ - (void)interstitialDidFailToShowWithError:(NSError *)error instanceId:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToShow:)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToShow:)]) { [delegate OMIronSourceDidFailToShow:error]; } } @@ -92,7 +92,7 @@ - (void)interstitialDidFailToShowWithError:(NSError *)error instanceId:(NSString */ - (void)didClickInterstitial:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidClick)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidClick)]) { [delegate OMIronSourceDidClick]; } } @@ -102,52 +102,52 @@ - (void)didClickInterstitial:(NSString *)instanceId{ - (void)rewardedVideoDidLoad:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidload)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidload)]) { [delegate OMIronSourceDidload]; } } - (void)rewardedVideoDidFailToLoadWithError:(NSError *)error instanceId:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToLoad:)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToLoad:)]) { [delegate OMIronSourceDidFailToLoad:error]; } } - (void)rewardedVideoDidOpen:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidStart)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidStart)]) { [delegate OMIronSourceDidStart]; } } - (void)rewardedVideoDidClose:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceVideoEnd)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceVideoEnd)]) { [delegate OMIronSourceVideoEnd]; } - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFinish)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFinish)]) { [delegate OMIronSourceDidFinish]; } } - (void)rewardedVideoDidFailToShowWithError:(NSError *)error instanceId:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToShow:)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidFailToShow:)]) { [delegate OMIronSourceDidFailToShow:error]; } } - (void)rewardedVideoDidClick:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidClick)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidClick)]) { [delegate OMIronSourceDidClick]; } } - (void)rewardedVideoAdRewarded:(NSString *)instanceId{ id delegate = [_placementDelegateMap objectForKey:instanceId]; - if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidReceiveReward)]){ + if(delegate && [delegate respondsToSelector:@selector(OMIronSourceDidReceiveReward)]) { [delegate OMIronSourceDidReceiveReward]; } } diff --git a/Adapters/MintegralAdapter/OMMintegralInterstitial.h b/Adapters/MintegralAdapter/OMMintegralInterstitial.h index 209ec34..f33bb1b 100644 --- a/Adapters/MintegralAdapter/OMMintegralInterstitial.h +++ b/Adapters/MintegralAdapter/OMMintegralInterstitial.h @@ -11,7 +11,6 @@ NS_ASSUME_NONNULL_BEGIN @interface OMMintegralInterstitial : NSObject @property (nonatomic, copy) NSString *pid; -@property (nonatomic, copy) NSString *appID; @property (nonatomic, strong) MTGInterstitialVideoAdManager *ivAdManager; @property (nonatomic, strong) MTGBidInterstitialVideoAdManager *ivBidAdManager; @property (nonatomic, weak) id delegate; diff --git a/Adapters/MintegralAdapter/OMMintegralInterstitial.m b/Adapters/MintegralAdapter/OMMintegralInterstitial.m index 42cf658..a1046e3 100644 --- a/Adapters/MintegralAdapter/OMMintegralInterstitial.m +++ b/Adapters/MintegralAdapter/OMMintegralInterstitial.m @@ -9,7 +9,6 @@ - (instancetype)initWithParameter:(NSDictionary*)adParameter { if (self = [super init]) { if (adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { _pid = [adParameter objectForKey:@"pid"]; - _appID = @""; } } return self; @@ -40,7 +39,7 @@ - (void)loadAdWithBidPayload:(NSString *)bidPayload { -(BOOL)isReady { if (_ivAdManager) { return [_ivAdManager isVideoReadyToPlayWithPlacementId:@"" unitId:_pid]; - }else if (_ivBidAdManager){ + }else if (_ivBidAdManager) { return [_ivBidAdManager isVideoReadyToPlayWithPlacementId:@"" unitId:_pid]; } return NO; @@ -49,7 +48,7 @@ -(BOOL)isReady { - (void)show:(UIViewController *)vc { if (_ivAdManager && [self isReady]) { [_ivAdManager showFromViewController:vc]; - }else if (_ivBidAdManager && [self isReady]){ + }else if (_ivBidAdManager && [self isReady]) { [_ivBidAdManager showFromViewController:vc]; } } diff --git a/Adapters/MintegralAdapter/OMMintegralRewardedVideo.m b/Adapters/MintegralAdapter/OMMintegralRewardedVideo.m index 0dbcabf..4024c4a 100644 --- a/Adapters/MintegralAdapter/OMMintegralRewardedVideo.m +++ b/Adapters/MintegralAdapter/OMMintegralRewardedVideo.m @@ -55,6 +55,7 @@ - (void)omMintegralDidReceiveReward { } - (void)omMintegralDidload { + NSLog(@"mintegral %@ did load",self.pid); if ([self isReady] && _delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } diff --git a/Adapters/MintegralAdapter/OMMintegralRouter.m b/Adapters/MintegralAdapter/OMMintegralRouter.m index 713e10a..19427a7 100644 --- a/Adapters/MintegralAdapter/OMMintegralRouter.m +++ b/Adapters/MintegralAdapter/OMMintegralRouter.m @@ -58,7 +58,11 @@ - (BOOL)isReady:(NSString *)pid { BOOL isReady = NO; if (_mintegralSDK && [_mintegralSDK respondsToSelector:@selector(isVideoReadyToPlayWithPlacementId:unitId:)]) { isReady = [_mintegralSDK isVideoReadyToPlayWithPlacementId:@"" unitId:pid]; + NSLog(@"mintegral %@ ready %zd",pid,(NSInteger)isReady); } +// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{ +// NSLog(@"call test %zd",(NSInteger)[self isReady:pid]); +// }); return isReady; } diff --git a/Adapters/MoPubAdapter/OMMopubAdapter.h b/Adapters/MoPubAdapter/OMMopubAdapter.h index 7cb1fd2..7ab9277 100644 --- a/Adapters/MoPubAdapter/OMMopubAdapter.h +++ b/Adapters/MoPubAdapter/OMMopubAdapter.h @@ -6,7 +6,7 @@ #import "OMMediationAdapter.h" #import "OMMopubClass.h" -static NSString * const MopubAdapterVersion = @"3.1.0"; +static NSString * const MopubAdapterVersion = @"3.1.2"; @interface OMMopubAdapter : NSObject diff --git a/Adapters/MoPubAdapter/OMMopubAdapter.m b/Adapters/MoPubAdapter/OMMopubAdapter.m index a01c1a3..d7d5506 100644 --- a/Adapters/MoPubAdapter/OMMopubAdapter.m +++ b/Adapters/MoPubAdapter/OMMopubAdapter.m @@ -10,23 +10,6 @@ + (NSString*)adapterVerison { return MopubAdapterVersion; } - -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"MoPub"); - if (sdkClass && [sdkClass respondsToSelector:@selector(sharedInstance)]) { - MoPub *mopub = [sdkClass sharedInstance]; - if ([mopub respondsToSelector:@selector(version)]) { - sdkVersion = [mopub version]; - } - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"5.5.0"; -} - + (void)setConsent:(BOOL)consent { Class MoPubClass = NSClassFromString(@"MoPub"); @@ -51,16 +34,7 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler completionHandler(error); return; } - - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.mopubadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - - + if ([pids count]>0 && MPConfigClass && [MPConfigClass instancesRespondToSelector:@selector(initWithAdUnitIdForAppInitialization:)] && MoPubClass && [MoPubClass instancesRespondToSelector:@selector(initializeSdkWithConfiguration:completion:)] ) { NSString *pid = pids[0]; diff --git a/Adapters/MoPubAdapter/OMMopubBanner.m b/Adapters/MoPubAdapter/OMMopubBanner.m index 94257a1..4d81bbe 100644 --- a/Adapters/MoPubAdapter/OMMopubBanner.m +++ b/Adapters/MoPubAdapter/OMMopubBanner.m @@ -59,22 +59,22 @@ - (void)adView:(MPAdView *)view didFailToLoadAdWithError:(NSError *)error { } - (void)willLeaveApplicationFromAd:(MPAdView *)view { - if (self.delegate && [self.delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { - [self.delegate bannerCustomEventDidClick:self]; - } - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillLeaveApplication:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillLeaveApplication:)]) { [_delegate bannerCustomEventWillLeaveApplication:self]; } } - (void)willPresentModalViewForAd:(MPAdView *)view { - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]) { [_delegate bannerCustomEventWillPresentScreen:self]; }; } - (void)didDismissModalViewForAd:(MPAdView *)view { - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDismissScreen:)]){ + if (self.delegate && [self.delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { + [self.delegate bannerCustomEventDidClick:self]; + } + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDismissScreen:)]) { [_delegate bannerCustomEventDismissScreen:self]; } } diff --git a/Adapters/MoPubAdapter/OMMopubNativeView.m b/Adapters/MoPubAdapter/OMMopubNativeView.m index d4e0661..ea492c8 100644 --- a/Adapters/MoPubAdapter/OMMopubNativeView.m +++ b/Adapters/MoPubAdapter/OMMopubNativeView.m @@ -6,7 +6,7 @@ @implementation OMMopubNativeView - (instancetype)initWithFrame:(CGRect)frame { - if(self = [super initWithFrame:frame]){ + if(self = [super initWithFrame:frame]) { _mediaView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)]; [self addGestureRecognizer:tap]; diff --git a/Adapters/MoPubAdapter/OMMopubRewardedVideo.m b/Adapters/MoPubAdapter/OMMopubRewardedVideo.m index 883f029..9c34f29 100644 --- a/Adapters/MoPubAdapter/OMMopubRewardedVideo.m +++ b/Adapters/MoPubAdapter/OMMopubRewardedVideo.m @@ -34,8 +34,8 @@ - (BOOL)isReady { - (void)show:(UIViewController*)vc { Class mopubClass = NSClassFromString(@"MPRewardedVideo"); - if (mopubClass && [mopubClass respondsToSelector:@selector(presentRewardedVideoAdForAdUnitID:fromViewController:withReward:)]) { - [mopubClass presentRewardedVideoAdForAdUnitID:_pid fromViewController:vc withReward:nil]; + if (mopubClass && [mopubClass respondsToSelector:@selector(presentRewardedVideoAdForAdUnitID:fromViewController:withReward:)] && [mopubClass respondsToSelector:@selector(availableRewardsForAdUnitID:)]) { + [mopubClass presentRewardedVideoAdForAdUnitID:_pid fromViewController:vc withReward:[mopubClass availableRewardsForAdUnitID:_pid][0]]; } } diff --git a/Adapters/MyTargetAdapter/OMMyTargetAdapter.m b/Adapters/MyTargetAdapter/OMMyTargetAdapter.m index 58d8c9a..6ff0c84 100644 --- a/Adapters/MyTargetAdapter/OMMyTargetAdapter.m +++ b/Adapters/MyTargetAdapter/OMMyTargetAdapter.m @@ -27,20 +27,6 @@ + (NSString*)adapterVerison{ return MyTargetAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"MTRGVersion"); - if (sdkClass && [sdkClass respondsToSelector:@selector(currentVersion)]) { - sdkVersion = [sdkClass currentVersion]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"5.4.8"; -} - - + (void)setConsent:(BOOL)consent { Class privacyClass = NSClassFromString(@"MTRGPrivacy"); if (privacyClass && [privacyClass respondsToSelector:@selector(setConsent:)]) { @@ -75,14 +61,6 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler completionHandler(error); return; } - - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.mytargetadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } completionHandler(nil); } diff --git a/Adapters/TapjoyAdapter/OMTapjoyAdapter.m b/Adapters/TapjoyAdapter/OMTapjoyAdapter.m index f1fe173..3475bcc 100644 --- a/Adapters/TapjoyAdapter/OMTapjoyAdapter.m +++ b/Adapters/TapjoyAdapter/OMTapjoyAdapter.m @@ -11,19 +11,6 @@ + (NSString*)adapterVerison { return TapjoyAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"Tapjoy"); - if (sdkClass && [sdkClass respondsToSelector:@selector(getVersion)]) { - sdkVersion = [sdkClass getVersion]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"7.2.0"; -} - + (void)setConsent:(BOOL)consent { id tapjoySDK; Class tapjoyClass = NSClassFromString(@"TJPrivacyPolicy"); @@ -62,20 +49,12 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.tapjoyadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tjcConnectSuccess:) name:TJC_CONNECT_SUCCESS object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tjcConnectSuccess:) name:TJC_LIMITED_CONNECT_SUCCESS object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tjcConnectFailed:) name:TJC_CONNECT_FAILED object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tjcConnectFailed:) name:TJC_LIMITED_CONNECT_FAILED object:nil]; - if(tapjoyClass && [tapjoyClass respondsToSelector:@selector(limitedConnect:)] && [key length]>0){ + if(tapjoyClass && [tapjoyClass respondsToSelector:@selector(limitedConnect:)] && [key length]>0) { [tapjoyClass limitedConnect:key]; } else if (tapjoyClass && [tapjoyClass respondsToSelector:@selector(connect:)] && [key length]>0) { [tapjoyClass connect:key];; @@ -88,14 +67,14 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler } +(void)tjcConnectSuccess:(NSNotification*)notifyObj{ - if([OMTapjoyAdapter sharedInstance].initBlock){ + if([OMTapjoyAdapter sharedInstance].initBlock) { [OMTapjoyAdapter sharedInstance].initBlock(nil); [OMTapjoyAdapter sharedInstance].initBlock = nil; } } +(void)tjcConnectFailed:(NSNotification*)notifyObj{ - if([OMTapjoyAdapter sharedInstance].initBlock){ + if([OMTapjoyAdapter sharedInstance].initBlock) { NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.tapjoyadapter" code:101 userInfo:@{NSLocalizedDescriptionKey:@"Init failed"}]; diff --git a/Adapters/TencentAdAdapter/OMTencentAdAdapter.m b/Adapters/TencentAdAdapter/OMTencentAdAdapter.m index 5c609f7..41424c3 100644 --- a/Adapters/TencentAdAdapter/OMTencentAdAdapter.m +++ b/Adapters/TencentAdAdapter/OMTencentAdAdapter.m @@ -9,20 +9,6 @@ + (NSString*)adapterVerison { return GdtAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"GDTSDKConfig"); - if (sdkClass && [sdkClass respondsToSelector:@selector(sdkVersion)]) { - sdkVersion = [sdkClass sdkVersion]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"4.11.4"; -} - - + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler { Class gdtClass = NSClassFromString(@"GDTSDKConfig"); @@ -34,14 +20,6 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.gdtadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - NSString *key = [configuration objectForKey:@"appKey"]; if (gdtClass && [gdtClass respondsToSelector:@selector(registerAppId:)] && [key length]>0) { [gdtClass registerAppId:key]; diff --git a/Adapters/TencentAdAdapter/OMTencentAdBanner.m b/Adapters/TencentAdAdapter/OMTencentAdBanner.m index 7ce8ca0..19feab3 100644 --- a/Adapters/TencentAdAdapter/OMTencentAdBanner.m +++ b/Adapters/TencentAdAdapter/OMTencentAdBanner.m @@ -6,7 +6,7 @@ @implementation OMTencentAdBanner - (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParameter rootViewController:(UIViewController *)rootViewController{ - if(self = [super initWithFrame:frame]){ + if(self = [super initWithFrame:frame]) { Class gdtClass = NSClassFromString(@"GDTUnifiedBannerView"); if (gdtClass && adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { _gdtBannerView = [[gdtClass alloc] initWithFrame:[self convertWithFrame:frame] placementId:([adParameter objectForKey:@"pid"]?[adParameter objectForKey:@"pid"]:@"") viewController:rootViewController]; @@ -29,25 +29,25 @@ - (void)loadAd{ } - (void)unifiedBannerViewDidLoad:(GDTUnifiedBannerView *)unifiedBannerView{ - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } } - (void)unifiedBannerViewFailedToLoad:(GDTUnifiedBannerView *)unifiedBannerView error:(NSError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:error]; } } - (void)unifiedBannerViewWillExpose:(GDTUnifiedBannerView *)unifiedBannerView{ - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]) { [_delegate bannerCustomEventWillPresentScreen:self]; } } - (void)unifiedBannerViewClicked:(GDTUnifiedBannerView *)unifiedBannerView{ - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { [_delegate bannerCustomEventDidClick:self]; } } diff --git a/Adapters/TencentAdAdapter/OMTencentAdInterstitial.m b/Adapters/TencentAdAdapter/OMTencentAdInterstitial.m index bffec39..00621cb 100644 --- a/Adapters/TencentAdAdapter/OMTencentAdInterstitial.m +++ b/Adapters/TencentAdAdapter/OMTencentAdInterstitial.m @@ -9,7 +9,7 @@ @implementation OMTencentAdInterstitial - (instancetype)initWithParameter:(NSDictionary*)adParameter { if (self = [super init]) { - if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]){ + if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { _pid = [adParameter objectForKey:@"pid"]; _appID = [adParameter objectForKey:@"appKey"]; } @@ -66,23 +66,23 @@ - (void)unifiedInterstitialWillPresentScreen:(GDTUnifiedInterstitialAd *)unified } - (void)unifiedInterstitialDidPresentScreen:(GDTUnifiedInterstitialAd *)unifiedInterstitial{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]) { [_delegate interstitialCustomEventDidOpen:self]; } - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]) { [_delegate interstitialCustomEventDidShow:self]; } } - (void)unifiedInterstitialFailToPresent:(GDTUnifiedInterstitialAd *)unifiedInterstitial error:(NSError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]) { [_delegate interstitialCustomEventDidFailToShow:self error:error]; } } - (void)unifiedInterstitialDidDismissScreen:(GDTUnifiedInterstitialAd *)unifiedInterstitial{ // 广告结束 - if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]) { [_delegate interstitialCustomEventDidClose:self]; } } diff --git a/Adapters/TencentAdAdapter/OMTencentAdNative.m b/Adapters/TencentAdAdapter/OMTencentAdNative.m index b98111e..0912326 100644 --- a/Adapters/TencentAdAdapter/OMTencentAdNative.m +++ b/Adapters/TencentAdAdapter/OMTencentAdNative.m @@ -21,7 +21,7 @@ - (instancetype)initWithParameter:(NSDictionary*)adParameter rootVC:(UIViewContr - (void)loadAd{ - if(_gdtNativeAd){ + if(_gdtNativeAd) { [_gdtNativeAd loadAdWithAdCount:1]; } } @@ -33,12 +33,12 @@ - (void)gdt_unifiedNativeAdLoaded:(NSArray * _Nu weakSelf.currentAdData = unifiedNativeAdDataObjects[0]; OMTencentAdNativeAd *gdtNativeAd = [[OMTencentAdNativeAd alloc] initWithGdtDataObject:unifiedNativeAdDataObjects[0]]; gdtNativeAd.adLoader = self; - if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [weakSelf.delegate customEvent:weakSelf didLoadAd:gdtNativeAd]; } }else{ dispatch_async(dispatch_get_main_queue(), ^{ - if(error && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(error && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [weakSelf.delegate customEvent:weakSelf didFailToLoadWithError:error]; } }); @@ -48,7 +48,7 @@ - (void)gdt_unifiedNativeAdLoaded:(NSArray * _Nu #pragma mark - GDTUnifiedNativeAdViewDelegate // 广告曝光回调 - (void)gdt_unifiedNativeAdViewWillExpose:(GDTUnifiedNativeAdView *)unifiedNativeAdView{ - if(_delegate && [_delegate respondsToSelector:@selector(nativeCustomEventWillShow:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(nativeCustomEventWillShow:)]) { [_delegate nativeCustomEventWillShow:self]; } } @@ -56,7 +56,7 @@ - (void)gdt_unifiedNativeAdViewWillExpose:(GDTUnifiedNativeAdView *)unifiedNativ //广告点击回调 - (void)gdt_unifiedNativeAdViewDidClick:(GDTUnifiedNativeAdView *)unifiedNativeAdView{ - if(_delegate && [_delegate respondsToSelector:@selector(nativeCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(nativeCustomEventDidClick:)]) { [_delegate nativeCustomEventDidClick:self]; } } diff --git a/Adapters/TencentAdAdapter/OMTencentAdNativeView.m b/Adapters/TencentAdAdapter/OMTencentAdNativeView.m index 4166d12..1969604 100644 --- a/Adapters/TencentAdAdapter/OMTencentAdNativeView.m +++ b/Adapters/TencentAdAdapter/OMTencentAdNativeView.m @@ -6,7 +6,7 @@ @implementation OMTencentAdNativeView - (instancetype)initWithFrame:(CGRect)frame{ - if(self = [super initWithFrame:frame]){ + if(self = [super initWithFrame:frame]) { Class gdtNativeAdViewClass = NSClassFromString(@"GDTUnifiedNativeAdView"); if (gdtNativeAdViewClass) { _gdtNativeView = [[gdtNativeAdViewClass alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; @@ -94,7 +94,7 @@ - (void)setNativeAd:(OMTencentAdNativeAd *)nativeAd{ } - (void)addSubview:(UIView *)view{ - if(_gdtNativeView && view != _gdtNativeView){ + if(_gdtNativeView && view != _gdtNativeView) { [_gdtNativeView addSubview:view]; }else{ [super addSubview:view]; diff --git a/Adapters/TencentAdAdapter/OMTencentAdRewardedVideo.m b/Adapters/TencentAdAdapter/OMTencentAdRewardedVideo.m index 39f649e..0c6bf4d 100644 --- a/Adapters/TencentAdAdapter/OMTencentAdRewardedVideo.m +++ b/Adapters/TencentAdAdapter/OMTencentAdRewardedVideo.m @@ -89,7 +89,7 @@ - (void)gdt_rewardVideoAd:(GDTRewardVideoAd *)rewardedVideoAd didFailWithError:( // 5004 没有合适的广告 if (error.code == 5003) { - if(error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]){ + if(error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { [_delegate rewardedVideoCustomEventDidFailToShow:self withError:error]; } }else{ @@ -100,13 +100,13 @@ - (void)gdt_rewardVideoAd:(GDTRewardVideoAd *)rewardedVideoAd didFailWithError:( } - (void)gdt_rewardVideoAdDidRewardEffective:(GDTRewardVideoAd *)rewardedVideoAd{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { [_delegate rewardedVideoCustomEventDidReceiveReward:self]; } } - (void)gdt_rewardVideoAdDidPlayFinish:(GDTRewardVideoAd *)rewardedVideoAd{ - if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { [_delegate rewardedVideoCustomEventVideoEnd:self]; } } diff --git a/Adapters/TikTokAdapter/OMTikTokAdapter.h b/Adapters/TikTokAdapter/OMTikTokAdapter.h index 6027b71..74c0847 100644 --- a/Adapters/TikTokAdapter/OMTikTokAdapter.h +++ b/Adapters/TikTokAdapter/OMTikTokAdapter.h @@ -7,9 +7,10 @@ NS_ASSUME_NONNULL_BEGIN -static NSString * const TikTokAdapterVersion = @"3.1.0"; +static NSString * const TikTokAdapterVersion = @"3.1.2"; @interface OMTikTokAdapter : NSObject +@property (class, nonatomic) BOOL expressAdAPI; + (NSString*)adapterVerison; + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler; @end diff --git a/Adapters/TikTokAdapter/OMTikTokAdapter.m b/Adapters/TikTokAdapter/OMTikTokAdapter.m index ae7aa92..0bdbbea 100644 --- a/Adapters/TikTokAdapter/OMTikTokAdapter.m +++ b/Adapters/TikTokAdapter/OMTikTokAdapter.m @@ -3,25 +3,23 @@ #import "OMTikTokAdapter.h" +static BOOL _expressAdAPI = NO; + @implementation OMTikTokAdapter + (NSString*)adapterVerison { return TikTokAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"BUAdSDKManager"); - if (sdkClass && [sdkClass respondsToSelector:@selector(SDKVersion)]) { - sdkVersion = [sdkClass SDKVersion]; - } - return sdkVersion; ++ (BOOL)expressAdAPI { + return _expressAdAPI; } -+ (NSString*)minimumSupportVersion { - return @"1.9.8"; ++ (void)setExpressAdAPI:(BOOL)expressAdAPI { + _expressAdAPI = expressAdAPI; } + + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler:(OMMediationAdapterInitCompletionBlock)completionHandler { NSString *key = [configuration objectForKey:@"appKey"]; @@ -34,15 +32,7 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.pangleadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - - if(buadClass && [buadClass respondsToSelector:@selector(setAppID:)]){ + if(buadClass && [buadClass respondsToSelector:@selector(setAppID:)]) { [buadClass setAppID:key]; completionHandler(nil); }else{ diff --git a/Adapters/TikTokAdapter/OMTikTokBanner.m b/Adapters/TikTokAdapter/OMTikTokBanner.m index f79e725..d80e75c 100644 --- a/Adapters/TikTokAdapter/OMTikTokBanner.m +++ b/Adapters/TikTokAdapter/OMTikTokBanner.m @@ -26,7 +26,7 @@ - (void)loadAd{ #pragma mark BUNativeExpressBannerViewDelegate - (void)nativeExpressBannerAdViewDidLoad:(BUNativeExpressBannerView *)bannerAdView{ - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } } @@ -36,7 +36,7 @@ - (void)nativeExpressBannerAdViewDidLoad:(BUNativeExpressBannerView *)bannerAdVi @param error : the reason of error */ - (void)nativeExpressBannerAdView:(BUNativeExpressBannerView *)bannerAdView didLoadFailWithError:(NSError *_Nullable)error{ - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:error]; } } @@ -45,7 +45,7 @@ - (void)nativeExpressBannerAdView:(BUNativeExpressBannerView *)bannerAdView didL This method is called when rendering a nativeExpressAdView successed. */ - (void)nativeExpressBannerAdViewRenderSuccess:(BUNativeExpressBannerView *)bannerAdView{ - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]) { [_delegate bannerCustomEventWillPresentScreen:self]; } } @@ -69,7 +69,7 @@ - (void)nativeExpressBannerAdViewWillBecomVisible:(BUNativeExpressBannerView *)b This method is called when bannerAdView is clicked. */ - (void)nativeExpressBannerAdViewDidClick:(BUNativeExpressBannerView *)bannerAdView{ - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { [_delegate bannerCustomEventDidClick:self]; } } diff --git a/Adapters/TikTokAdapter/OMTikTokInterstitial.h b/Adapters/TikTokAdapter/OMTikTokInterstitial.h index 0329d1b..dff2750 100644 --- a/Adapters/TikTokAdapter/OMTikTokInterstitial.h +++ b/Adapters/TikTokAdapter/OMTikTokInterstitial.h @@ -10,8 +10,7 @@ NS_ASSUME_NONNULL_BEGIN @interface OMTikTokInterstitial : NSObject @property (nonatomic, copy) NSString *pid; -@property (nonatomic, copy) NSString *appID; -@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; +@property (nonatomic, assign) BOOL adReadyFlag; @property (nonatomic, strong) BUFullscreenVideoAd *fullscreenVideoAd; @property (nonatomic, weak) id delegate; diff --git a/Adapters/TikTokAdapter/OMTikTokInterstitial.m b/Adapters/TikTokAdapter/OMTikTokInterstitial.m index 1744716..4d86fbb 100644 --- a/Adapters/TikTokAdapter/OMTikTokInterstitial.m +++ b/Adapters/TikTokAdapter/OMTikTokInterstitial.m @@ -1,6 +1,7 @@ // Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED // Licensed under the GNU Lesser General Public License Version 3 +#import "OMTikTokAdapter.h" #import "OMTikTokInterstitial.h" @@ -10,14 +11,13 @@ - (instancetype)initWithParameter:(NSDictionary*)adParameter { if (self = [super init]) { if (adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { _pid = [adParameter objectForKey:@"pid"]; - _appID = @""; } } return self; } -(void)loadAd { - Class BUFullscreenVideoAdClass = NSClassFromString(@"BUFullscreenVideoAd"); + Class BUFullscreenVideoAdClass = NSClassFromString([OMTikTokAdapter expressAdAPI]?@"BUNativeExpressFullscreenVideoAd":@"BUFullscreenVideoAd"); if (BUFullscreenVideoAdClass && [[BUFullscreenVideoAdClass alloc] respondsToSelector:@selector(initWithSlotID:)]) { _fullscreenVideoAd = [[BUFullscreenVideoAdClass alloc] initWithSlotID:_pid]; @@ -30,7 +30,7 @@ -(void)loadAd { -(BOOL)isReady { if (_fullscreenVideoAd) { - return _fullscreenVideoAd.adValid; + return (_fullscreenVideoAd.adValid && self.adReadyFlag); } return NO; } @@ -38,6 +38,7 @@ -(BOOL)isReady { - (void)show:(UIViewController *)vc { if ([self isReady]) { + self.adReadyFlag = NO; [_fullscreenVideoAd showAdFromRootViewController:vc]; } } @@ -47,6 +48,7 @@ - (void)show:(UIViewController *)vc 视频广告视频素材缓存成功 */ - (void)fullscreenVideoAdVideoDataDidLoad:(BUFullscreenVideoAd *)fullscreenVideoAd { + self.adReadyFlag = YES; if (_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } @@ -98,4 +100,70 @@ - (void)fullscreenVideoAd:(BUFullscreenVideoAd *)fullscreenVideoAd didFailWithEr } +#pragma mark BUNativeExpressFullscreenVideoAdDelegate +- (void)nativeExpressFullscreenVideoAdDidLoad:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + self.adReadyFlag = YES; + if (_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [_delegate customEvent:self didLoadAd:nil]; + } +} + +- (void)nativeExpressFullscreenVideoAd:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd didFailWithError:(NSError *_Nullable)error { + if (_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [_delegate customEvent:self didFailToLoadWithError:error]; + } + +} + +- (void)nativeExpressFullscreenVideoAdViewRenderSuccess:(BUNativeExpressFullscreenVideoAd *)rewardedVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidOpen:)]) { + [_delegate interstitialCustomEventDidOpen:self]; + } +} + + +- (void)nativeExpressFullscreenVideoAdViewRenderFail:(BUNativeExpressFullscreenVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error { + if (_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidFailToShow:error:)]) { + [_delegate interstitialCustomEventDidFailToShow:self error:error]; + } + +} + +- (void)nativeExpressFullscreenVideoAdDidDownLoadVideo:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + +} + +- (void)nativeExpressFullscreenVideoAdWillVisible:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + +} + +- (void)nativeExpressFullscreenVideoAdDidVisible:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidShow:)]) { + [_delegate interstitialCustomEventDidShow:self]; + } +} + +- (void)nativeExpressFullscreenVideoAdDidClick:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClick:)]) { + [_delegate interstitialCustomEventDidClick:self]; + } +} + +- (void)nativeExpressFullscreenVideoAdDidClickSkip:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + +} + +- (void)nativeExpressFullscreenVideoAdWillClose:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + +} + +- (void)nativeExpressFullscreenVideoAdDidClose:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(interstitialCustomEventDidClose:)]) { + [_delegate interstitialCustomEventDidClose:self]; + } +} + +- (void)nativeExpressFullscreenVideoAdDidPlayFinish:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd didFailWithError:(NSError *_Nullable)error { + +} @end diff --git a/Adapters/TikTokAdapter/OMTikTokInterstitialClass.h b/Adapters/TikTokAdapter/OMTikTokInterstitialClass.h index 071a8cd..534da87 100644 --- a/Adapters/TikTokAdapter/OMTikTokInterstitialClass.h +++ b/Adapters/TikTokAdapter/OMTikTokInterstitialClass.h @@ -102,6 +102,154 @@ NS_ASSUME_NONNULL_BEGIN @end + +@class BUNativeExpressFullscreenVideoAd; + +typedef NS_ENUM(NSUInteger, BUNativeExpressFullScreenAdType) { + BUNativeExpressFullScreenAdTypeEndcard = 0, // video + endcard + BUNativeExpressFullScreenAdTypeVideoPlayable = 1, // video + playable + BUNativeExpressFullScreenAdTypePurePlayable = 2 // pure playable +}; + +typedef NS_ENUM(NSInteger, BUInteractionType) { + BUInteractionTypeCustorm = 0, + BUInteractionTypeNO_INTERACTION = 1, // pure ad display + BUInteractionTypeURL = 2, // open the webpage using a browser + BUInteractionTypePage = 3, // open the webpage within the app + BUInteractionTypeDownload = 4, // download the app + BUInteractionTypePhone = 5, // make a call + BUInteractionTypeMessage = 6, // send messages + BUInteractionTypeEmail = 7, // send email + BUInteractionTypeVideoAdDetail = 8 // video ad details page +}; + +@protocol BUNativeExpressFullscreenVideoAdDelegate + +@optional +/** + This method is called when video ad material loaded successfully. + */ +- (void)nativeExpressFullscreenVideoAdDidLoad:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad materia failed to load. + @param error : the reason of error + */ +- (void)nativeExpressFullscreenVideoAd:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd didFailWithError:(NSError *_Nullable)error; + +/** + This method is called when rendering a nativeExpressAdView successed. + It will happen when ad is show. + */ +- (void)nativeExpressFullscreenVideoAdViewRenderSuccess:(BUNativeExpressFullscreenVideoAd *)rewardedVideoAd; + +/** + This method is called when a nativeExpressAdView failed to render. + @param error : the reason of error + */ +- (void)nativeExpressFullscreenVideoAdViewRenderFail:(BUNativeExpressFullscreenVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error; + +/** + This method is called when video cached successfully. + For a better user experience, it is recommended to display video ads at this time. + And you can call [BUNativeExpressFullscreenVideoAd showAdFromRootViewController:]. + */ +- (void)nativeExpressFullscreenVideoAdDidDownLoadVideo:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad slot will be showing. + */ +- (void)nativeExpressFullscreenVideoAdWillVisible:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad slot has been shown. + */ +- (void)nativeExpressFullscreenVideoAdDidVisible:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad is clicked. + */ +- (void)nativeExpressFullscreenVideoAdDidClick:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when the user clicked skip button. + */ +- (void)nativeExpressFullscreenVideoAdDidClickSkip:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad is about to close. + */ +- (void)nativeExpressFullscreenVideoAdWillClose:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad is closed. + */ +- (void)nativeExpressFullscreenVideoAdDidClose:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd; + +/** + This method is called when video ad play completed or an error occurred. + @param error : the reason of error + */ +- (void)nativeExpressFullscreenVideoAdDidPlayFinish:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd didFailWithError:(NSError *_Nullable)error; + +/** +This method is used to get the type of nativeExpressFullScreenVideo ad + */ +- (void)nativeExpressFullscreenVideoAdCallback:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd withType:(BUNativeExpressFullScreenAdType) nativeExpressVideoAdType; + +/** + This method is called when another controller has been closed. + @param interactionType : open appstore in app or open the webpage or view video ad details page. + */ +- (void)nativeExpressFullscreenVideoAdDidCloseOtherController:(BUNativeExpressFullscreenVideoAd *)fullscreenVideoAd interactionType:(BUInteractionType)interactionType; + +@end + +@interface BUNativeExpressFullscreenVideoAd : NSObject + +@property (nonatomic, weak, nullable) id delegate; +@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; + +/// media configuration parameters. +@property (nonatomic, copy, readonly) NSDictionary *mediaExt; + +/** + Initializes video ad with slot id. + @param slotID : the unique identifier of video ad. + @return BUFullscreenVideoAd + */ +- (instancetype)initWithSlotID:(NSString *)slotID; + +/** +adload_seq:(针对聚合广告位)传递本次请求是为“自然日内某设备某广告位置第N次展示机会”发出的广告请求,同物理位置在自然日从1开始计数,不同物理位置独立计数;example:某原生广告位置,当天第5次产生展示机会,这次展示机向穿山甲发送了4次广告请求,则这4次广告请求的"adload_seq"的值应为5。第二天重新开始计数。 + +prime_rit:(针对聚合广告位)广告物理位置对应的固定穿山甲广告位id,可以使用第一层的广告位id也可以为某一层的广告位id,但要求同一物理位置在该字段固定上报同一广告位id,不频繁更换;example:某原生广告位,当天共发出了1000个请求,这1000个请求中使用了5个不同target的穿山甲rit,用某X rit来作为该位置的标记rit,则这1000次请求的prime_rit都需要上报X rit的rit id。 +*/ + +- (instancetype)initWithSlotID:(NSString *)slotID adloadSeq:(NSInteger)adloadSeq primeRit:(NSString * __nullable)primeRit; + +/** + Load video ad datas. + */ +- (void)loadAdData; + +/** + Display video ad. + @param rootViewController : root view controller for displaying ad. + @return : whether it is successfully displayed. + */ +- (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController; + +/** + Display video ad. + @param rootViewController : root view controller for displaying ad. + @param sceneDescirbe : optional. Identifies a custom description of the presentation scenario. + @return : whether it is successfully displayed. + */ +- (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController ritSceneDescribe:(NSString *_Nullable)sceneDescirbe; + +@end + NS_ASSUME_NONNULL_END #endif /* OMTikTokInterstitialClass_h */ diff --git a/Adapters/TikTokAdapter/OMTikTokRewardedVideo.h b/Adapters/TikTokAdapter/OMTikTokRewardedVideo.h index 16ac973..12ce9f2 100644 --- a/Adapters/TikTokAdapter/OMTikTokRewardedVideo.h +++ b/Adapters/TikTokAdapter/OMTikTokRewardedVideo.h @@ -10,9 +10,8 @@ NS_ASSUME_NONNULL_BEGIN @interface OMTikTokRewardedVideo : NSObject @property (nonatomic, copy) NSString *pid; -@property (nonatomic, copy) NSString *appID; @property (nonatomic, strong) BURewardedVideoAd *rewardedVideoAd; -@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; +@property (nonatomic, assign) BOOL adReadyFlag; @property (nonatomic, weak) id delegate; - (instancetype)initWithParameter:(NSDictionary*)adParameter; diff --git a/Adapters/TikTokAdapter/OMTikTokRewardedVideo.m b/Adapters/TikTokAdapter/OMTikTokRewardedVideo.m index 7b436d9..a5fb47a 100644 --- a/Adapters/TikTokAdapter/OMTikTokRewardedVideo.m +++ b/Adapters/TikTokAdapter/OMTikTokRewardedVideo.m @@ -1,6 +1,7 @@ // Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED // Licensed under the GNU Lesser General Public License Version 3 +#import "OMTikTokAdapter.h" #import "OMTikTokRewardedVideo.h" @interface OMTikTokRewardedVideo() @@ -11,14 +12,13 @@ @implementation OMTikTokRewardedVideo - (instancetype)initWithParameter:(NSDictionary*)adParameter { if (self = [super init]) { _pid = [adParameter objectForKey:@"pid"]; - _appID = @""; } return self; } -(void)loadAd { - Class BURewardedVideoAdClass = NSClassFromString(@"BURewardedVideoAd"); + Class BURewardedVideoAdClass = NSClassFromString([OMTikTokAdapter expressAdAPI]?@"BUNativeExpressRewardedVideoAd":@"BURewardedVideoAd"); Class BURewardedVideoModelClass = NSClassFromString(@"BURewardedVideoModel"); if (BURewardedVideoAdClass && BURewardedVideoModelClass && [BURewardedVideoAdClass instancesRespondToSelector:@selector(initWithSlotID:rewardedVideoModel:)]) { BURewardedVideoModel *rewardedModel = [[BURewardedVideoModelClass alloc] init]; @@ -32,13 +32,14 @@ -(void)loadAd { -(BOOL)isReady { if (_rewardedVideoAd) { - return _rewardedVideoAd.adValid; + return (_rewardedVideoAd.adValid && self.adReadyFlag); } return NO; } - (void)show:(UIViewController *)vc { if ([self isReady]) { + self.adReadyFlag = NO; [_rewardedVideoAd showAdFromRootViewController:vc]; } @@ -46,6 +47,7 @@ - (void)show:(UIViewController *)vc { -(void)rewardedVideoAdVideoDidLoad:(BURewardedVideoAd *)rewardedVideoAd { + self.adReadyFlag = YES; if (_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } @@ -97,4 +99,94 @@ - (void)rewardedVideoAdDidClose:(BURewardedVideoAd *)rewardedVideoAd { } } + +#pragma mark - BUNativeExpressRewardedVideoAdDelegate +- (void)nativeExpressRewardedVideoAdDidLoad:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + self.adReadyFlag = YES; + if (_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [_delegate customEvent:self didLoadAd:nil]; + } +} + +- (void)nativeExpressRewardedVideoAd:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error { + if (_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [_delegate customEvent:self didFailToLoadWithError:error]; + } +} + +- (void)nativeExpressRewardedVideoAdCallback:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd withType:(BUNativeExpressRewardedVideoAdType)nativeExpressVideoType{ + +} + +- (void)nativeExpressRewardedVideoAdDidDownLoadVideo:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + +} + +- (void)nativeExpressRewardedVideoAdViewRenderSuccess:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { + [_delegate rewardedVideoCustomEventDidOpen:self]; + } +} + +- (void)nativeExpressRewardedVideoAdViewRenderFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error { + if (error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { + [_delegate rewardedVideoCustomEventDidFailToShow:self withError:error]; + } +} + +- (void)nativeExpressRewardedVideoAdWillVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + +} + +- (void)nativeExpressRewardedVideoAdDidVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { + [_delegate rewardedVideoCustomEventVideoStart:self]; + } +} + +- (void)nativeExpressRewardedVideoAdWillClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + +} + +- (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { + [_delegate rewardedVideoCustomEventDidClose:self]; + } +} + +- (void)nativeExpressRewardedVideoAdDidClick:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { + [_delegate rewardedVideoCustomEventDidClick:self]; + } +} + +- (void)nativeExpressRewardedVideoAdDidClickSkip:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd { + +} + +- (void)nativeExpressRewardedVideoAdDidPlayFinish:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error { + if (error && _delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidFailToShow:withError:)]) { + [_delegate rewardedVideoCustomEventDidFailToShow:self withError:error]; + } + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { + [_delegate rewardedVideoCustomEventVideoEnd:self]; + } +} + +- (void)nativeExpressRewardedVideoAdServerRewardDidSucceed:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd verify:(BOOL)verify { + if (verify) { + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { + [_delegate rewardedVideoCustomEventDidReceiveReward:self]; + } + } +} + +- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError * _Nullable)error { + +} + +- (void)nativeExpressRewardedVideoAdDidCloseOtherController:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd interactionType:(BUInteractionType)interactionType { + + +} @end diff --git a/Adapters/TikTokAdapter/OMTikTokRewardedVideoClass.h b/Adapters/TikTokAdapter/OMTikTokRewardedVideoClass.h index 7002e03..f160e63 100644 --- a/Adapters/TikTokAdapter/OMTikTokRewardedVideoClass.h +++ b/Adapters/TikTokAdapter/OMTikTokRewardedVideoClass.h @@ -109,6 +109,173 @@ NS_ASSUME_NONNULL_BEGIN @end +@protocol BUNativeExpressRewardedVideoAdDelegate; + +typedef NS_ENUM(NSInteger, BURitSceneType) { + BURitSceneType_custom = 0,//custom + BURitSceneType_home_open_bonus = 1,//Login/open rewards (login, sign-in, offline rewards doubling, etc.) + BURitSceneType_home_svip_bonus = 2,//Special privileges (VIP privileges, daily rewards, etc.) + BURitSceneType_home_get_props = 3,//Watch rewarded video ad to gain skin, props, levels, skills, etc + BURitSceneType_home_try_props = 4,//Watch rewarded video ad to try out skins, props, levels, skills, etc + BURitSceneType_home_get_bonus = 5,//Watch rewarded video ad to get gold COINS, diamonds, etc + BURitSceneType_home_gift_bonus = 6,//Sweepstakes, turntables, gift boxes, etc + BURitSceneType_game_start_bonus = 7,//Before the opening to obtain physical strength, opening to strengthen, opening buff, task props + BURitSceneType_game_reduce_waiting = 8,//Reduce wait and cooldown on skill CD, building CD, quest CD, etc + BURitSceneType_game_more_opportunities = 9,//More chances (resurrect death, extra game time, decrypt tips, etc.) + BURitSceneType_game_finish_rewards = 10,//Settlement multiple times/extra bonus (completion of chapter, victory over boss, first place, etc.) + BURitSceneType_game_gift_bonus = 11//The game dropped treasure box, treasures and so on +}; + +typedef NS_ENUM(NSUInteger, BUNativeExpressRewardedVideoAdType) { + BUNativeExpressRewardedVideoAdTypeEndcard = 0, // video + endcard + BUNativeExpressRewardedVideoAdTypeVideoPlayable = 1, // video + playable + BUNativeExpressRewardedVideoAdTypePurePlayable = 2, // pure playable +}; + +typedef NS_ENUM(NSInteger, BUInteractionType) { + BUInteractionTypeCustorm = 0, + BUInteractionTypeNO_INTERACTION = 1, // pure ad display + BUInteractionTypeURL = 2, // open the webpage using a browser + BUInteractionTypePage = 3, // open the webpage within the app + BUInteractionTypeDownload = 4, // download the app + BUInteractionTypePhone = 5, // make a call + BUInteractionTypeMessage = 6, // send messages + BUInteractionTypeEmail = 7, // send email + BUInteractionTypeVideoAdDetail = 8 // video ad details page +}; + +@interface BUNativeExpressRewardedVideoAd : NSObject +@property (nonatomic, strong) BURewardedVideoModel *rewardedVideoModel; +@property (nonatomic, weak, nullable) id delegate; +/// media configuration parameters. +@property (nonatomic, copy, readonly) NSDictionary *mediaExt; + +/** + Whether material is effective. + Setted to YES when data is not empty and has not been displayed. + Repeated display is not billed. + */ +@property (nonatomic, getter=isAdValid, readonly) BOOL adValid; + +- (instancetype)initWithSlotID:(NSString *)slotID rewardedVideoModel:(BURewardedVideoModel *)model; +- (void)loadAdData; + +/** + Display video ad. + @param rootViewController : root view controller for displaying ad. + @return : whether it is successfully displayed. + */ +- (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController; + +/** + If ritSceneType is custom, you need to pass in the values for sceneDescirbe. + @param ritSceneType : optional. Identifies a custom description of the presentation scenario. + @param sceneDescirbe : optional. Identify the scene of presentation. + */ +- (BOOL)showAdFromRootViewController:(UIViewController *)rootViewController ritScene:(BURitSceneType)ritSceneType ritSceneDescribe:(NSString *_Nullable)sceneDescirbe; +@end + +@protocol BUNativeExpressRewardedVideoAdDelegate + +@optional +/** + This method is called when video ad material loaded successfully. + */ +- (void)nativeExpressRewardedVideoAdDidLoad:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when video ad materia failed to load. + @param error : the reason of error + */ +- (void)nativeExpressRewardedVideoAd:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error; +/** + this methods is to tell delegate the type of native express rewarded video Ad + */ +- (void)nativeExpressRewardedVideoAdCallback:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd withType:(BUNativeExpressRewardedVideoAdType)nativeExpressVideoType; + +/** + This method is called when cached successfully. + For a better user experience, it is recommended to display video ads at this time. + And you can call [BUNativeExpressRewardedVideoAd showAdFromRootViewController:]. + */ +- (void)nativeExpressRewardedVideoAdDidDownLoadVideo:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when rendering a nativeExpressAdView successed. + It will happen when ad is show. + */ +- (void)nativeExpressRewardedVideoAdViewRenderSuccess:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when a nativeExpressAdView failed to render. + @param error : the reason of error + */ +- (void)nativeExpressRewardedVideoAdViewRenderFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error; + +/** + This method is called when video ad slot will be showing. + */ +- (void)nativeExpressRewardedVideoAdWillVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when video ad slot has been shown. + */ +- (void)nativeExpressRewardedVideoAdDidVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when video ad is about to close. + */ +- (void)nativeExpressRewardedVideoAdWillClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when video ad is closed. + */ +- (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when video ad is clicked. + */ +- (void)nativeExpressRewardedVideoAdDidClick:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when the user clicked skip button. + */ +- (void)nativeExpressRewardedVideoAdDidClickSkip:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd; + +/** + This method is called when video ad play completed or an error occurred. + @param error : the reason of error + */ +- (void)nativeExpressRewardedVideoAdDidPlayFinish:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error; + +/** + Server verification which is requested asynchronously is succeeded. now include two v erify methods: + 1. C2C need server verify 2. S2S don't need server verify + @param verify :return YES when return value is 2000. + */ +- (void)nativeExpressRewardedVideoAdServerRewardDidSucceed:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd verify:(BOOL)verify; + +/** + Server verification which is requested asynchronously is failed. + Return value is not 2000. + */ +- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd __attribute__((deprecated("Use nativeExpressRewardedVideoAdServerRewardDidFail: error: instead."))); + +/** + Server verification which is requested asynchronously is failed. + @param rewardedVideoAd express rewardVideo Ad + @param error request error info + */ +- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error; + +/** + This method is called when another controller has been closed. + @param interactionType : open appstore in app or open the webpage or view video ad details page. + */ +- (void)nativeExpressRewardedVideoAdDidCloseOtherController:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd interactionType:(BUInteractionType)interactionType; + +@end + NS_ASSUME_NONNULL_END #endif /* OMTikTokRewardedVideoClass_h */ diff --git a/Adapters/UnityAdapter/OMUnityAdapter.m b/Adapters/UnityAdapter/OMUnityAdapter.m index ff4d11a..825d525 100644 --- a/Adapters/UnityAdapter/OMUnityAdapter.m +++ b/Adapters/UnityAdapter/OMUnityAdapter.m @@ -10,19 +10,6 @@ + (NSString*)adapterVerison { return UnityAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"UnityAds"); - if(sdkClass && [sdkClass respondsToSelector:@selector(getVersion)]){ - sdkVersion = [sdkClass getVersion]; - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"3.0.0"; -} - + (void)setConsent:(BOOL)consent { Class metaDataClass = NSClassFromString(@"UADSMetaData"); @@ -53,14 +40,6 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.unityadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - NSString *key = [configuration objectForKey:@"appKey"]; if (unityClass && [unityClass respondsToSelector:@selector(initialize:delegate:)] && [key length]>0) { [unityClass initialize:key]; diff --git a/Adapters/UnityAdapter/OMUnityBanner.m b/Adapters/UnityAdapter/OMUnityBanner.m index 9d07e70..5ea3614 100644 --- a/Adapters/UnityAdapter/OMUnityBanner.m +++ b/Adapters/UnityAdapter/OMUnityBanner.m @@ -25,25 +25,25 @@ - (void)loadAd{ -(void)bannerViewDidLoad:(UADSBannerView *)bannerView{ - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { [_delegate customEvent:self didLoadAd:nil]; } } - (void)bannerViewDidError:(UADSBannerView *)bannerView error:(UADSBannerError *)error{ - if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { [_delegate customEvent:self didFailToLoadWithError:error]; } } -(void)bannerViewDidClick:(UADSBannerView *)bannerView{ - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { [_delegate bannerCustomEventDidClick:self]; } } - (void)bannerViewDidLeaveApplication:(UADSBannerView *)bannerView{ - if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillLeaveApplication:)]){ + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillLeaveApplication:)]) { [_delegate bannerCustomEventWillLeaveApplication:self]; } } diff --git a/Adapters/VungleAdapter/OMVungleAdapter.h b/Adapters/VungleAdapter/OMVungleAdapter.h index 9da44f7..3fb9e04 100644 --- a/Adapters/VungleAdapter/OMVungleAdapter.h +++ b/Adapters/VungleAdapter/OMVungleAdapter.h @@ -4,7 +4,7 @@ #import #import "OMMediationAdapter.h" -static NSString * const VungleAdapterVersion = @"3.1.1"; +static NSString * const VungleAdapterVersion = @"3.1.4"; @interface OMVungleAdapter : NSObject diff --git a/Adapters/VungleAdapter/OMVungleAdapter.m b/Adapters/VungleAdapter/OMVungleAdapter.m index a799381..8f173b2 100644 --- a/Adapters/VungleAdapter/OMVungleAdapter.m +++ b/Adapters/VungleAdapter/OMVungleAdapter.m @@ -10,25 +10,6 @@ + (NSString*)adapterVerison { return VungleAdapterVersion; } -+ (NSString*)adNetworkVersion { - NSString *sdkVersion = @""; - Class sdkClass = NSClassFromString(@"VungleSDK"); - if (sdkClass && [sdkClass respondsToSelector:@selector(sharedSDK)]) { - VungleSDK *vungle = [sdkClass sharedSDK]; - if (vungle && [vungle respondsToSelector:@selector(debugInfo)]) { - NSDictionary *dic = [vungle debugInfo]; - if (dic[@"version"]) { - sdkVersion = dic[@"version"]; - } - } - } - return sdkVersion; -} - -+ (NSString*)minimumSupportVersion { - return @"6.3.2"; -} - + (void)setConsent:(BOOL)consent { Class vungleClass = NSClassFromString(@"VungleSDK"); if (vungleClass && [vungleClass respondsToSelector:@selector(sharedSDK)]) { @@ -61,21 +42,24 @@ + (void)initSDKWithConfiguration:(NSDictionary *)configuration completionHandler return; } - if ([[self adNetworkVersion]compare:[self minimumSupportVersion]options:NSNumericSearch] == NSOrderedAscending) { - NSError *error = [[NSError alloc] initWithDomain:@"com.mediation.vungleadapter" - code:505 - userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"The current ad network(%@) is below the minimum required version(%@)",[self adNetworkVersion],[self minimumSupportVersion]]}]; - completionHandler(error); - return; - } - - if(vungleClass && [vungleClass respondsToSelector:@selector(sharedSDK)] && [key length]>0){ + if(vungleClass && [vungleClass respondsToSelector:@selector(sharedSDK)] && [key length]>0) { VungleSDK *vungle = [vungleClass sharedSDK]; - if(vungle && [vungle respondsToSelector:@selector(startWithAppId:error:)]){ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + SEL setPluginNameSelecotr = @selector(setPluginName:version:); + if ([vungle respondsToSelector:setPluginNameSelecotr]) { + [vungle performSelector: setPluginNameSelecotr + withObject: @"vunglehbs" + withObject: @"1.0.0"]; + + } +#pragma clang diagnostic pop + if(vungle && [vungle respondsToSelector:@selector(startWithAppId:error:)]) { NSError *error = nil; BOOL start = [vungle startWithAppId:key error:&error]; vungle.delegate = [OMVungleRouter sharedInstance]; - if(start){ + if(start) { completionHandler(nil); }else{ completionHandler(error); diff --git a/Adapters/VungleAdapter/OMVungleBid.h b/Adapters/VungleAdapter/OMVungleBid.h new file mode 100644 index 0000000..03d9b7c --- /dev/null +++ b/Adapters/VungleAdapter/OMVungleBid.h @@ -0,0 +1,15 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMBidCustomEvent.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMVungleBid : NSObject + ++ (NSString*)bidderToken; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Adapters/VungleAdapter/OMVungleBid.m b/Adapters/VungleAdapter/OMVungleBid.m new file mode 100644 index 0000000..f652527 --- /dev/null +++ b/Adapters/VungleAdapter/OMVungleBid.m @@ -0,0 +1,18 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMVungleBid.h" +#import "OMVungleBidClass.h" + +@implementation OMVungleBid + ++ (NSString*)bidderToken { + NSString *token = @""; + Class vungleSDK = NSClassFromString(@"VungleSDK"); + if (vungleSDK && [vungleSDK respondsToSelector:@selector(sharedSDK)] && [vungleSDK instancesRespondToSelector:@selector(currentSuperToken)]) { + token = [[vungleSDK sharedSDK] currentSuperToken]; + } + return token; +} + +@end diff --git a/Adapters/VungleAdapter/OMVungleBidClass.h b/Adapters/VungleAdapter/OMVungleBidClass.h new file mode 100644 index 0000000..ea7ea09 --- /dev/null +++ b/Adapters/VungleAdapter/OMVungleBidClass.h @@ -0,0 +1,60 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#ifndef OMVungleBidClass_h +#define OMVungleBidClass_h + +#import "OMVungleClass.h" +@protocol VungleSDKHeaderBidding; + +@interface VungleSDK () + +/** + * Setting this to a non-nil value will enabled header bidding and reporting + */ +@property (nonatomic, weak) NSObject *headerBiddingDelegate; + +/** + * This is a synchronous method to fetch a bid token for any placement. This method + * will return nil if it is unable to find a bid token, or a cached placement. + * + * @param placement The ID of a that has already been loaded placement + */ +- (NSString *)bidTokenForPlacement:(NSString *)placement; + +/** + * This is a synchronous method to fetch super token. This method + * will return nil if it is unable to find an available token. + * + */ +- (NSString *)currentSuperToken; + +@end + +@protocol VungleSDKHeaderBidding + +@optional +/** + * If implemented, this will be called as soon as the SDK receives a bidToken for a particular + * placement. Note that the placement is NOT available to playback until preparation. + * + * @param placement The ID of a placement which is ready to be played + * @param bidToken An encrypted bid token used to identify the placement through the auction + */ +- (void)placementWillBeginCaching:(NSString *)placement + withBidToken:(NSString *)bidToken; + +@required +/** + * If implemented, this will be called when the SDK has a placement fully prepared and cached + * to disk with a corresponding bid token. + * + * @param placement The ID of a placement which is ready to be played + * @param bidToken An encrypted bid token used to identify the placement through the auction + */ +- (void)placementPrepared:(NSString *)placement + withBidToken:(NSString *)bidToken; + +@end + +#endif /* OMVungleBidClass_h */ diff --git a/Adapters/VungleAdapter/OMVungleRewardedVideo.m b/Adapters/VungleAdapter/OMVungleRewardedVideo.m index 41bb24d..a7f430b 100644 --- a/Adapters/VungleAdapter/OMVungleRewardedVideo.m +++ b/Adapters/VungleAdapter/OMVungleRewardedVideo.m @@ -17,6 +17,10 @@ - (void)loadAd { [[OMVungleRouter sharedInstance]loadPlacmentID:_pid]; } +- (void)loadAdWithBidPayload:(NSString *)bidPayload { + [self loadAd]; +} + - (BOOL)isReady { return [[OMVungleRouter sharedInstance]isAdAvailableForPlacementID:_pid]; } @@ -42,7 +46,7 @@ - (void)omVungleDidStart { if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { [_delegate rewardedVideoCustomEventDidOpen:self]; } - if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { + if (_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { [_delegate rewardedVideoCustomEventVideoStart:self]; } } diff --git a/Adapters/VungleAdapter/OMVungleRouter.h b/Adapters/VungleAdapter/OMVungleRouter.h index 63c7e4f..152b49d 100644 --- a/Adapters/VungleAdapter/OMVungleRouter.h +++ b/Adapters/VungleAdapter/OMVungleRouter.h @@ -3,6 +3,7 @@ #import #import "OMVungleClass.h" +#import "OMVungleBidClass.h" NS_ASSUME_NONNULL_BEGIN @@ -21,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN @end -@interface OMVungleRouter : NSObject +@interface OMVungleRouter : NSObject @property (nonatomic, assign) BOOL isAdPlaying; @property (nonatomic, strong) NSMutableDictionary *placementDelegateMap; diff --git a/Adapters/VungleAdapter/OMVungleRouter.m b/Adapters/VungleAdapter/OMVungleRouter.m index 4e065ea..c7fba16 100644 --- a/Adapters/VungleAdapter/OMVungleRouter.m +++ b/Adapters/VungleAdapter/OMVungleRouter.m @@ -3,6 +3,7 @@ #import "OMVungleRouter.h" + static OMVungleRouter * _instance = nil; @@ -20,6 +21,7 @@ - (instancetype)init { Class vungleClass = NSClassFromString(@"VungleSDK"); if (vungleClass && [vungleClass respondsToSelector:@selector(sharedSDK)]) { _vungleSDK = [vungleClass sharedSDK]; + ((VungleSDK*)_vungleSDK).headerBiddingDelegate = self; } _placementDelegateMap = [NSMutableDictionary dictionary]; } @@ -84,6 +86,8 @@ - (void)showAdFromViewController:(UIViewController *)viewController forPlacement #pragma mark -- VungleSDKDelegate - (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID error:(nullable NSError *)error { + NSLog(@"vungle bid %@ isadplayable %zd",placementID, (NSInteger)isAdPlayable); + id delegate = [_placementDelegateMap objectForKey:placementID]; if(![self isAdPlaying] && isAdPlayable && _vungleSDK && [_vungleSDK respondsToSelector:@selector(isAdCachedForPlacementID:)] && [_vungleSDK isAdCachedForPlacementID:placementID] ) { @@ -148,4 +152,24 @@ - (void)nativeAdsPlacementWillTriggerURLLaunch:(NSString *)placement { } } +#pragma mark - VungleSDKHeaderBidding + +- (void)placementWillBeginCaching:(NSString *)placement + withBidToken:(NSString *)bidToken { + NSLog(@"vungle bid begin cache %@ token %@",placement, bidToken); +} + +- (void)placementPrepared:(NSString *)placement + withBidToken:(NSString *)bidToken { + NSLog(@"vungle bid preload %@ token %@",placement, bidToken); +} + +- (void)vungleSDKDidInitialize { + NSString *token = @""; + Class vungleSDK = NSClassFromString(@"VungleSDK"); + if (vungleSDK && [vungleSDK respondsToSelector:@selector(sharedSDK)] && [vungleSDK instancesRespondToSelector:@selector(currentSuperToken)]) { + token = [[vungleSDK sharedSDK] currentSuperToken]; + } + +} @end diff --git a/OpenMediation.podspec b/OpenMediation.podspec index 69bc090..c1a1945 100644 --- a/OpenMediation.podspec +++ b/OpenMediation.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'OpenMediation' - s.version = '1.3.3' + s.version = '2.0.0' s.summary = 'OpenMediation SDK for iOS' s.homepage = 'https://github.com/AdTiming/OpenMediation-iOS' s.description = <<-DESC diff --git a/OpenMediation.xcodeproj/project.pbxproj b/OpenMediation.xcodeproj/project.pbxproj index 92f1913..c3fe4b6 100644 --- a/OpenMediation.xcodeproj/project.pbxproj +++ b/OpenMediation.xcodeproj/project.pbxproj @@ -155,6 +155,9 @@ 0CF881072473857600ED2CBD /* SplashViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CF881062473857600ED2CBD /* SplashViewController.m */; }; 49097843240383EA00D39DF5 /* OMUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = 49097842240383EA00D39DF5 /* OMUnit.m */; }; 490978452403841300D39DF5 /* NSError+OMExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 490978442403841300D39DF5 /* NSError+OMExtension.m */; }; + 491B9C5F251DDCB3007A4310 /* OMVungleBidClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 491B9C5C251DDCB2007A4310 /* OMVungleBidClass.h */; }; + 491B9C60251DDCB3007A4310 /* OMVungleBid.h in Headers */ = {isa = PBXBuildFile; fileRef = 491B9C5D251DDCB2007A4310 /* OMVungleBid.h */; }; + 491B9C61251DDCB3007A4310 /* OMVungleBid.m in Sources */ = {isa = PBXBuildFile; fileRef = 491B9C5E251DDCB3007A4310 /* OMVungleBid.m */; }; 492018D023F6C20C007C5EA4 /* OMLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 492018CE23F6C20C007C5EA4 /* OMLoad.h */; }; 492018D123F6C20C007C5EA4 /* OMLoad.m in Sources */ = {isa = PBXBuildFile; fileRef = 492018CF23F6C20C007C5EA4 /* OMLoad.m */; }; 492403BE23F6A2F200687456 /* OMAdTimingAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C8B66A023ED167F00C5B97A /* OMAdTimingAdapter.framework */; }; @@ -197,11 +200,39 @@ 4959CEBE23EBEE7300A433A8 /* OMChartboostAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4959CEB723EBEE7300A433A8 /* OMChartboostAdapter.framework */; }; 4959CECF23EBEE8100A433A8 /* OMTikTokAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4959CEC823EBEE8100A433A8 /* OMTikTokAdapter.framework */; }; 4959CEE023EBEE9400A433A8 /* OMMintegralAdapter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4959CED923EBEE9400A433A8 /* OMMintegralAdapter.framework */; }; + 497B96E6255D244D0024592E /* OMCrossPromotionDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 497B96DE255D244C0024592E /* OMCrossPromotionDownloader.h */; }; + 497B96E7255D244D0024592E /* OMCrossPromotionDownloadManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 497B96DF255D244C0024592E /* OMCrossPromotionDownloadManager.h */; }; + 497B96E8255D244D0024592E /* OMCrossPromotionDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 497B96E0255D244C0024592E /* OMCrossPromotionDownloader.m */; }; + 497B96E9255D244D0024592E /* OMCrossPromotionHTTPCacheControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 497B96E1255D244C0024592E /* OMCrossPromotionHTTPCacheControl.m */; }; + 497B96EA255D244D0024592E /* OMCrossPromotionDownloadManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 497B96E2255D244D0024592E /* OMCrossPromotionDownloadManager.m */; }; + 497B96EB255D244D0024592E /* OMCrossPromotionHTTPCacheControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 497B96E3255D244D0024592E /* OMCrossPromotionHTTPCacheControl.h */; }; + 497B96EC255D244D0024592E /* OMCrossPromotionCacheFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 497B96E4255D244D0024592E /* OMCrossPromotionCacheFile.m */; }; + 497B96ED255D244D0024592E /* OMCrossPromotionCacheFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 497B96E5255D244D0024592E /* OMCrossPromotionCacheFile.h */; }; + 497F021125650BF900354846 /* OMCrossPromotionAdDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 497F020B25650BF900354846 /* OMCrossPromotionAdDelegate.h */; }; + 497F021225650BF900354846 /* OMCrossPromotionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 497F020C25650BF900354846 /* OMCrossPromotionDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 497F021325650BF900354846 /* OMCrossPromotionAd.h in Headers */ = {isa = PBXBuildFile; fileRef = 497F020D25650BF900354846 /* OMCrossPromotionAd.h */; }; + 497F021425650BF900354846 /* OMCrossPromotion.m in Sources */ = {isa = PBXBuildFile; fileRef = 497F020E25650BF900354846 /* OMCrossPromotion.m */; }; + 497F021525650BF900354846 /* OMCrossPromotionAd.m in Sources */ = {isa = PBXBuildFile; fileRef = 497F020F25650BF900354846 /* OMCrossPromotionAd.m */; }; + 497F021625650BF900354846 /* OMCrossPromotion.h in Headers */ = {isa = PBXBuildFile; fileRef = 497F021025650BF900354846 /* OMCrossPromotion.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 497F028425650ECE00354846 /* OMCrossPromotionCustomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 497F028325650ECE00354846 /* OMCrossPromotionCustomEvent.h */; }; + 497F02AB25661FE700354846 /* OMCrossPromotionCP.h in Headers */ = {isa = PBXBuildFile; fileRef = 497F02A925661FE700354846 /* OMCrossPromotionCP.h */; }; + 497F02AC25661FE700354846 /* OMCrossPromotionCP.m in Sources */ = {isa = PBXBuildFile; fileRef = 497F02AA25661FE700354846 /* OMCrossPromotionCP.m */; }; + 497F02C12566416A00354846 /* CrossPromotionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 497F02C02566416A00354846 /* CrossPromotionViewController.m */; }; 499E7E9E24E6A72900F1D96C /* OMAdColonyRewardedVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = 499E7E9924E6A72800F1D96C /* OMAdColonyRewardedVideo.m */; }; 499E7E9F24E6A72900F1D96C /* OMAdColonyAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 499E7E9A24E6A72800F1D96C /* OMAdColonyAdapter.m */; }; 499E7EA024E6A72900F1D96C /* OMAdColonyAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 499E7E9B24E6A72800F1D96C /* OMAdColonyAdapter.h */; }; 499E7EA124E6A72900F1D96C /* OMAdColonyRewardedVideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 499E7E9C24E6A72800F1D96C /* OMAdColonyRewardedVideo.h */; }; 499E7EA224E6A72900F1D96C /* OMAdColonyClass.h in Headers */ = {isa = PBXBuildFile; fileRef = 499E7E9D24E6A72900F1D96C /* OMAdColonyClass.h */; }; + 49B2A659255D48B400A22A9A /* OMCrossPromotionClRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B2A657255D48B300A22A9A /* OMCrossPromotionClRequest.h */; }; + 49B2A65A255D48B400A22A9A /* OMCrossPromotionClRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 49B2A658255D48B400A22A9A /* OMCrossPromotionClRequest.m */; }; + 49B2A681255E5B8400A22A9A /* OMCrossPromotionJSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B2A67F255E5B8400A22A9A /* OMCrossPromotionJSBridge.h */; }; + 49B2A682255E5B8400A22A9A /* OMCrossPromotionJSBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 49B2A680255E5B8400A22A9A /* OMCrossPromotionJSBridge.m */; }; + 49B2A6CD255E8F0800A22A9A /* OMCrossPromotionExposureMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 49B2A6CB255E8F0700A22A9A /* OMCrossPromotionExposureMonitor.m */; }; + 49B2A6CE255E8F0800A22A9A /* OMCrossPromotionExposureMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B2A6CC255E8F0700A22A9A /* OMCrossPromotionExposureMonitor.h */; }; + 49B2A707255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B2A705255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.h */; }; + 49B2A708255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.m in Sources */ = {isa = PBXBuildFile; fileRef = 49B2A706255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.m */; }; + 49B2A71D255EA62D00A22A9A /* OMCrossPromotionVideoController.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B2A71B255EA62C00A22A9A /* OMCrossPromotionVideoController.h */; }; + 49B2A71E255EA62D00A22A9A /* OMCrossPromotionVideoController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49B2A71C255EA62D00A22A9A /* OMCrossPromotionVideoController.m */; }; 49C0F93024DAF14700C20F54 /* OMAdTimingAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C0F91B24DAF14500C20F54 /* OMAdTimingAdapter.h */; }; 49C0F93124DAF14700C20F54 /* OMAdTimingNative.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C0F91C24DAF14500C20F54 /* OMAdTimingNative.h */; }; 49C0F93224DAF14700C20F54 /* OMAdTimingAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 49C0F91D24DAF14500C20F54 /* OMAdTimingAdapter.m */; }; @@ -418,6 +449,30 @@ 49DF722B23E948840033495A /* OpenMediationAdFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DF722A23E948840033495A /* OpenMediationAdFormats.h */; settings = {ATTRIBUTES = (Public, ); }; }; 49DF722F23E962710033495A /* OMAudience.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DF722D23E962710033495A /* OMAudience.h */; }; 49DF723023E962710033495A /* OMAudience.m in Sources */ = {isa = PBXBuildFile; fileRef = 49DF722E23E962710033495A /* OMAudience.m */; }; + 49EA8821255BC6C600D4B932 /* OMCDRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA881F255BC6C600D4B932 /* OMCDRequest.h */; }; + 49EA8822255BC6C600D4B932 /* OMCDRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8820255BC6C600D4B932 /* OMCDRequest.m */; }; + 49EA8834255BC71000D4B932 /* OMCrossPromotionNativeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8824255BC70F00D4B932 /* OMCrossPromotionNativeView.m */; }; + 49EA8835255BC71000D4B932 /* OMCrossPromotionNative.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA8825255BC70F00D4B932 /* OMCrossPromotionNative.h */; }; + 49EA8837255BC71000D4B932 /* OMCrossPromotionBanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA8827255BC70F00D4B932 /* OMCrossPromotionBanner.h */; }; + 49EA8838255BC71000D4B932 /* OMCrossPromotionNativeAd.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8828255BC70F00D4B932 /* OMCrossPromotionNativeAd.m */; }; + 49EA8839255BC71000D4B932 /* OMCrossPromotionBid.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8829255BC70F00D4B932 /* OMCrossPromotionBid.m */; }; + 49EA883A255BC71000D4B932 /* OMCrossPromotionNativeAd.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA882A255BC70F00D4B932 /* OMCrossPromotionNativeAd.h */; }; + 49EA883B255BC71000D4B932 /* OMCrossPromotionRewardedVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA882B255BC70F00D4B932 /* OMCrossPromotionRewardedVideo.m */; }; + 49EA883C255BC71000D4B932 /* OMCrossPromotionRewardedVideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA882C255BC70F00D4B932 /* OMCrossPromotionRewardedVideo.h */; }; + 49EA883D255BC71000D4B932 /* OMCrossPromotionNative.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA882D255BC70F00D4B932 /* OMCrossPromotionNative.m */; }; + 49EA883E255BC71000D4B932 /* OMCrossPromotionBid.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA882E255BC70F00D4B932 /* OMCrossPromotionBid.h */; }; + 49EA8840255BC71000D4B932 /* OMCrossPromotionNativeView.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA8830255BC71000D4B932 /* OMCrossPromotionNativeView.h */; }; + 49EA8841255BC71000D4B932 /* OMCrossPromotionBanner.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8831255BC71000D4B932 /* OMCrossPromotionBanner.m */; }; + 49EA8849255BD01C00D4B932 /* OMCrossPromotionCampaignManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA8847255BD01C00D4B932 /* OMCrossPromotionCampaignManager.h */; }; + 49EA884A255BD01C00D4B932 /* OMCrossPromotionCampaignManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8848255BD01C00D4B932 /* OMCrossPromotionCampaignManager.m */; }; + 49EA884D255BD08500D4B932 /* OMCrossPromotionCampaign.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA884B255BD08500D4B932 /* OMCrossPromotionCampaign.h */; }; + 49EA884E255BD08500D4B932 /* OMCrossPromotionCampaign.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA884C255BD08500D4B932 /* OMCrossPromotionCampaign.m */; }; + 49EA8851255BD0B800D4B932 /* OMCrossPromotionClickHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA884F255BD0B800D4B932 /* OMCrossPromotionClickHandler.h */; }; + 49EA8852255BD0B800D4B932 /* OMCrossPromotionClickHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8850255BD0B800D4B932 /* OMCrossPromotionClickHandler.m */; }; + 49EA8859255BD11B00D4B932 /* OMCrossPromotionWebController.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA8857255BD11B00D4B932 /* OMCrossPromotionWebController.h */; }; + 49EA885A255BD11B00D4B932 /* OMCrossPromotionWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA8858255BD11B00D4B932 /* OMCrossPromotionWebController.m */; }; + 49EA885D255C273500D4B932 /* OMCrossPromotionCampaignModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EA885B255C273500D4B932 /* OMCrossPromotionCampaignModel.h */; }; + 49EA885E255C273500D4B932 /* OMCrossPromotionCampaignModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EA885C255C273500D4B932 /* OMCrossPromotionCampaignModel.m */; }; 49FD2BA423FCEAC600FFA0EF /* OMSmartLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 49FD2BA223FCEAC600FFA0EF /* OMSmartLoad.h */; }; 49FD2BA523FCEAC600FFA0EF /* OMSmartLoad.m in Sources */ = {isa = PBXBuildFile; fileRef = 49FD2BA323FCEAC600FFA0EF /* OMSmartLoad.m */; }; 49FD2BA823FD0CC300FFA0EF /* OMHbRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 49FD2BA623FD0CC300FFA0EF /* OMHbRequest.h */; }; @@ -559,6 +614,16 @@ name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; }; + 49EA87F7255BB9D000D4B932 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -723,6 +788,9 @@ 0CF881062473857600ED2CBD /* SplashViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SplashViewController.m; sourceTree = ""; }; 49097842240383EA00D39DF5 /* OMUnit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMUnit.m; sourceTree = ""; }; 490978442403841300D39DF5 /* NSError+OMExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+OMExtension.m"; sourceTree = ""; }; + 491B9C5C251DDCB2007A4310 /* OMVungleBidClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMVungleBidClass.h; path = Adapters/VungleAdapter/OMVungleBidClass.h; sourceTree = SOURCE_ROOT; }; + 491B9C5D251DDCB2007A4310 /* OMVungleBid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMVungleBid.h; path = Adapters/VungleAdapter/OMVungleBid.h; sourceTree = SOURCE_ROOT; }; + 491B9C5E251DDCB3007A4310 /* OMVungleBid.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OMVungleBid.m; path = Adapters/VungleAdapter/OMVungleBid.m; sourceTree = SOURCE_ROOT; }; 492018CE23F6C20C007C5EA4 /* OMLoad.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMLoad.h; sourceTree = ""; }; 492018CF23F6C20C007C5EA4 /* OMLoad.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMLoad.m; sourceTree = ""; }; 4924037A23F690DE00687456 /* ExportOptions.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ExportOptions.plist; sourceTree = ""; }; @@ -777,11 +845,40 @@ 4959CED923EBEE9400A433A8 /* OMMintegralAdapter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OMMintegralAdapter.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4959CEDC23EBEE9400A433A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4959CEFD23EC40D000A433A8 /* OpenMediation.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = OpenMediation.modulemap; sourceTree = ""; }; + 497B96DE255D244C0024592E /* OMCrossPromotionDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionDownloader.h; sourceTree = ""; }; + 497B96DF255D244C0024592E /* OMCrossPromotionDownloadManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionDownloadManager.h; sourceTree = ""; }; + 497B96E0255D244C0024592E /* OMCrossPromotionDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionDownloader.m; sourceTree = ""; }; + 497B96E1255D244C0024592E /* OMCrossPromotionHTTPCacheControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionHTTPCacheControl.m; sourceTree = ""; }; + 497B96E2255D244D0024592E /* OMCrossPromotionDownloadManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionDownloadManager.m; sourceTree = ""; }; + 497B96E3255D244D0024592E /* OMCrossPromotionHTTPCacheControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionHTTPCacheControl.h; sourceTree = ""; }; + 497B96E4255D244D0024592E /* OMCrossPromotionCacheFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionCacheFile.m; sourceTree = ""; }; + 497B96E5255D244D0024592E /* OMCrossPromotionCacheFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionCacheFile.h; sourceTree = ""; }; + 497F020B25650BF900354846 /* OMCrossPromotionAdDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionAdDelegate.h; sourceTree = ""; }; + 497F020C25650BF900354846 /* OMCrossPromotionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionDelegate.h; sourceTree = ""; }; + 497F020D25650BF900354846 /* OMCrossPromotionAd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionAd.h; sourceTree = ""; }; + 497F020E25650BF900354846 /* OMCrossPromotion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotion.m; sourceTree = ""; }; + 497F020F25650BF900354846 /* OMCrossPromotionAd.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionAd.m; sourceTree = ""; }; + 497F021025650BF900354846 /* OMCrossPromotion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotion.h; sourceTree = ""; }; + 497F028325650ECE00354846 /* OMCrossPromotionCustomEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionCustomEvent.h; sourceTree = ""; }; + 497F02A925661FE700354846 /* OMCrossPromotionCP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionCP.h; sourceTree = ""; }; + 497F02AA25661FE700354846 /* OMCrossPromotionCP.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionCP.m; sourceTree = ""; }; + 497F02BF2566416A00354846 /* CrossPromotionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrossPromotionViewController.h; sourceTree = ""; }; + 497F02C02566416A00354846 /* CrossPromotionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CrossPromotionViewController.m; sourceTree = ""; }; 499E7E9924E6A72800F1D96C /* OMAdColonyRewardedVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OMAdColonyRewardedVideo.m; path = Adapters/AdColonyAdapter/OMAdColonyRewardedVideo.m; sourceTree = SOURCE_ROOT; }; 499E7E9A24E6A72800F1D96C /* OMAdColonyAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OMAdColonyAdapter.m; path = Adapters/AdColonyAdapter/OMAdColonyAdapter.m; sourceTree = SOURCE_ROOT; }; 499E7E9B24E6A72800F1D96C /* OMAdColonyAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMAdColonyAdapter.h; path = Adapters/AdColonyAdapter/OMAdColonyAdapter.h; sourceTree = SOURCE_ROOT; }; 499E7E9C24E6A72800F1D96C /* OMAdColonyRewardedVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMAdColonyRewardedVideo.h; path = Adapters/AdColonyAdapter/OMAdColonyRewardedVideo.h; sourceTree = SOURCE_ROOT; }; 499E7E9D24E6A72900F1D96C /* OMAdColonyClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMAdColonyClass.h; path = Adapters/AdColonyAdapter/OMAdColonyClass.h; sourceTree = SOURCE_ROOT; }; + 49B2A657255D48B300A22A9A /* OMCrossPromotionClRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionClRequest.h; sourceTree = ""; }; + 49B2A658255D48B400A22A9A /* OMCrossPromotionClRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionClRequest.m; sourceTree = ""; }; + 49B2A67F255E5B8400A22A9A /* OMCrossPromotionJSBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionJSBridge.h; sourceTree = ""; }; + 49B2A680255E5B8400A22A9A /* OMCrossPromotionJSBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionJSBridge.m; sourceTree = ""; }; + 49B2A6CB255E8F0700A22A9A /* OMCrossPromotionExposureMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionExposureMonitor.m; sourceTree = ""; }; + 49B2A6CC255E8F0700A22A9A /* OMCrossPromotionExposureMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionExposureMonitor.h; sourceTree = ""; }; + 49B2A705255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionNativeMediaView.h; sourceTree = ""; }; + 49B2A706255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionNativeMediaView.m; sourceTree = ""; }; + 49B2A71B255EA62C00A22A9A /* OMCrossPromotionVideoController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionVideoController.h; sourceTree = ""; }; + 49B2A71C255EA62D00A22A9A /* OMCrossPromotionVideoController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionVideoController.m; sourceTree = ""; }; 49C0F91B24DAF14500C20F54 /* OMAdTimingAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMAdTimingAdapter.h; path = Adapters/AdTimingAdapter/OMAdTimingAdapter.h; sourceTree = SOURCE_ROOT; }; 49C0F91C24DAF14500C20F54 /* OMAdTimingNative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OMAdTimingNative.h; path = Adapters/AdTimingAdapter/OMAdTimingNative.h; sourceTree = SOURCE_ROOT; }; 49C0F91D24DAF14500C20F54 /* OMAdTimingAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OMAdTimingAdapter.m; path = Adapters/AdTimingAdapter/OMAdTimingAdapter.m; sourceTree = SOURCE_ROOT; }; @@ -1003,6 +1100,30 @@ 49DF722A23E948840033495A /* OpenMediationAdFormats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenMediationAdFormats.h; sourceTree = ""; }; 49DF722D23E962710033495A /* OMAudience.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMAudience.h; sourceTree = ""; }; 49DF722E23E962710033495A /* OMAudience.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMAudience.m; sourceTree = ""; }; + 49EA881F255BC6C600D4B932 /* OMCDRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCDRequest.h; sourceTree = ""; }; + 49EA8820255BC6C600D4B932 /* OMCDRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCDRequest.m; sourceTree = ""; }; + 49EA8824255BC70F00D4B932 /* OMCrossPromotionNativeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionNativeView.m; sourceTree = ""; }; + 49EA8825255BC70F00D4B932 /* OMCrossPromotionNative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionNative.h; sourceTree = ""; }; + 49EA8827255BC70F00D4B932 /* OMCrossPromotionBanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionBanner.h; sourceTree = ""; }; + 49EA8828255BC70F00D4B932 /* OMCrossPromotionNativeAd.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionNativeAd.m; sourceTree = ""; }; + 49EA8829255BC70F00D4B932 /* OMCrossPromotionBid.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionBid.m; sourceTree = ""; }; + 49EA882A255BC70F00D4B932 /* OMCrossPromotionNativeAd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionNativeAd.h; sourceTree = ""; }; + 49EA882B255BC70F00D4B932 /* OMCrossPromotionRewardedVideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionRewardedVideo.m; sourceTree = ""; }; + 49EA882C255BC70F00D4B932 /* OMCrossPromotionRewardedVideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionRewardedVideo.h; sourceTree = ""; }; + 49EA882D255BC70F00D4B932 /* OMCrossPromotionNative.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionNative.m; sourceTree = ""; }; + 49EA882E255BC70F00D4B932 /* OMCrossPromotionBid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionBid.h; sourceTree = ""; }; + 49EA8830255BC71000D4B932 /* OMCrossPromotionNativeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionNativeView.h; sourceTree = ""; }; + 49EA8831255BC71000D4B932 /* OMCrossPromotionBanner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionBanner.m; sourceTree = ""; }; + 49EA8847255BD01C00D4B932 /* OMCrossPromotionCampaignManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionCampaignManager.h; sourceTree = ""; }; + 49EA8848255BD01C00D4B932 /* OMCrossPromotionCampaignManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionCampaignManager.m; sourceTree = ""; }; + 49EA884B255BD08500D4B932 /* OMCrossPromotionCampaign.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionCampaign.h; sourceTree = ""; }; + 49EA884C255BD08500D4B932 /* OMCrossPromotionCampaign.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionCampaign.m; sourceTree = ""; }; + 49EA884F255BD0B800D4B932 /* OMCrossPromotionClickHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionClickHandler.h; sourceTree = ""; }; + 49EA8850255BD0B800D4B932 /* OMCrossPromotionClickHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionClickHandler.m; sourceTree = ""; }; + 49EA8857255BD11B00D4B932 /* OMCrossPromotionWebController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionWebController.h; sourceTree = ""; }; + 49EA8858255BD11B00D4B932 /* OMCrossPromotionWebController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionWebController.m; sourceTree = ""; }; + 49EA885B255C273500D4B932 /* OMCrossPromotionCampaignModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMCrossPromotionCampaignModel.h; sourceTree = ""; }; + 49EA885C255C273500D4B932 /* OMCrossPromotionCampaignModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMCrossPromotionCampaignModel.m; sourceTree = ""; }; 49FD2BA223FCEAC600FFA0EF /* OMSmartLoad.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMSmartLoad.h; sourceTree = ""; }; 49FD2BA323FCEAC600FFA0EF /* OMSmartLoad.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OMSmartLoad.m; sourceTree = ""; }; 49FD2BA623FD0CC300FFA0EF /* OMHbRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OMHbRequest.h; sourceTree = ""; }; @@ -1242,11 +1363,13 @@ 49DE5A0923EC459F00F89345 /* OpenMediationUmbrella.h */, 4959CEFD23EC40D000A433A8 /* OpenMediation.modulemap */, 0C70AA2623D162E70021D67A /* Info.plist */, + 49EA881E255BC61500D4B932 /* OpenMediationPromotion */, 49468C0C24B75A2F00AF4E06 /* OpenMediationBid */, 0C86483423EA621E00CB942D /* OpenMediationBanner */, 0C86487323EA6FA300CB942D /* OpenMediationNative */, 0C86486023EA68E200CB942D /* OpenMediationInterstitial */, 0C86488C23EA73C300CB942D /* OpenMediationRewardedVideo */, + 497F020A25650BCE00354846 /* OpenMediationCrossPromotion */, 0CF880F82473847A00ED2CBD /* OpenMediationSplash */, 4959CEE623EBF09E00A433A8 /* OpenMediationCustomEvent */, 49DF722C23E9620D0033495A /* OpenMediaitonSegments */, @@ -1332,6 +1455,8 @@ 49FD2BA723FD0CC300FFA0EF /* OMHbRequest.m */, 49D1B85A23EA78CB0028CB5C /* OMEventRequest.h */, 49D1B85B23EA78CC0028CB5C /* OMEventRequest.m */, + 49EA881F255BC6C600D4B932 /* OMCDRequest.h */, + 49EA8820255BC6C600D4B932 /* OMCDRequest.m */, ); path = OpenMediationNetwork; sourceTree = ""; @@ -1460,6 +1585,8 @@ 0C981BF523D6D9A80074B43A /* RewardedVideoViewController.m */, 0CF881052473857500ED2CBD /* SplashViewController.h */, 0CF881062473857600ED2CBD /* SplashViewController.m */, + 497F02BF2566416A00354846 /* CrossPromotionViewController.h */, + 497F02C02566416A00354846 /* CrossPromotionViewController.m */, 0C981BDC23D6D6360074B43A /* BaseViewController.h */, 0C981BDD23D6D6360074B43A /* BaseViewController.m */, 0C981BCA23D69A1D0074B43A /* Main.storyboard */, @@ -1591,6 +1718,9 @@ 4959CE7423EBEDDF00A433A8 /* OMVungleAdapter */ = { isa = PBXGroup; children = ( + 491B9C5D251DDCB2007A4310 /* OMVungleBid.h */, + 491B9C5E251DDCB3007A4310 /* OMVungleBid.m */, + 491B9C5C251DDCB2007A4310 /* OMVungleBidClass.h */, 49C0F9E324DAF28400C20F54 /* OMVungleSplash.h */, 49C0F9E424DAF28400C20F54 /* OMVungleSplash.m */, 49C0F9B324DAF1C100C20F54 /* OMVungleAdapter.h */, @@ -1738,10 +1868,24 @@ 0C86486223EA68E200CB942D /* OMInterstitialCustomEvent.h */, 0C86489223EA73C300CB942D /* OMRewardedVideoCustomEvent.h */, 0CF88103247384C900ED2CBD /* OMSplashCustomEvent.h */, + 497F028325650ECE00354846 /* OMCrossPromotionCustomEvent.h */, ); path = OpenMediationCustomEvent; sourceTree = ""; }; + 497F020A25650BCE00354846 /* OpenMediationCrossPromotion */ = { + isa = PBXGroup; + children = ( + 497F021025650BF900354846 /* OMCrossPromotion.h */, + 497F020E25650BF900354846 /* OMCrossPromotion.m */, + 497F020D25650BF900354846 /* OMCrossPromotionAd.h */, + 497F020F25650BF900354846 /* OMCrossPromotionAd.m */, + 497F020B25650BF900354846 /* OMCrossPromotionAdDelegate.h */, + 497F020C25650BF900354846 /* OMCrossPromotionDelegate.h */, + ); + path = OpenMediationCrossPromotion; + sourceTree = ""; + }; 49C1CF0324AF48B70093F489 /* OMChartboostBidAdapter */ = { isa = PBXGroup; children = ( @@ -1887,6 +2031,55 @@ path = OpenMediaitonSegments; sourceTree = ""; }; + 49EA881E255BC61500D4B932 /* OpenMediationPromotion */ = { + isa = PBXGroup; + children = ( + 49EA882E255BC70F00D4B932 /* OMCrossPromotionBid.h */, + 49EA8829255BC70F00D4B932 /* OMCrossPromotionBid.m */, + 49EA8827255BC70F00D4B932 /* OMCrossPromotionBanner.h */, + 49EA8831255BC71000D4B932 /* OMCrossPromotionBanner.m */, + 49EA8825255BC70F00D4B932 /* OMCrossPromotionNative.h */, + 49EA882D255BC70F00D4B932 /* OMCrossPromotionNative.m */, + 49EA882A255BC70F00D4B932 /* OMCrossPromotionNativeAd.h */, + 49EA8828255BC70F00D4B932 /* OMCrossPromotionNativeAd.m */, + 49EA8830255BC71000D4B932 /* OMCrossPromotionNativeView.h */, + 49EA8824255BC70F00D4B932 /* OMCrossPromotionNativeView.m */, + 49B2A705255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.h */, + 49B2A706255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.m */, + 49EA882C255BC70F00D4B932 /* OMCrossPromotionRewardedVideo.h */, + 49EA882B255BC70F00D4B932 /* OMCrossPromotionRewardedVideo.m */, + 49B2A71B255EA62C00A22A9A /* OMCrossPromotionVideoController.h */, + 49B2A71C255EA62D00A22A9A /* OMCrossPromotionVideoController.m */, + 497F02A925661FE700354846 /* OMCrossPromotionCP.h */, + 497F02AA25661FE700354846 /* OMCrossPromotionCP.m */, + 49B2A67F255E5B8400A22A9A /* OMCrossPromotionJSBridge.h */, + 49B2A680255E5B8400A22A9A /* OMCrossPromotionJSBridge.m */, + 49EA8847255BD01C00D4B932 /* OMCrossPromotionCampaignManager.h */, + 49EA8848255BD01C00D4B932 /* OMCrossPromotionCampaignManager.m */, + 49EA884B255BD08500D4B932 /* OMCrossPromotionCampaign.h */, + 49EA884C255BD08500D4B932 /* OMCrossPromotionCampaign.m */, + 49EA885B255C273500D4B932 /* OMCrossPromotionCampaignModel.h */, + 49EA885C255C273500D4B932 /* OMCrossPromotionCampaignModel.m */, + 49EA884F255BD0B800D4B932 /* OMCrossPromotionClickHandler.h */, + 49EA8850255BD0B800D4B932 /* OMCrossPromotionClickHandler.m */, + 49EA8857255BD11B00D4B932 /* OMCrossPromotionWebController.h */, + 49EA8858255BD11B00D4B932 /* OMCrossPromotionWebController.m */, + 497B96DF255D244C0024592E /* OMCrossPromotionDownloadManager.h */, + 497B96E2255D244D0024592E /* OMCrossPromotionDownloadManager.m */, + 497B96DE255D244C0024592E /* OMCrossPromotionDownloader.h */, + 497B96E0255D244C0024592E /* OMCrossPromotionDownloader.m */, + 497B96E5255D244D0024592E /* OMCrossPromotionCacheFile.h */, + 497B96E4255D244D0024592E /* OMCrossPromotionCacheFile.m */, + 497B96E3255D244D0024592E /* OMCrossPromotionHTTPCacheControl.h */, + 497B96E1255D244C0024592E /* OMCrossPromotionHTTPCacheControl.m */, + 49B2A657255D48B300A22A9A /* OMCrossPromotionClRequest.h */, + 49B2A658255D48B400A22A9A /* OMCrossPromotionClRequest.m */, + 49B2A6CC255E8F0700A22A9A /* OMCrossPromotionExposureMonitor.h */, + 49B2A6CB255E8F0700A22A9A /* OMCrossPromotionExposureMonitor.m */, + ); + path = OpenMediationPromotion; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -1894,16 +2087,27 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 497F021225650BF900354846 /* OMCrossPromotionDelegate.h in Headers */, + 497F021625650BF900354846 /* OMCrossPromotion.h in Headers */, + 49EA8837255BC71000D4B932 /* OMCrossPromotionBanner.h in Headers */, 0C86488823EA6FA400CB942D /* OMNativeDelegate.h in Headers */, 0C0F88E223D42E4B002AB5C7 /* OMScene.h in Headers */, + 497F021125650BF900354846 /* OMCrossPromotionAdDelegate.h in Headers */, 0C5DB6BF23E9822400842709 /* OMAdBase.h in Headers */, + 49EA883A255BC71000D4B932 /* OMCrossPromotionNativeAd.h in Headers */, 0C5DB6BD23E9822400842709 /* OMAdSingletonInterface.h in Headers */, + 49EA883C255BC71000D4B932 /* OMCrossPromotionRewardedVideo.h in Headers */, 49DE5A0A23EC459F00F89345 /* OpenMediationUmbrella.h in Headers */, 0C86489A23EA73C300CB942D /* OMRewardedVideoDelegate.h in Headers */, 0C86489E23EA73C300CB942D /* OMRewardedVideo.h in Headers */, 0C86488123EA6FA400CB942D /* OMNativeView.h in Headers */, + 49B2A6CE255E8F0800A22A9A /* OMCrossPromotionExposureMonitor.h in Headers */, + 497F028425650ECE00354846 /* OMCrossPromotionCustomEvent.h in Headers */, + 49B2A659255D48B400A22A9A /* OMCrossPromotionClRequest.h in Headers */, 0C86488A23EA6FA400CB942D /* OMNativeMediaView.h in Headers */, 0C86488923EA6FA400CB942D /* OMNativeAd.h in Headers */, + 497B96E7255D244D0024592E /* OMCrossPromotionDownloadManager.h in Headers */, + 49B2A681255E5B8400A22A9A /* OMCrossPromotionJSBridge.h in Headers */, 49DE5A0D23EC4BAE00F89345 /* OMDependTask.h in Headers */, 0C86488423EA6FA400CB942D /* OMNative.h in Headers */, 0CF88104247384C900ED2CBD /* OMSplashCustomEvent.h in Headers */, @@ -1912,6 +2116,7 @@ 0CF881012473847A00ED2CBD /* OMSplash.h in Headers */, 49468C1824B75A2F00AF4E06 /* OMBidNetworkItem.h in Headers */, 0CF881022473847A00ED2CBD /* OMSplashDelegate.h in Headers */, + 497B96EB255D244D0024592E /* OMCrossPromotionHTTPCacheControl.h in Headers */, 0CF880FE2473847A00ED2CBD /* OMSplashAd.h in Headers */, 0C86486C23EA68E300CB942D /* OMInterstitial.h in Headers */, 0C86485023EA628400CB942D /* OMBannerDelegate.h in Headers */, @@ -1919,6 +2124,7 @@ 0C86484C23EA628400CB942D /* OMBanner.h in Headers */, 0C86485323EA632800CB942D /* OMModelUmbrella.h in Headers */, 0C5DB6C023E9822400842709 /* OMLoadFrequencryControl.h in Headers */, + 49EA8821255BC6C600D4B932 /* OMCDRequest.h in Headers */, 0C5DB6C123E9822400842709 /* OMAdBasePrivate.h in Headers */, 49DF722B23E948840033495A /* OpenMediationAdFormats.h in Headers */, 0C70AA5C23D165F80021D67A /* OpenMediation.h in Headers */, @@ -1926,9 +2132,13 @@ 49D1B84F23E97FEC0028CB5C /* OMCrashHandle.h in Headers */, 49DF722F23E962710033495A /* OMAudience.h in Headers */, 0C86488623EA6FA400CB942D /* OMNativeViewCustomEvent.h in Headers */, + 49EA883E255BC71000D4B932 /* OMCrossPromotionBid.h in Headers */, + 49EA885D255C273500D4B932 /* OMCrossPromotionCampaignModel.h in Headers */, 0CF1EEEB23D30C0E00D98999 /* NSData+OMGzip.h in Headers */, 0C86489B23EA73C300CB942D /* OMRewardedVideoCustomEvent.h in Headers */, + 497F021325650BF900354846 /* OMCrossPromotionAd.h in Headers */, 0C5DB60D23E93D1000842709 /* OMErrorRequest.h in Headers */, + 497F02AB25661FE700354846 /* OMCrossPromotionCP.h in Headers */, 0C70AC2523D1968E0021D67A /* OMInitRequest.h in Headers */, 0C5DB67923E9670E00842709 /* OMError.h in Headers */, 0C70AC3123D19FEF0021D67A /* UIDevice+OMExtension.h in Headers */, @@ -1937,6 +2147,8 @@ 0C0F88D623D42DD0002AB5C7 /* OMConfig.h in Headers */, 49FD2BAC23FD619800FFA0EF /* OMHybridLoad.h in Headers */, 0C981B9123D55ECE0074B43A /* OMReachability+OMExtentsion.h in Headers */, + 49EA8859255BD11B00D4B932 /* OMCrossPromotionWebController.h in Headers */, + 49B2A71D255EA62D00A22A9A /* OMCrossPromotionVideoController.h in Headers */, 49468C1A24B75A2F00AF4E06 /* OMBidResponse.h in Headers */, 0C86486B23EA68E300CB942D /* OMInterstitialCustomEvent.h in Headers */, 0C70AC4323D1A5920021D67A /* OMBaseRequest.h in Headers */, @@ -1944,14 +2156,19 @@ 0C70AC3423D1A0CC0021D67A /* OMMacros.h in Headers */, 0C0F88DE23D42E3A002AB5C7 /* OMUnit.h in Headers */, 0C5DB64F23E94D9900842709 /* NSString+OMEncrypt.h in Headers */, + 49EA8835255BC71000D4B932 /* OMCrossPromotionNative.h in Headers */, 0C86485B23EA64D200CB942D /* UIView+OMExtentsion.h in Headers */, + 497B96ED255D244D0024592E /* OMCrossPromotionCacheFile.h in Headers */, 0C70AC2123D196110021D67A /* OMRequest.h in Headers */, 0C981B9B23D58FEB0074B43A /* OMMediations.h in Headers */, 0C86489623EA73C300CB942D /* OMRewardedVideoAd.h in Headers */, 49DF722623E93F160033495A /* OMMediationAdapter.h in Headers */, 0C5DB67123E958AF00842709 /* OMWeakObject.h in Headers */, + 49B2A707255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.h in Headers */, + 497B96E6255D244D0024592E /* OMCrossPromotionDownloader.h in Headers */, 0C86484D23EA628400CB942D /* OMBannerAd.h in Headers */, 0C70AC4723D1A76D0021D67A /* NSError+OMExtension.h in Headers */, + 49EA8840255BC71000D4B932 /* OMCrossPromotionNativeView.h in Headers */, 49FD2BA423FCEAC600FFA0EF /* OMSmartLoad.h in Headers */, 0C86484F23EA628400CB942D /* OMBannerCustomEvent.h in Headers */, 49D1B85323E980040028CB5C /* OMBacktrace.h in Headers */, @@ -1972,12 +2189,15 @@ 0C5DB6BE23E9822400842709 /* OMAdSingletonInterfacePrivate.h in Headers */, 0C70AC3F23D1A4000021D67A /* OMReachability.h in Headers */, 0C86488723EA6FA400CB942D /* OMMediatedNativeAd.h in Headers */, + 49EA8851255BD0B800D4B932 /* OMCrossPromotionClickHandler.h in Headers */, 0C5DB67A23E9670E00842709 /* OMSDKError.h in Headers */, + 49EA884D255BD08500D4B932 /* OMCrossPromotionCampaign.h in Headers */, 0C70AA5E23D167E00021D67A /* OpenMediationConstant.h in Headers */, 0C0E580B23E82C3A0015C456 /* OMWaterfallRequest.h in Headers */, 0C5DB6A923E97C0100842709 /* OMCustomEventDelegate.h in Headers */, 0C86485F23EA675A00CB942D /* OMExposureMonitor.h in Headers */, 0C0F88DA23D42E29002AB5C7 /* OMInstance.h in Headers */, + 49EA8849255BD01C00D4B932 /* OMCrossPromotionCampaignManager.h in Headers */, 0C981B9423D584140074B43A /* OMNetworkUmbrella.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2064,7 +2284,9 @@ 49C0F9E524DAF28400C20F54 /* OMVungleSplash.h in Headers */, 49C0F9BC24DAF1C100C20F54 /* OMVungleAdapter.h in Headers */, 49C0F9B424DAF1C100C20F54 /* OMVungleClass.h in Headers */, + 491B9C5F251DDCB3007A4310 /* OMVungleBidClass.h in Headers */, 49C0F9B924DAF1C100C20F54 /* OMVungleRewardedVideo.h in Headers */, + 491B9C60251DDCB3007A4310 /* OMVungleBid.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2279,6 +2501,7 @@ 0C981BBC23D69A1D0074B43A /* Frameworks */, 0C981BBD23D69A1D0074B43A /* Resources */, 492403A323F69CCC00687456 /* Embed App Extensions */, + 49EA87F7255BB9D000D4B932 /* Embed Frameworks */, ); buildRules = ( ); @@ -2841,13 +3064,18 @@ 0C70AC2E23D198DE0021D67A /* NSDate+OMExtension.m in Sources */, 0C0E580823E820EA0015C456 /* OMIcRequest.m in Sources */, 0C5DB60E23E93D1000842709 /* OMErrorRequest.m in Sources */, + 497B96E9255D244D0024592E /* OMCrossPromotionHTTPCacheControl.m in Sources */, + 49EA885E255C273500D4B932 /* OMCrossPromotionCampaignModel.m in Sources */, 0C5DB64E23E94D9900842709 /* NSString+OMEncrypt.m in Sources */, 0C86489923EA73C300CB942D /* OMRewardedVideo.m in Sources */, 0C0E580423E814ED0015C456 /* OMIAPRequest.m in Sources */, 49097843240383EA00D39DF5 /* OMUnit.m in Sources */, 0C70AC2223D196110021D67A /* OMRequest.m in Sources */, + 49EA8838255BC71000D4B932 /* OMCrossPromotionNativeAd.m in Sources */, 49468C1624B75A2F00AF4E06 /* OMBidResponse.m in Sources */, + 49B2A65A255D48B400A22A9A /* OMCrossPromotionClRequest.m in Sources */, 49D1B85D23EA78CC0028CB5C /* OMEventRequest.m in Sources */, + 49EA883D255BC71000D4B932 /* OMCrossPromotionNative.m in Sources */, 0C981B9223D55ECE0074B43A /* OMReachability+OMExtentsion.m in Sources */, 0C0E580C23E82C3A0015C456 /* OMWaterfallRequest.m in Sources */, 492018D123F6C20C007C5EA4 /* OMLoad.m in Sources */, @@ -2857,11 +3085,17 @@ 0C0F88DB23D42E29002AB5C7 /* OMInstance.m in Sources */, 0C86485923EA64D200CB942D /* UIView+OMExtentsion.m in Sources */, 0C86485123EA628400CB942D /* OMBanner.m in Sources */, + 49EA884E255BD08500D4B932 /* OMCrossPromotionCampaign.m in Sources */, + 49B2A6CD255E8F0800A22A9A /* OMCrossPromotionExposureMonitor.m in Sources */, 49FD2BA923FD0CC300FFA0EF /* OMHbRequest.m in Sources */, 0C86487023EA68E300CB942D /* OMInterstitialAd.m in Sources */, + 497F02AC25661FE700354846 /* OMCrossPromotionCP.m in Sources */, + 49B2A71E255EA62D00A22A9A /* OMCrossPromotionVideoController.m in Sources */, + 497B96E8255D244D0024592E /* OMCrossPromotionDownloader.m in Sources */, 0C0E57FC23E7EE4B0015C456 /* OMLrRequest.m in Sources */, 49DE5A0E23EC4BAE00F89345 /* OMDependTask.m in Sources */, 0C5DB6BA23E9822400842709 /* OMLoadFrequencryControl.m in Sources */, + 49EA8834255BC71000D4B932 /* OMCrossPromotionNativeView.m in Sources */, 0C86488323EA6FA400CB942D /* OMNativeMediaView.m in Sources */, 0CF1EEEC23D30C0E00D98999 /* NSData+OMGzip.m in Sources */, 0C5DB67223E958AF00842709 /* OMWeakObject.m in Sources */, @@ -2873,10 +3107,15 @@ 0C0F88E323D42E4B002AB5C7 /* OMScene.m in Sources */, 0C70AC3223D19FEF0021D67A /* UIDevice+OMExtension.m in Sources */, 0CF880FF2473847A00ED2CBD /* OMSplash.m in Sources */, + 49EA8841255BC71000D4B932 /* OMCrossPromotionBanner.m in Sources */, 0C70AA5A23D165DC0021D67A /* OpenMediation.m in Sources */, 0C0F88D723D42DD0002AB5C7 /* OMConfig.m in Sources */, 0C86484E23EA628400CB942D /* OMBannerAd.m in Sources */, 0C5DB68A23E9726D00842709 /* NSNumber+OMExtension.m in Sources */, + 49EA8822255BC6C600D4B932 /* OMCDRequest.m in Sources */, + 497B96EA255D244D0024592E /* OMCrossPromotionDownloadManager.m in Sources */, + 49B2A682255E5B8400A22A9A /* OMCrossPromotionJSBridge.m in Sources */, + 49EA883B255BC71000D4B932 /* OMCrossPromotionRewardedVideo.m in Sources */, 0C86485A23EA64D200CB942D /* UIViewController+OMExtension.m in Sources */, 0C5DB67723E9670E00842709 /* OMError.m in Sources */, 0C86488523EA6FA400CB942D /* OMNativeView.m in Sources */, @@ -2884,17 +3123,25 @@ 0C70AC4423D1A5920021D67A /* OMBaseRequest.m in Sources */, 0C70AC3823D1A1C50021D67A /* OMKeychain.m in Sources */, 0C70AC2623D1968E0021D67A /* OMInitRequest.m in Sources */, + 49EA885A255BD11B00D4B932 /* OMCrossPromotionWebController.m in Sources */, 49468C1524B75A2F00AF4E06 /* OMBidNetworkItem.m in Sources */, + 497B96EC255D244D0024592E /* OMCrossPromotionCacheFile.m in Sources */, + 497F021525650BF900354846 /* OMCrossPromotionAd.m in Sources */, 49FD2BAD23FD619800FFA0EF /* OMHybridLoad.m in Sources */, + 49EA8839255BC71000D4B932 /* OMCrossPromotionBid.m in Sources */, 0C5DB6B823E9822400842709 /* OMAdSingletonInterface.m in Sources */, + 49EA8852255BD0B800D4B932 /* OMCrossPromotionClickHandler.m in Sources */, + 497F021425650BF900354846 /* OMCrossPromotion.m in Sources */, 49FD2BA523FCEAC600FFA0EF /* OMSmartLoad.m in Sources */, 0C5DB67823E9670E00842709 /* OMSDKError.m in Sources */, 0C70AC2A23D198600021D67A /* OMLogMoudle.m in Sources */, 0C5DB6AA23E97C0100842709 /* OMInstanceContainer.m in Sources */, 0C5DB64A23E94D1500842709 /* NSString+OMExtension.m in Sources */, + 49EA884A255BD01C00D4B932 /* OMCrossPromotionCampaignManager.m in Sources */, 49D1B86223EA7C620028CB5C /* OMEventManager.m in Sources */, 0C981B9C23D58FEB0074B43A /* OMMediations.m in Sources */, 0C70AC3C23D1A3D00021D67A /* OMNetMonitor.m in Sources */, + 49B2A708255EA12E00A22A9A /* OMCrossPromotionNativeMediaView.m in Sources */, 0C86485E23EA675A00CB942D /* OMExposureMonitor.m in Sources */, 49DF723023E962710033495A /* OMAudience.m in Sources */, 0C86488223EA6FA400CB942D /* OMNativeAd.m in Sources */, @@ -2923,6 +3170,7 @@ 0C981BF023D6D97B0074B43A /* NativeViewController.m in Sources */, 0C981BFC23D6DB4E0074B43A /* MainViewController.m in Sources */, 0C981BF623D6D9A80074B43A /* RewardedVideoViewController.m in Sources */, + 497F02C12566416A00354846 /* CrossPromotionViewController.m in Sources */, 0C981BC323D69A1D0074B43A /* AppDelegate.m in Sources */, 0C981BDE23D6D6360074B43A /* BaseViewController.m in Sources */, 0CF881072473857600ED2CBD /* SplashViewController.m in Sources */, @@ -2979,6 +3227,7 @@ files = ( 49C0F9E624DAF28400C20F54 /* OMVungleSplash.m in Sources */, 49C0F9B624DAF1C100C20F54 /* OMVungleBanner.m in Sources */, + 491B9C61251DDCB3007A4310 /* OMVungleBid.m in Sources */, 49C0F9B524DAF1C100C20F54 /* OMVungleRouter.m in Sources */, 49C0F9BB24DAF1C100C20F54 /* OMVungleAdapter.m in Sources */, 49C0F9B824DAF1C100C20F54 /* OMVungleRewardedVideo.m in Sources */, @@ -3360,7 +3609,7 @@ ); LINK_WITH_STANDARD_LIBRARIES = YES; MACH_O_TYPE = staticlib; - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.3.4; MODULEMAP_FILE = OpenMediation/OpenMediation.modulemap; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.openmediation.mediationsdk; @@ -3389,7 +3638,7 @@ ); LINK_WITH_STANDARD_LIBRARIES = YES; MACH_O_TYPE = staticlib; - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.3.4; MODULEMAP_FILE = OpenMediation/OpenMediation.modulemap; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.openmediation.mediationsdk; @@ -3467,7 +3716,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.3.4; OTHER_LDFLAGS = ( "-ObjC", "$(inherited)", @@ -3495,7 +3744,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.3.4; OTHER_LDFLAGS = ( "-ObjC", "$(inherited)", diff --git a/OpenMediation/Info.plist b/OpenMediation/Info.plist index edb1931..c0701c6 100644 --- a/OpenMediation/Info.plist +++ b/OpenMediation/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.3.0 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/OpenMediation/OpenMediaitonSegments/OMAdBase.m b/OpenMediation/OpenMediaitonSegments/OMAdBase.m index 6b29578..efb299f 100644 --- a/OpenMediation/OpenMediaitonSegments/OMAdBase.m +++ b/OpenMediation/OpenMediaitonSegments/OMAdBase.m @@ -15,10 +15,7 @@ #import "OMEventManager.h" #import "OpenMediation.h" #import "OMBid.h" - -@protocol OMBidCustomEvent -- (void)loadAdWithBidPayload:(NSString *)bidPayload; -@end +#import "OMInterstitialCustomEvent.h" #define OMDefaultMaxTimeoutMS 5000 @@ -92,7 +89,7 @@ - (void)loadAd:(OpenMediationAdFormat)adFormat actionType:(OMLoadAction)action { [self loadAdWithAction:action]; } } realTaskCheckValues:@[@"0"] realTask:^{ - [OpenMediation initWithAppKey:[OMConfig sharedInstance].appKey]; + [OpenMediation initWithAppKey:[OMConfig sharedInstance].appKey baseHost:[OMConfig sharedInstance].baseHost]; }]; } @@ -126,12 +123,11 @@ - (NSArray*)bidNetworkItmes:(NSArray*)intances { for (NSString *instanceID in intances) { OMInstance *bidInstance = [config getInstanceByinstanceID:[NSString stringWithFormat:@"%@",instanceID]]; if (bidInstance) { - id adapter = [_instanceAdapters objectForKey:bidInstance.instanceID]; - if (!(adapter && [adapter respondsToSelector:@selector(isReady)] && [adapter isReady] )) { - NSString *adnName = [config.adnNameMap objectForKey:@(bidInstance.adnID)]; - NSString *appKey = [config.adnAppkeyMap objectForKey:@(bidInstance.adnID)]; - OMBidNetworkItem *bidNetworkItem = [OMBidNetworkItem networkItemWithName:adnName appKey:appKey placementID:bidInstance.adnPlacementID timeOut:((bidInstance.hbt<1000)?OMDefaultMaxTimeoutMS:bidInstance.hbt) test:OMBidTest extra:@{@"instanceID":bidInstance.instanceID,@"platformID":[NSNumber numberWithInteger:bidInstance.adnID],@"prefix":@"OM"}]; - [bidItems addObject:bidNetworkItem]; + NSString *adnName = [config.adnNameMap objectForKey:@(bidInstance.adnID)]; + NSString *appKey = [config.adnAppkeyMap objectForKey:@(bidInstance.adnID)]; + OMBidNetworkItem *bidNetworkItem = [OMBidNetworkItem networkItemWithName:adnName appKey:appKey placementID:bidInstance.adnPlacementID timeOut:((bidInstance.hbt<1000)?OMDefaultMaxTimeoutMS:bidInstance.hbt) test:OMBidTest extra:@{@"instanceID":bidInstance.instanceID,@"adnID":[NSNumber numberWithInteger:bidInstance.adnID],@"prefix":@"OM"}]; + [bidItems addObject:bidNetworkItem]; + if (bidInstance.adnID == OMAdNetworkChartboostBid) { [self addEvent:INSTANCE_BID_REQUEST instance:bidInstance.instanceID extraData:nil]; } } @@ -147,9 +143,13 @@ - (void)getBidResponses:(OMLoadAction)action completionHandler:(void(^)(NSArray if (unit) { NSMutableArray *bidRequestInstances = [NSMutableArray array]; for (NSString *instanceID in unit.hbInstances) { - if ( (unit.adFormat == OpenMediationAdFormatRewardedVideo || unit.adFormat == OpenMediationAdFormatInterstitial) && [self.bidLoadInstances objectForKey:instanceID]) { + OMBidResponse *bidResponse = [self.bidLoadInstances objectForKey:instanceID]; + if ( (unit.adFormat == OpenMediationAdFormatRewardedVideo || unit.adFormat == OpenMediationAdFormatInterstitial) && (bidResponse && (bidResponse.expire <= 0 || (bidResponse.expire > (NSInteger)([NSDate date].timeIntervalSince1970*1000))))) { [bidSuccessResponses setObject:[self.bidLoadInstances objectForKey:instanceID] forKey:instanceID]; } else { + if (bidResponse) { + [bidResponse notifyLossWithReasonCode:OMBidLossedReasonCodeNotHiggestBidder]; + } [bidRequestInstances addObject:instanceID]; } } @@ -208,6 +208,11 @@ - (void)omLoadReqeustWithAction:(OMLoadAction)action { if (action == OMLoadActionTimer) { self.replenishLoad = YES; } + if (_adFormat == OpenMediationAdFormatCrossPromotion) { + [self.adLoader loadWithPriority:@[[[OMConfig sharedInstance]checkinstanceIDWithAdNetwork:OMAdNetworkCrossPromotion adnPlacementID:self.pid]]]; //交叉推广不请求wf接口 + return; + } + [self getBidResponses:action completionHandler:^(NSArray * _Nonnull tokens,NSDictionary * _Nonnull bidResponses) { self.bidInstances = [bidResponses copy]; @@ -233,6 +238,9 @@ - (void)omLoadReqeustWithAction:(OMLoadAction)action { if (!error) { self.abTest = [[ins objectForKey:@"abt"]boolValue]; + [[NSUserDefaults standardUserDefaults]setObject:[NSNumber numberWithBool:self.abTest] forKey:[NSString stringWithFormat:@"%@_abt",self.pid]]; + [[NSUserDefaults standardUserDefaults]synchronize]; + NSMutableDictionary *addBidResponse = [NSMutableDictionary dictionary]; if ([ins objectForKey:@"bidresp"] && [[ins objectForKey:@"bidresp"]isKindOfClass:[NSArray class]] ) { NSArray *responses = [ins objectForKey:@"bidresp"]; @@ -296,7 +304,7 @@ - (void)omLoadInstance:(NSString*)instanceID { [self addEvent:INSTANCE_NOT_FOUND instance:instanceID extraData:nil]; [self instanceLoadBlockWithError:OMErrorLoadInstanceNotFound instanceID:instanceID]; } else { - if ([[config adnAppKey:adnID]length]>0 || adnID == OMAdNetworkMopub) { + if ([[config adnAppKey:adnID]length]>0 || adnID == OMAdNetworkMopub || adnID == OMAdNetworkCrossPromotion) { if (![[OMMediations sharedInstance]adnSDKInitialized:adnID]) { //mediation init [self addEvent:INSTANCE_INIT_START instance:instanceID extraData:nil]; @@ -310,7 +318,7 @@ - (void)omLoadInstance:(NSString*)instanceID { } else { //init failed OMLogD(@"%@ %@ init failed: %@",self.pid,instanceID,error); - [self addEvent:INSTANCE_INIT_FAILED instance:instanceID extraData:@{@"msg":[error description]}]; + [self addEvent:INSTANCE_INIT_FAILED instance:instanceID extraData:@{@"msg":OM_SAFE_STRING([error description])}]; [weakSelf instanceLoadBlockWithError:OMErrorLoadInitFailed instanceID:instanceID]; } }]; @@ -333,7 +341,7 @@ - (void)loadInstance:(NSString*)instanceID { if (adapter && [adapter respondsToSelector:@selector(isReady)] && [adapter isReady]) { OMLogD(@"%@ load instance %@ ready true",self.pid,instanceID); - if (instanceBidResponse && (adnID == OMAdNetworkChartboostBid)) { + if (instanceBidResponse && (adnID == OMAdNetworkChartboostBid || adnID == OMAdNetworkVungle)) { @synchronized (self) { [_bidLoadInstances setObject:instanceBidResponse forKey:instanceID]; } @@ -384,14 +392,13 @@ - (void)omLoadFill:(NSString*)instanceID { if ((_adFormat < OpenMediationAdFormatRewardedVideo) || (_adFormat == OpenMediationAdFormatSplash)) { [self omDidLoad]; } else { - [self addEvent:AVAILABLE_FROM_CACHE instance:instanceID extraData:nil]; [self notifyAvailable:YES]; } } - (void)omLoadOptimalFill:(NSString*)instanceID { OMLogD(@"%@ Optimal fill instance %@",self.pid,instanceID); - [self notifyAvailable:YES]; +// [self notifyAvailable:YES]; } - (void)omLoadNoFill { @@ -638,6 +645,8 @@ - (void)showInstance:(id)instanceID { [[OMInstanceContainer sharedInstance]removeImpressionInstance:instanceID]; [self addEvent:INSTANCE_SHOW instance:instanceID extraData:nil]; } + [[NSUserDefaults standardUserDefaults]setObject:OM_SAFE_STRING(self.showSceneID) forKey:[NSString stringWithFormat:@"%@_scene",self.pid]]; + [[NSUserDefaults standardUserDefaults]synchronize]; } - (void)adshow:(id)instanceAdapter { @@ -729,6 +738,15 @@ - (void)dealloc{ #pragma mark - addEvent +- (void)customEventAddEvent:(NSObject*)adapter event:(NSDictionary*)body { + if([body isKindOfClass:[NSDictionary class]]&& [body objectForKey:@"eid"]) { + NSInteger eid = [[body objectForKey:@"eid"]integerValue]; + NSString *adapterInstanceID = [self checkInstanceIDWithAdapter:adapter]; + [self addEvent:eid instance:adapterInstanceID extraData:[body copy]]; + } +} + + - (void)addEvent:(NSInteger)eventID instance:(NSString*)instanceID extraData:data { NSMutableDictionary *wrapperData = [NSMutableDictionary dictionary]; @@ -744,9 +762,9 @@ - (void)addEvent:(NSInteger)eventID instance:(NSString*)instanceID extraData:dat OMAdNetwork adnID = [config getInstanceAdNetwork:instanceID]; [wrapperData setObject:[NSNumber omStr2Number:instanceID] forKey:@"iid"]; [wrapperData setObject:[NSNumber numberWithInteger:adnID] forKey:@"mid"]; - if([self.bidLoadInstances objectForKey:instanceID]){ + if([self.bidLoadInstances objectForKey:instanceID]) { OMBidResponse *bidResponse = [self.bidLoadInstances objectForKey:instanceID]; - if(bidResponse){ + if(bidResponse) { [wrapperData setObject:[NSNumber numberWithInt:1] forKey:@"bid"]; [wrapperData setObject:[NSNumber numberWithDouble:bidResponse.price] forKey:@"price"]; [wrapperData setObject:bidResponse.currency forKey:@"cur"]; diff --git a/OpenMediation/OpenMediaitonSegments/OMAudience.m b/OpenMediation/OpenMediaitonSegments/OMAudience.m index 177b04c..7ad84dd 100644 --- a/OpenMediation/OpenMediaitonSegments/OMAudience.m +++ b/OpenMediation/OpenMediaitonSegments/OMAudience.m @@ -27,7 +27,7 @@ -(void)userPurchase:(CGFloat)amout currency:(NSString*)currencyUnit { __weak __typeof(self) weakSelf = self; [OMIAPRequest iapWithPurchase:amout total:_purchaseAmount currency:currencyUnit completionHandler:^(NSDictionary * _Nullable object, NSError * _Nullable error) { if (!error && [object isKindOfClass:[NSDictionary class]] && weakSelf) { - weakSelf.purchaseAmount = [[object objectForKey:@"iap_usd"]floatValue]; + weakSelf.purchaseAmount = [[object objectForKey:@"iapUsd"]floatValue]; [[NSUserDefaults standardUserDefaults]setObject:[NSNumber numberWithFloat:weakSelf.purchaseAmount] forKey:@"iap_usd"]; [[NSUserDefaults standardUserDefaults]synchronize]; } diff --git a/OpenMediation/OpenMediaitonSegments/OMLoad.h b/OpenMediation/OpenMediaitonSegments/OMLoad.h index 47a9297..9c6df42 100644 --- a/OpenMediation/OpenMediaitonSegments/OMLoad.h +++ b/OpenMediation/OpenMediaitonSegments/OMLoad.h @@ -46,6 +46,7 @@ typedef NS_ENUM(NSInteger, OMInstanceLoadState) { @property (nonatomic, assign) OpenMediationAdFormat adFormat; @property (nonatomic, assign) OMLoadAction loadAction; +@property (nonatomic, assign) NSInteger configCacheCount; @property (nonatomic, assign) NSInteger cacheCount; @property (nonatomic, assign) NSInteger timeoutSecond; @property (nonatomic, strong) NSArray *priorityList; diff --git a/OpenMediation/OpenMediaitonSegments/OMMediations.m b/OpenMediation/OpenMediaitonSegments/OMMediations.m index b79714d..d8634d5 100644 --- a/OpenMediation/OpenMediaitonSegments/OMMediations.m +++ b/OpenMediation/OpenMediaitonSegments/OMMediations.m @@ -26,7 +26,7 @@ + (NSString *)getVersion; @end @interface ALSdk : NSObject -@property (class, nonatomic, assign, readonly) NSUInteger versionCode; +@property (class, nonatomic, copy, readonly) NSString *version; @end @interface Chartboost : NSObject @@ -177,7 +177,7 @@ - (NSString*)adnSDKVersion:(OMAdNetwork)adnID { { if (sdkClass && [sdkClass respondsToSelector:@selector(sharedInstance)]) { GADMobileAds *admob = [sdkClass sharedInstance]; - if(admob && [admob respondsToSelector:@selector(sdkVersion)]){ + if(admob && [admob respondsToSelector:@selector(sdkVersion)]) { sdkVersion = [admob sdkVersion]; } } @@ -217,8 +217,8 @@ - (NSString*)adnSDKVersion:(OMAdNetwork)adnID { break; case OMAdNetworkAppLovin: { - if (sdkClass && [sdkClass respondsToSelector:@selector(versionCode)]) { - sdkVersion = [NSString stringWithFormat:@"%zd",[sdkClass versionCode]]; + if(sdkClass && [sdkClass respondsToSelector:@selector(version)]) { + sdkVersion = [sdkClass performSelector:@selector(version)]; } } break; @@ -260,7 +260,7 @@ - (NSString*)adnSDKVersion:(OMAdNetwork)adnID { break; case OMAdNetworkTencentAd: { - if(sdkClass && [sdkClass respondsToSelector:@selector(sdkVersion)]){ + if(sdkClass && [sdkClass respondsToSelector:@selector(sdkVersion)]) { sdkVersion = [sdkClass sdkVersion]; } @@ -268,7 +268,7 @@ - (NSString*)adnSDKVersion:(OMAdNetwork)adnID { break; case OMAdNetworkIronSource: { - if(sdkClass && [sdkClass respondsToSelector:@selector(sdkVersion)]){ + if(sdkClass && [sdkClass respondsToSelector:@selector(sdkVersion)]) { sdkVersion = [sdkClass sdkVersion]; } } @@ -364,8 +364,12 @@ - (void)initAdNetworkSDKWithId:(OMAdNetwork)adnID completionHandler:(OMMediation } - (BOOL)adnSDKInitialized:(OMAdNetwork)adnID { - OMAdnSDKInitState initState = [[self.adnSDKInitState objectForKey:[NSString stringWithFormat:@"%zd",adnID]]integerValue]; - return (initState == OMAdnSDKInitStateInitialized); + if(adnID == OMAdNetworkCrossPromotion) { + return YES; + }else{ + OMAdnSDKInitState initState = [[self.adnSDKInitState objectForKey:[NSString stringWithFormat:@"%zd",adnID]]integerValue]; + return (initState == OMAdnSDKInitStateInitialized); + } } - (BOOL)adnSDKInitializing:(OMAdNetwork)adnID { diff --git a/OpenMediation/OpenMediaitonSegments/OMSmartLoad.m b/OpenMediation/OpenMediaitonSegments/OMSmartLoad.m index 1ef44c8..f909a2c 100644 --- a/OpenMediation/OpenMediaitonSegments/OMSmartLoad.m +++ b/OpenMediation/OpenMediaitonSegments/OMSmartLoad.m @@ -20,11 +20,12 @@ - (instancetype)initWithPid:(NSString*)pid adFormat:(OpenMediationAdFormat)forma } if (!unit || unit.cacheCount <= 0) { - self.cacheCount = 2; + self.configCacheCount = 2; OMLogD(@"%@ cache use default %zd",self.pid,self.cacheCount); } else { - self.cacheCount = unit.cacheCount; + self.configCacheCount = unit.cacheCount; } + self.cacheCount = self.configCacheCount; [self addCheckCacheTimer]; } return self; @@ -69,6 +70,7 @@ - (void)checkCache { - (void)loadWithAction:(OMLoadAction)action { [super loadWithAction:action]; + [self checkOptimalInstance]; if (self.adShow) { OMLogD(@"%@ smart load block: adshow",self.pid); [self addEvent:LOAD_BLOCKED extraData:@{@"msg":@"ad show"}]; @@ -118,20 +120,16 @@ - (void)loadWithPriority:(NSArray *)insPriority { OMLogD(@"%@ priority empty",self.pid); [self notifyNoFill]; [self notifyLoadEnd]; - return; - } - - NSString *instancePriorityStr = [self.priorityList componentsJoinedByString:@","]; - OMLogD(@"%@ load with priority %@",self.pid,instancePriorityStr); - - if (self.priorityList.count < self.cacheCount) { - self.cacheCount = self.priorityList.count; + } else { + NSString *instancePriorityStr = [self.priorityList componentsJoinedByString:@","]; + OMLogD(@"%@ load with priority %@",self.pid,instancePriorityStr); + self.cacheCount = MIN(self.priorityList.count, self.configCacheCount); OMLogD(@"%@ priority count less than cache count use min %zd ",self.pid,self.cacheCount); + [self checkOptimalInstance]; + [self groupByBatchSize:1]; + [self addLoadingInstance]; } - [self groupByBatchSize:1]; - [self addLoadingInstance]; - } - (void)saveInstanceLoadState:(NSString*)instanceID state:(OMInstanceLoadState)loadState { @@ -154,7 +152,7 @@ - (void)checkOptimalInstance { OMInstanceLoadState loadState = [self.instanceLoadState[instanceID]integerValue]; if (loadState == OMInstanceLoadStateLoading) { _loadingCount++; - } else if (loadState == OMInstanceLoadStateSuccess) { + } else if (loadState == OMInstanceLoadStateSuccess && [self.delegate omCheckInstanceReady:instanceID]) { if (![self.optimalFillInstance length]) { self.optimalFillInstance = instanceID; } diff --git a/OpenMediation/OpenMediation.h b/OpenMediation/OpenMediation.h index b236299..6708d98 100644 --- a/OpenMediation/OpenMediation.h +++ b/OpenMediation/OpenMediation.h @@ -28,10 +28,10 @@ extern NSString *kOpenMediatonInitSuccessNotification; @interface OpenMediation : NSObject /// Initializes OpenMediation's SDK with all the ad types that are defined in the platform. -+ (void)initWithAppKey:(NSString*)appKey; ++ (void)initWithAppKey:(NSString*)appKey baseHost:(NSString*)host; /// Initializes OpenMediation's SDK with the requested ad types. -+ (void)initWithAppKey:(NSString *)appKey adFormat:(OpenMediationAdFormat)initAdFormats; ++ (void)initWithAppKey:(NSString *)appKey baseHost:(NSString*)host adFormat:(OpenMediationAdFormat)initAdFormats ; /// Check that `OpenMediation` has been initialized + (BOOL)isInitialized; @@ -45,6 +45,12 @@ extern NSString *kOpenMediatonInitSuccessNotification; /// Set the gender of the current user + (void)setUserGender:(OMGender)userGender; +///Send conversion attribution data to server ++ (void)sendAFConversionData:(NSDictionary*)conversionInfo; + +///Send deep link attribution data to server ++ (void)sendAFDeepLinkData:(NSDictionary*)attributionData; + /// setUserConsent "NO" is Refuse,"YES" is Accepted. //GDPR /// According to the GDPR, set method of this property must be called before "initWithAppKey:", or by default will collect user's information. + (void)setGDPRConsent:(BOOL)consent; diff --git a/OpenMediation/OpenMediation.m b/OpenMediation/OpenMediation.m index e3536ca..24c05a0 100644 --- a/OpenMediation/OpenMediation.m +++ b/OpenMediation/OpenMediation.m @@ -10,6 +10,7 @@ #import "OMEventManager.h" #import "OMInterstitial.h" #import "OMRewardedVideo.h" +#import "OMCrossPromotion.h" @interface OMRewardedVideo() - (void)preload; @@ -19,6 +20,9 @@ @interface OMInterstitial() - (void)preload; @end +@interface OMCrossPromotion() +- (void)preload; +@end static OpenMediationAdFormat initAdFormats = 0; @@ -30,17 +34,17 @@ - (void)preload; @implementation OpenMediation /// Initializes OpenMediation's SDK with all the ad types that are defined in the platform. -+ (void)initWithAppKey:(NSString*)appKey { ++ (void)initWithAppKey:(NSString*)appKey baseHost:(nonnull NSString *)host { if (!initAdFormats) { - [self initWithAppKey:appKey adFormat:(OpenMediationAdFormatRewardedVideo|OpenMediationAdFormatInterstitial)]; + [self initWithAppKey:appKey baseHost:host adFormat:(OpenMediationAdFormatRewardedVideo|OpenMediationAdFormatInterstitial|OpenMediationAdFormatCrossPromotion)]; } else { - [self initWithAppKey:appKey adFormat:initAdFormats]; + [self initWithAppKey:appKey baseHost:host adFormat:initAdFormats]; } } /// Initializes OpenMediation's SDK with the requested ad types. -+ (void)initWithAppKey:(NSString *)appKey adFormat:(OpenMediationAdFormat)initAdTypes { - [self initWithAppKey:appKey completionHandler:^(NSError * _Nullable error) { ++ (void)initWithAppKey:(NSString *)appKey baseHost:(NSString*)host adFormat:(OpenMediationAdFormat)initAdTypes { + [self initWithAppKey:appKey baseHost:host completionHandler:^(NSError * _Nullable error) { if (!error) { if (initAdTypes & OpenMediationAdFormatInterstitial) { [[OMInterstitial sharedInstance]preload]; @@ -48,6 +52,9 @@ + (void)initWithAppKey:(NSString *)appKey adFormat:(OpenMediationAdFormat)initAd if (initAdTypes & OpenMediationAdFormatRewardedVideo) { [[OMRewardedVideo sharedInstance]preload]; } + if (initAdTypes & OpenMediationAdFormatCrossPromotion) { + [[OMCrossPromotion sharedInstance]preload]; + } } }]; @@ -62,11 +69,11 @@ + (void)initWithAppKey:(NSString *)appKey adFormat:(OpenMediationAdFormat)initAd + (void)checkSDKInit { if ([[OMConfig sharedInstance].appKey length]>0 && ![OpenMediation isInitialized] && [OMNetMonitor sharedInstance].netStatus) { - [self initWithAppKey:[OMConfig sharedInstance].appKey]; + [self initWithAppKey:[OMConfig sharedInstance].appKey baseHost:[OMConfig sharedInstance].baseHost]; } } -+ (void)initWithAppKey:(NSString*)appKey completionHandler:(initCompletionHandler)completionHandler { ++ (void)initWithAppKey:(NSString*)appKey baseHost:(NSString*)host completionHandler:(initCompletionHandler)completionHandler { OMConfig *config = [OMConfig sharedInstance]; if (config.initState == OMInitStateInitializing || config.initState == OMInitStateInitialized) { if (config.initState == OMInitStateInitialized) { @@ -76,7 +83,7 @@ + (void)initWithAppKey:(NSString*)appKey completionHandler:(initCompletionHandle } OMLogI(@"OpenMediation SDK init Version %@",OPENMEDIATION_SDK_VERSION); [[OMNetMonitor sharedInstance] startMonitor]; - [OMInitRequest configureWithAppKey:appKey completionHandler:^(NSError *error) { + [OMInitRequest configureWithAppKey:appKey baseHost:host completionHandler:^(NSError *error) { if (!error) { [self settingWithConfig]; OMLogI(@"OpenMediation SDK init success"); @@ -144,6 +151,24 @@ + (void)setUserGender:(OMGender)userGender { } } +#pragma mark - ROAS +/// calculate each Media Source, Campaign level ROAS, and LTV data ++ (void)sendAFConversionData:(NSDictionary*)conversionInfo { + [OMCDRequest postWithType:0 data:conversionInfo completionHandler:^(NSDictionary * _Nullable object, NSError * _Nullable error) { + if (!error) { + OMLogD(@"send af conversion data success"); + } + }]; +} + ++ (void)sendAFDeepLinkData:(NSDictionary*)attributionData { + [OMCDRequest postWithType:1 data:attributionData completionHandler:^(NSDictionary * _Nullable object, NSError * _Nullable error) { + if (!error) { + OMLogD(@"send af deep link data success"); + } + }]; +} + #pragma mark - GDPR/CCPA + (void)setGDPRConsent:(BOOL)consent { [[OMConfig sharedInstance] setConsent:consent]; @@ -154,7 +179,7 @@ + (void)setGDPRConsent:(BOOL)consent { + (OMConsentStatus)currentConsentStatus { if (OM_IS_NULL([[NSUserDefaults standardUserDefaults] stringForKey:@"OMConsentStatus"])) { return OMConsentStatusUnknown; - }else if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OMConsentStatus"] == YES){ + }else if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OMConsentStatus"] == YES) { return OMConsentStatusConsented; }else{ return OMConsentStatusDenied; diff --git a/OpenMediation/OpenMediationAdFormats.h b/OpenMediation/OpenMediationAdFormats.h index 29525b9..87cf0de 100644 --- a/OpenMediation/OpenMediationAdFormats.h +++ b/OpenMediation/OpenMediationAdFormats.h @@ -10,6 +10,7 @@ typedef NS_ENUM(NSInteger, OpenMediationAdFormat) { OpenMediationAdFormatRewardedVideo = (1 << 2), OpenMediationAdFormatInterstitial = (1 << 3), OpenMediationAdFormatSplash = (1 << 4), + OpenMediationAdFormatCrossPromotion = (1 << 5), }; #endif /* OpenMediationAdFormats_h */ diff --git a/OpenMediation/OpenMediationBid/OMBid.m b/OpenMediation/OpenMediationBid/OMBid.m index adcb021..29f03f1 100644 --- a/OpenMediation/OpenMediationBid/OMBid.m +++ b/OpenMediation/OpenMediationBid/OMBid.m @@ -6,6 +6,7 @@ #import "OMBidResponse.h" #import "OMEventManager.h" #import "OMToolUmbrella.h" +#import "OMMediations.h" @implementation OMBid @@ -23,6 +24,14 @@ - (void)bidWithNetworkItems:(NSArray*)networkItems adFormat:(NSString*)format co for (OMBidNetworkItem *networkItem in networkItems) { if (!OM_STR_EMPTY(networkItem.adnName)) { + OMAdNetwork adnID = [networkItem.extraData[@"adnID"] integerValue]; + + if ((adnID == OMAdNetworkVungle || adnID == OMAdNetworkChartboostBid) && ![[OMMediations sharedInstance]adnSDKInitialized:adnID]) { + [[OMMediations sharedInstance]initAdNetworkSDKWithId:adnID + completionHandler:^(NSError * _Nullable error) { + }]; + } + NSString *className = [NSString stringWithFormat:@"OM%@Bid",networkItem.adnName]; Class bidClass = NSClassFromString(className); if (bidClass && [bidClass respondsToSelector:@selector(bidderToken)]) { diff --git a/OpenMediation/OpenMediationBid/OMBidResponse.h b/OpenMediation/OpenMediationBid/OMBidResponse.h index b3ec1c7..8171b76 100644 --- a/OpenMediation/OpenMediationBid/OMBidResponse.h +++ b/OpenMediation/OpenMediationBid/OMBidResponse.h @@ -23,6 +23,7 @@ typedef NS_ENUM (NSInteger, OMBidLossedReasonCode) { @property (nonatomic, assign) float price; @property (nonatomic, copy) NSString *currency; @property (nonatomic, copy) NSObject *payLoad; +@property (nonatomic, assign) NSInteger expire; @property (nonatomic,copy, nullable) void(^notifyWin)(void); @property (nonatomic,copy, nullable) void(^notifyLoss)(void); diff --git a/OpenMediation/OpenMediationBid/OMBidResponse.m b/OpenMediation/OpenMediationBid/OMBidResponse.m index fc8c07c..7959fe9 100644 --- a/OpenMediation/OpenMediationBid/OMBidResponse.m +++ b/OpenMediation/OpenMediationBid/OMBidResponse.m @@ -50,6 +50,10 @@ + (OMBidResponse *)buildResponseWithData:(NSDictionary*)responseData { response.lurl = [responseData objectForKey:@"lurl"]; response.notifyWin = [responseData objectForKey:@"winBlock"]; response.notifyLoss = [responseData objectForKey:@"lossBlock"]; + if ([responseData objectForKey:@"expire"]) { + response.expire = (NSInteger)([NSDate date].timeIntervalSince1970 + [[responseData objectForKey:@"expire"]integerValue]*60)*1000; + } + return response; } diff --git a/OpenMediation/OpenMediationConstant.h b/OpenMediation/OpenMediationConstant.h index 4c65746..eacdcfc 100644 --- a/OpenMediation/OpenMediationConstant.h +++ b/OpenMediation/OpenMediationConstant.h @@ -4,7 +4,7 @@ #ifndef OpenMediationConstant_h #define OpenMediationConstant_h -#define OPENMEDIATION_SDK_VERSION @"1.3.3" +#define OPENMEDIATION_SDK_VERSION @"2.0.0" typedef NS_ENUM(NSInteger, OMAdNetwork) { OMAdNetworkAdTiming = 1, @@ -22,6 +22,7 @@ typedef NS_ENUM(NSInteger, OMAdNetwork) { OMAdNetworkMintegral = 14, OMAdNetworkIronSource = 15, OMAdNetworkChartboostBid = 17, + OMAdNetworkCrossPromotion = 19, OMAdNetworkFyber = 30, }; diff --git a/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.h b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.h new file mode 100644 index 0000000..6093f6d --- /dev/null +++ b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.h @@ -0,0 +1,47 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import + +#import "OMAdSingletonInterface.h" +#import "OMCrossPromotionDelegate.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotion : OMAdSingletonInterface +/// Returns the singleton instance. ++ (instancetype)sharedInstance; + +/// Add delegate +- (void)addDelegate:(id)delegate; + +/// Remove delegate +- (void)removeDelegate:(id)delegate; + +/// Indicates whether the promotion ad is ready to show ad. +- (BOOL)isReady; + +/// Indicates whether the scene has reached the display frequency. +- (BOOL)isCappedForScene:(NSString *)sceneName; + +/// Show promotion ad on top view +/// Parameter scaleXY: the value is a CGPonit, x is width percentage, y is height percentage. eg screen center CGPointMake(0.5,0.5) +/// Parameter scene: the value is an NSString, ad scene name in OpenMediation dashboard setting. +- (void)showAdWithScreenPoint:(CGPoint)scaleXY scene:(NSString *)sceneName; + + +/// Show promotion ad on top view. +/// @param adSize ad size +/// @param scaleXY The value is a CGPonit, x is width percentage, y is height percentage. eg screen center CGPointMake(0.5,0.5) +/// @param xAngle Rotated angle in clockwise. +/// @param zAngle Rotated angle in clockwise. +/// @param sceneName The value is an NSString, ad scene name in OpenMediation dashboard setting. +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString *)sceneName; + +/// Hide promotion ad. +- (void)hideAd; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.m b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.m new file mode 100644 index 0000000..48b75a7 --- /dev/null +++ b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotion.m @@ -0,0 +1,192 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotion.h" +#import "OMCrossPromotionAd.h" +#import "OpenMediationAdFormats.h" +#import "OMToolUmbrella.h" +#import "OMModelUmbrella.h" +#import "OMAdBasePrivate.h" +#import "OMAdSingletonInterfacePrivate.h" +#import "OMEventManager.h" + +#define DEFAULT_AD_SIZE CGSizeMake(132, 153) + + +@protocol OMCrossPromotionPrivateDelegate + +@optional + +- (void)omCrossPromotionChangedAvailability:(NSString*)placementID newValue:(BOOL)available; + +@end + +static OMCrossPromotion * _instance = nil; + +@implementation OMCrossPromotion + ++ (instancetype)sharedInstance{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] initWithAdClassName:@"OMCrossPromotionAd" adFormat:OpenMediationAdFormatCrossPromotion]; + }); + return _instance; + +} + +- (void)addDelegate:(id)delegate{ + [super addDelegate:delegate]; +} + +- (void)removeDelegate:(id)delegate{ + [super removeDelegate:delegate]; +} + +- (BOOL)isReady { + return [super isReady]; +} + + +- (BOOL)isCappedForScene:(NSString *)sceneName { + return [super isCappedForScene:sceneName]; +} + +- (void)showAdWithScreenPoint:(CGPoint)scaleXY scene:(NSString *)sceneName { + [self showAdWithSize:DEFAULT_AD_SIZE screenPoint:scaleXY xAngle:0 zAngle:0 scene:sceneName]; +} + + +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString *)sceneName { + NSString *unitID = [[OMConfig sharedInstance]defaultUnitIDForAdFormat:OpenMediationAdFormatCrossPromotion]; + OMScene *scene = [[OMConfig sharedInstance]getSceneWithSceneName:sceneName inAdUnit:unitID]; + [self addAdEvent:CALLED_SHOW placementID:unitID scene:scene extraMsg:OM_SAFE_STRING(sceneName)]; + [self showAdWithSize:adSize screenPoint:scaleXY xAngle:xAngle zAngle:zAngle placementID:unitID scene:sceneName]; +} + +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle placementID:(NSString *)placementID { + [self addAdEvent:CALLED_SHOW placementID:placementID scene:nil extraMsg:nil]; + [self showAdWithSize:adSize screenPoint:scaleXY xAngle:xAngle zAngle:zAngle placementID:placementID scene:@""]; +} + +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle placementID:(NSString *)placementID scene:(NSString*)sceneName { + if(![OMConfig sharedInstance].initSuccess) { + NSError *adtError = [OMError omErrorWithCode:OMErrorShowNotInitialized]; + [OMSDKError throwDeveloperError:[OMSDKError errorWithAdtError:adtError]]; + return; + } + + if(OM_STR_EMPTY(placementID)) { + NSError *adtError = [OMError omErrorWithCode:OMErrorShowPlacementEmpty]; + [OMSDKError throwDeveloperError:[OMSDKError errorWithAdtError:adtError]]; + return; + } + + if(![[OMConfig sharedInstance]configContainAdUnit:placementID]) { + NSError *adtError = [OMError omErrorWithCode:OMErrorLoadPlacementNotFound]; + [OMSDKError throwDeveloperError:[OMSDKError errorWithAdtError:adtError]]; + return; + } + + if(![[OMConfig sharedInstance] isValidAdUnitId:placementID forAdFormat:OpenMediationAdFormatCrossPromotion]) { + NSError *adtError = [OMError omErrorWithCode:OMErrorLoadPlacementAdTypeIncorrect]; + [OMSDKError throwDeveloperError:[OMSDKError errorWithAdtError:adtError]]; + return; + } + + if(![self placementIsReady:placementID]) { + NSError *adtError = [OMError omErrorWithCode:OMErrorShowFailNotReady]; + NSError *noReadyError = [OMSDKError errorWithAdtError:adtError]; + [OMSDKError throwDeveloperError:noReadyError]; + [self promotionDidFailToShow:placementID scene:sceneName withError:noReadyError]; + return; + } + if([[OMLoadFrequencryControl sharedInstance]overCapOnPlacement:placementID scene:sceneName]) { + NSError *adtError = [OMError omErrorWithCode:OMErrorShowFailSceneCapped]; + NSError *cappedError = [OMSDKError errorWithAdtError:adtError]; + [OMSDKError throwDeveloperError:cappedError]; + [self promotionDidFailToShow:placementID scene:sceneName withError:cappedError]; + return; + } + OMCrossPromotionAd *promotionAd = [self.loadAdInstanceDic objectForKey:placementID]; + if(promotionAd) { + [promotionAd showAdWithSize:adSize screenPoint:scaleXY xAngle:xAngle zAngle:zAngle scene:sceneName]; + } +} + +- (void)hideAd { + NSString *unitID = [[OMConfig sharedInstance]defaultUnitIDForAdFormat:OpenMediationAdFormatCrossPromotion]; + [self hideAd:unitID]; +} + +- (void)hideAd:(NSString*)placementID { + OMCrossPromotionAd *promotionAd = [self.loadAdInstanceDic objectForKey:placementID]; + if(promotionAd) { + [promotionAd hideAd]; + } +} + +#pragma mark - OMCrossPromotionAdDelegate + + +- (void)promotionChangedAvailability:(OMCrossPromotionAd *)promotion newValue:(BOOL)available { + for (id delegate in self.delegates) { + if(delegate && [delegate respondsToSelector:@selector(omCrossPromotionChangedAvailability:)]) { + if (available) { + [self addAdEvent:CALLBACK_LOAD_SUCCESS placementID:promotion.placementID scene:nil extraMsg:nil]; + } + [delegate omCrossPromotionChangedAvailability:available]; + } + } +} + +- (void)promotionWillAppear:(OMCrossPromotionAd *)promotion { + OMScene *showScene = [[OMConfig sharedInstance]getSceneWithSceneID:((OMAdBase*)promotion).showSceneID inAdUnit:promotion.placementID]; + if(showScene) { + for (id delegate in self.delegates) { + if (delegate && [delegate conformsToProtocol:@protocol(OMCrossPromotionDelegate)] && [delegate respondsToSelector:@selector(omCrossPromotionWillAppear:)]) { + [self addAdEvent:CALLBACK_PRESENT_SCREEN placementID:promotion.placementID scene:showScene extraMsg:nil]; + [delegate omCrossPromotionWillAppear:showScene]; + } + } + } +} + + +- (void)promotionDidClick:(OMCrossPromotionAd *)promotion { + OMScene *showScene = [[OMConfig sharedInstance]getSceneWithSceneID:((OMAdBase*)promotion).showSceneID inAdUnit:promotion.placementID]; + if(showScene) { + for (id delegate in self.delegates) { + if (delegate && [delegate conformsToProtocol:@protocol(OMCrossPromotionDelegate)] && [delegate respondsToSelector:@selector(omCrossPromotionDidClick:)]) { + [self addAdEvent:CALLBACK_CLICK placementID:promotion.placementID scene:showScene extraMsg:nil]; + [delegate omCrossPromotionDidClick:showScene]; + } + } + } +} + +- (void)promotionDidDisappear:(OMCrossPromotionAd *)promotion { + OMScene *showScene = [[OMConfig sharedInstance]getSceneWithSceneID:((OMAdBase*)promotion).showSceneID inAdUnit:promotion.placementID]; + if(showScene) { + for (id delegate in self.delegates) { + if (delegate && [delegate conformsToProtocol:@protocol(OMCrossPromotionDelegate)] && [delegate respondsToSelector:@selector(omCrossPromotionDidDisappear:)]) { + [self addAdEvent:CALLBACK_DISMISS_SCREEN placementID:promotion.placementID scene:showScene extraMsg:nil]; + [delegate omCrossPromotionDidDisappear:showScene]; + } + } + } +} + + + +- (void)promotionDidFailToShow:(NSString*)placementID scene:(NSString*)sceneName withError:(NSError*)error { + OMScene *showScene = [[OMConfig sharedInstance]getSceneWithSceneName:sceneName inAdUnit:placementID]; + if(showScene) { + for (id delegate in self.delegates) { + if (delegate && [delegate conformsToProtocol:@protocol(OMCrossPromotionDelegate)] && [delegate respondsToSelector:@selector(omCrossPromotionDidFailToShow:withError:)]) { + [self addAdEvent:CALLBACK_SHOW_FAILED placementID:placementID scene:showScene extraMsg:OM_SAFE_STRING([error description])]; + [delegate omCrossPromotionDidFailToShow:showScene withError:error]; + } + } + } +} +@end diff --git a/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.h b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.h new file mode 100644 index 0000000..3479eef --- /dev/null +++ b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.h @@ -0,0 +1,30 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMCrossPromotionAdDelegate.h" +#import "OMAdBase.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionAd : OMAdBase + +@property (nonatomic, weak)id delegate; + +- (NSString*)placementID; + +- (instancetype)initWithPlacementID:(NSString *)placementID; + +- (BOOL)isReady; + +- (void)loadAd; + +- (void)preload; + +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString*)sceneName; + +- (void)hideAd; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.m b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.m new file mode 100644 index 0000000..6b327b9 --- /dev/null +++ b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAd.m @@ -0,0 +1,122 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionAd.h" +#import "OpenMediationAdFormats.h" +#import "OMModelUmbrella.h" +#import "OMNetworkUmbrella.h" +#import "OMCrossPromotionCustomEvent.h" +#import "OMInstanceContainer.h" +#import "OMAdBasePrivate.h" + + +@interface OMCrossPromotionAd () + +@end + +@implementation OMCrossPromotionAd + +- (instancetype)initWithPlacementID:(NSString *)placementID { + if (self = [super initWithPlacementID:placementID size:[UIScreen mainScreen].bounds.size]) { + } + return self; +} + +- (void)loadInstance:(NSString*)instanceID { + OMInstance *instance = [[OMConfig sharedInstance]getInstanceByinstanceID:instanceID]; + if(instance) { + NSString *mediationPid = instance.adnPlacementID; + OMAdNetwork adnID = instance.adnID; + NSString *instanceID = instance.instanceID; + NSString *mediationName = [[OMConfig sharedInstance]adnName:adnID]; + if ([mediationName length]>0) { + NSString *className = [NSString stringWithFormat:@"OM%@CP",mediationName]; + Class adapterClass = NSClassFromString(className); + if (adapterClass && [adapterClass conformsToProtocol:@protocol(OMCrossPromotionCustomEvent)] && [adapterClass instancesRespondToSelector:@selector(initWithParameter:)]) { + id promotionAdapter = [[OMInstanceContainer sharedInstance]getInstance:instanceID block:^id { + id adapter = [[adapterClass alloc] initWithParameter:@{@"pid":mediationPid,@"appKey":[[OMConfig sharedInstance]adnAppKey:adnID] }]; + return adapter; + }] ; + promotionAdapter.delegate = self; + [self.instanceAdapters setObject:promotionAdapter forKey:instanceID]; + } + } + } + [super loadInstance:instanceID]; +} + +- (void)loadAd { + [super loadAd:OpenMediationAdFormatCrossPromotion actionType:OMLoadActionManualLoad]; +} + +- (void)preload{ + [self loadAd:OpenMediationAdFormatCrossPromotion actionType:OMLoadActionInit]; +} + +- (BOOL)isReady{ + return [super isReady]; +} + +- (NSString*)placementID{ + return self.pid; +} + +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString*)sceneName { + + self.showSceneID = [[OMConfig sharedInstance] getSceneIDWithSceneName:sceneName inAdUnit:self.placementID]; + OMLogD(@"promotion show pid = %@ scene name %@ scene id %@",self.placementID,(OM_STR_EMPTY(sceneName)?@"empty":sceneName),self.showSceneID); + + if(self.adLoader && !OM_STR_EMPTY(self.adLoader.optimalFillInstance)) { + id promotionAdapter = [self.instanceAdapters objectForKey:self.adLoader.optimalFillInstance]; + if(promotionAdapter && [promotionAdapter respondsToSelector:@selector(setShowSceneID:)]) { + [(OMAdBase*)promotionAdapter setShowSceneID:self.showSceneID]; + } + + if(promotionAdapter && [promotionAdapter respondsToSelector:@selector(showAdWithSize:screenPoint:xAngle:zAngle:scene:)]) { + [promotionAdapter showAdWithSize:adSize screenPoint:scaleXY xAngle:xAngle zAngle:zAngle scene:sceneName]; + } + [self showInstance:self.adLoader.optimalFillInstance]; + + } +} + +- (void)hideAd { + NSArray *cpAdapters = self.instanceAdapters.allValues; + for (id promotionAdapter in cpAdapters) { + if(promotionAdapter && [promotionAdapter respondsToSelector:@selector(hideAd)]) { + [promotionAdapter hideAd]; + } + } +} + +- (void)omDidChangedAvailable:(BOOL)available{ + [super omDidChangedAvailable:available]; + if (self.delegate && [self.delegate respondsToSelector:@selector(promotionChangedAvailability:newValue:)]) { + [self.delegate promotionChangedAvailability:self newValue:available]; + } +} + +#pragma mark -- crossPromotionCustomEventDelegate + +- (void)promotionCustomEventWillAppear:(id)adapter { + [self adshow:adapter]; + if (self.delegate && [self.delegate respondsToSelector:@selector(promotionWillAppear:)]) { + [self.delegate promotionWillAppear:self]; + } +} + +- (void)promotionCustomEventDidClick:(id)adapter { + [self adClick:adapter]; + if (self.delegate && [self.delegate respondsToSelector:@selector(promotionDidClick:)]) { + [self.delegate promotionDidClick:self]; + } +} + +- (void)promotionCustomEventDidDisAppear:(id)adapter { + [self adClose:adapter]; + if (self.delegate && [self.delegate respondsToSelector:@selector(promotionDidDisappear:)]) { + [self.delegate promotionDidDisappear:self]; + } +} + +@end diff --git a/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAdDelegate.h b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAdDelegate.h new file mode 100644 index 0000000..35327ad --- /dev/null +++ b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionAdDelegate.h @@ -0,0 +1,30 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +@class OMCrossPromotionAd; + +NS_ASSUME_NONNULL_BEGIN + +@protocol OMCrossPromotionAdDelegate + +@optional + + +- (void)promotionChangedAvailability:(OMCrossPromotionAd *)Promotion newValue:(BOOL)available; + +- (void)promotionDidLoad:(OMCrossPromotionAd*)Promotion; + +- (void)promotionDidFailToLoad:(OMCrossPromotionAd*)Promotion withError:(NSError*)error; + +- (void)promotionWillAppear:(OMCrossPromotionAd *)Promotion; + +- (void)promotionDidClick:(OMCrossPromotionAd *)Promotion; + +- (void)promotionDidDisappear:(OMCrossPromotionAd *)Promotion; + +@end + +NS_ASSUME_NONNULL_END + diff --git a/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionDelegate.h b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionDelegate.h new file mode 100644 index 0000000..34944c5 --- /dev/null +++ b/OpenMediation/OpenMediationCrossPromotion/OMCrossPromotionDelegate.h @@ -0,0 +1,30 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMScene.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol OMCrossPromotionDelegate + +@optional + +/// Invoked when promotion ad is available. +- (void)omCrossPromotionChangedAvailability:(BOOL)available; + +/// Sent immediately when promotion ad will appear. +- (void)omCrossPromotionWillAppear:(OMScene*)scene; + +/// Sent after a promotion ad has been clicked. +- (void)omCrossPromotionDidClick:(OMScene*)scene; + +/// Sent after a promotion ad did disappear. +- (void)omCrossPromotionDidDisappear:(OMScene*)scene; + +/// Sent after a promotion ad has failed to play. +- (void)omCrossPromotionDidFailToShow:(OMScene*)scene withError:(NSError *)error; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationCustomEvent/OMBannerCustomEvent.h b/OpenMediation/OpenMediationCustomEvent/OMBannerCustomEvent.h index 30220d7..7648f02 100644 --- a/OpenMediation/OpenMediationCustomEvent/OMBannerCustomEvent.h +++ b/OpenMediation/OpenMediationCustomEvent/OMBannerCustomEvent.h @@ -18,7 +18,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol OMBannerCustomEvent @property(nonatomic, weak, nullable) id delegate; - (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParameter rootViewController:(UIViewController *)rootViewController; +@optional - (void)loadAd; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; @end NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationCustomEvent/OMCrossPromotionCustomEvent.h b/OpenMediation/OpenMediationCustomEvent/OMCrossPromotionCustomEvent.h new file mode 100644 index 0000000..c99c57f --- /dev/null +++ b/OpenMediation/OpenMediationCustomEvent/OMCrossPromotionCustomEvent.h @@ -0,0 +1,30 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import "OMCustomEventDelegate.h" + +NS_ASSUME_NONNULL_BEGIN + + +@protocol OMCrossPromotionCustomEvent; + +@protocol crossPromotionCustomEventDelegate + +- (void)promotionCustomEventWillAppear:(id)adapter; +- (void)promotionCustomEventDidClick:(id)adapter; +- (void)promotionCustomEventDidDisAppear:(id)adapter; + +@end + +@protocol OMCrossPromotionCustomEvent +@property(nonatomic, weak, nullable) id delegate; +- (instancetype)initWithParameter:(NSDictionary*)adParameter; +- (void)loadAd; +- (BOOL)isReady; +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString*)sceneName; +- (void)hideAd; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationCustomEvent/OMInterstitialCustomEvent.h b/OpenMediation/OpenMediationCustomEvent/OMInterstitialCustomEvent.h index 05375ee..687084e 100644 --- a/OpenMediation/OpenMediationCustomEvent/OMInterstitialCustomEvent.h +++ b/OpenMediation/OpenMediationCustomEvent/OMInterstitialCustomEvent.h @@ -21,7 +21,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol OMInterstitialCustomEvent @property(nonatomic, weak, nullable) id delegate; - (instancetype)initWithParameter:(NSDictionary*)adParameter; +@optional - (void)loadAd; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; - (BOOL)isReady; - (void)show:(UIViewController*)rootViewController; @end diff --git a/OpenMediation/OpenMediationCustomEvent/OMNativeCustomEvent.h b/OpenMediation/OpenMediationCustomEvent/OMNativeCustomEvent.h index 6a66d5c..e0bc362 100644 --- a/OpenMediation/OpenMediationCustomEvent/OMNativeCustomEvent.h +++ b/OpenMediation/OpenMediationCustomEvent/OMNativeCustomEvent.h @@ -18,7 +18,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol OMNativeCustomEvent @property (nonatomic, weak) id delegate; - (instancetype)initWithParameter:(NSDictionary*)adParameter rootVC:(UIViewController*)rootViewController; +@optional - (void)loadAd; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; @end NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationCustomEvent/OMRewardedVideoCustomEvent.h b/OpenMediation/OpenMediationCustomEvent/OMRewardedVideoCustomEvent.h index de598c9..1668766 100644 --- a/OpenMediation/OpenMediationCustomEvent/OMRewardedVideoCustomEvent.h +++ b/OpenMediation/OpenMediationCustomEvent/OMRewardedVideoCustomEvent.h @@ -23,7 +23,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol OMRewardedVideoCustomEvent @property(nonatomic, weak, nullable) id delegate; - (instancetype)initWithParameter:(NSDictionary*)adParameter; +@optional - (void)loadAd; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; - (BOOL)isReady; - (void)show:(UIViewController*)vc; @end diff --git a/OpenMediation/OpenMediationCustomEvent/OMSplashCustomEvent.h b/OpenMediation/OpenMediationCustomEvent/OMSplashCustomEvent.h index 46afb17..42f9034 100644 --- a/OpenMediation/OpenMediationCustomEvent/OMSplashCustomEvent.h +++ b/OpenMediation/OpenMediationCustomEvent/OMSplashCustomEvent.h @@ -19,7 +19,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol OMSplashCustomEvent @property(nonatomic, weak, nullable) id delegate; - (instancetype)initWithParameter:(NSDictionary *)adParameter adSize:(CGSize)size; +@optional - (void)loadAd; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; - (BOOL)isReady; - (void)showWithWindow:(UIWindow *)window customView:(UIView *)customView; @end diff --git a/OpenMediation/OpenMediationModel/OMConfig.h b/OpenMediation/OpenMediationModel/OMConfig.h index ad80376..41f04e9 100644 --- a/OpenMediation/OpenMediationModel/OMConfig.h +++ b/OpenMediation/OpenMediationModel/OMConfig.h @@ -18,15 +18,19 @@ typedef NS_ENUM(NSInteger, OMInitState) { @property(nonatomic, assign) OMInitState initState; @property(nonatomic, assign) BOOL initSuccess; +@property(nonatomic, copy) NSString *baseHost; @property(nonatomic, copy) NSString *appKey; @property(nonatomic, assign) BOOL openDebug; -@property(nonatomic, copy) NSString *clUrl; +@property(nonatomic, copy) NSString *wfUrl; @property(nonatomic, copy) NSString *lrUrl; @property(nonatomic, copy) NSString *icUrl; @property(nonatomic, copy) NSString *iapUrl; @property(nonatomic, copy) NSString *erUrl; +@property(nonatomic, copy) NSString *cdUrl; @property(nonatomic, copy) NSString *hbUrl; +@property(nonatomic, copy) NSString *clUrl; +@property(nonatomic, copy) NSString *plUrl; @property(nonatomic, strong) NSMutableDictionary *adnNameMap; @property(nonatomic, strong) NSMutableDictionary *adnAppkeyMap; diff --git a/OpenMediation/OpenMediationModel/OMConfig.m b/OpenMediation/OpenMediationModel/OMConfig.m index e4a2d50..6c24083 100644 --- a/OpenMediation/OpenMediationModel/OMConfig.m +++ b/OpenMediation/OpenMediationModel/OMConfig.m @@ -29,13 +29,14 @@ - (instancetype)init { @(OpenMediationAdFormatNative):@"Native",\ @(OpenMediationAdFormatInterstitial):@"Interstitial",\ @(OpenMediationAdFormatRewardedVideo):@"RewardedVideo"}; + _baseHost = @""; _appKey = @""; _hbUrl = @""; - _clUrl = @""; _lrUrl = @""; _icUrl = @""; _iapUrl = @""; _erUrl = @""; + _cdUrl = @""; _openDebug = YES; _adnNameMap = [NSMutableDictionary dictionary]; _adnAppkeyMap = [NSMutableDictionary dictionary]; @@ -96,11 +97,14 @@ - (void)loadCongifData:(NSDictionary *)configData { - (void)loadApi:(NSDictionary*)apiData { _hbUrl = OM_SAFE_STRING([apiData objectForKey:@"hb"]); - _clUrl = OM_SAFE_STRING([apiData objectForKey:@"wf"]); + _wfUrl = OM_SAFE_STRING([apiData objectForKey:@"wf"]); _lrUrl = OM_SAFE_STRING([apiData objectForKey:@"lr"]); _icUrl = OM_SAFE_STRING([apiData objectForKey:@"ic"]); _iapUrl = OM_SAFE_STRING([apiData objectForKey:@"iap"]); _erUrl = OM_SAFE_STRING([apiData objectForKey:@"er"]); + _cdUrl = OM_SAFE_STRING([apiData objectForKey:@"cd"]); + _clUrl = OM_SAFE_STRING([apiData objectForKey:@"cpcl"]); + _plUrl = OM_SAFE_STRING([apiData objectForKey:@"cppl"]); } - (void)loadMediation:(NSArray *)mediationData { diff --git a/OpenMediation/OpenMediationModel/OMScene.m b/OpenMediation/OpenMediationModel/OMScene.m index a113d97..db8b899 100644 --- a/OpenMediation/OpenMediationModel/OMScene.m +++ b/OpenMediation/OpenMediationModel/OMScene.m @@ -9,7 +9,6 @@ @implementation OMScene - (instancetype)initWithUnitID:(NSString *)unitID sceneData:(NSDictionary *)sceneData { if (self = [super init]) { _unitID = unitID; - _sceneID = [NSString stringWithFormat:@"%@", sceneData[@"id"]]; _sceneID = [NSString stringWithFormat:@"%@",sceneData[@"id"]]; _sceneName = OM_SAFE_STRING(sceneData[@"n"]); _defaultScene = [sceneData[@"isd"]boolValue]; diff --git a/OpenMediation/OpenMediationNative/OMNative.m b/OpenMediation/OpenMediationNative/OMNative.m index fab8e47..1633b43 100644 --- a/OpenMediation/OpenMediationNative/OMNative.m +++ b/OpenMediation/OpenMediationNative/OMNative.m @@ -64,6 +64,7 @@ - (NSString*)placementID{ } - (void)nativeCustomEventWillShow:(id)adapter { + [self showInstance:self.adLoader.optimalFillInstance]; [self adshow:adapter]; [self omWillExposure]; } diff --git a/OpenMediation/OpenMediationNetwork/OMBaseRequest.m b/OpenMediation/OpenMediationNetwork/OMBaseRequest.m index c64db58..a921970 100644 --- a/OpenMediation/OpenMediationNetwork/OMBaseRequest.m +++ b/OpenMediation/OpenMediationNetwork/OMBaseRequest.m @@ -37,12 +37,8 @@ + (void)requestWithUrl:(NSURL *)url [request setHTTPMethod:httpMethod]; [request setHTTPBody:body]; - if (requestType == OMRequestTypeNormal) { - [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; - } else { - [request setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"]; - } - //[request setValue:@"1" forHTTPHeaderField:@"debug"]; + [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + [request setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"]; dispatch_queue_t requestQueue = dispatch_queue_create("com.om.request", DISPATCH_QUEUE_SERIAL); dispatch_async(requestQueue, ^{ diff --git a/OpenMediation/OpenMediationNetwork/OMCDRequest.h b/OpenMediation/OpenMediationNetwork/OMCDRequest.h new file mode 100644 index 0000000..2e998a1 --- /dev/null +++ b/OpenMediation/OpenMediationNetwork/OMCDRequest.h @@ -0,0 +1,16 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +NS_ASSUME_NONNULL_BEGIN + +typedef void(^cdCompletionHandler)(NSDictionary *_Nullable object, NSError *_Nullable error); + +@interface OMCDRequest : NSObject + ++ (void)postWithType:(NSInteger)type data:(NSDictionary*)data completionHandler:(cdCompletionHandler)completionHandler; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationNetwork/OMCDRequest.m b/OpenMediation/OpenMediationNetwork/OMCDRequest.m new file mode 100644 index 0000000..84b137b --- /dev/null +++ b/OpenMediation/OpenMediationNetwork/OMCDRequest.m @@ -0,0 +1,40 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCDRequest.h" +#import "OMRequest.h" +#import "OMConfig.h" + +@implementation OMCDRequest + +//type 0:Install, 1:Retargeting ++ (void)postWithType:(NSInteger)type data:(NSDictionary*)data completionHandler:(cdCompletionHandler)completionHandler { + + NSDictionary *parameters = [self parametersWithType:type data:data]; + NSError *jsonError; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&jsonError]; + if (jsonData && !jsonError && [[OMConfig sharedInstance].cdUrl length]>0) { + [OMRequest postWithUrl:[self cdUrl] data:jsonData completionHandler:^(NSObject *object, NSError *error) { + if (error) { + OMLogD(@"ic report error"); + } + }]; + } + +} + ++ (NSString *)cdUrl { + return [NSString stringWithFormat:@"%@?v=1&plat=0&sdkv=%@&k=%@",[OMConfig sharedInstance].cdUrl,OPENMEDIATION_SDK_VERSION,[OMConfig sharedInstance].appKey]; +} + ++ (NSDictionary*)parametersWithType:(NSInteger)type data:(NSDictionary*)data { + NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:[OMRequest commonDeviceInfo]]; + parameters[@"type"] = @(type); + if ([data isKindOfClass:[NSDictionary class]]) { + parameters[@"cd"] = data; + } + + return [parameters copy]; +} + +@end diff --git a/OpenMediation/OpenMediationNetwork/OMInitRequest.h b/OpenMediation/OpenMediationNetwork/OMInitRequest.h index 3c4c2bf..eb35bd3 100644 --- a/OpenMediation/OpenMediationNetwork/OMInitRequest.h +++ b/OpenMediation/OpenMediationNetwork/OMInitRequest.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @interface OMInitRequest : NSObject -+(void)configureWithAppKey:(NSString *)appKey completionHandler:(configureCompletionHandler)completionHandler; ++(void)configureWithAppKey:(NSString *)appKey baseHost:(NSString*)host completionHandler:(configureCompletionHandler)completionHandler; @end diff --git a/OpenMediation/OpenMediationNetwork/OMInitRequest.m b/OpenMediation/OpenMediationNetwork/OMInitRequest.m index aa6e6f3..4eef5bd 100644 --- a/OpenMediation/OpenMediationNetwork/OMInitRequest.m +++ b/OpenMediation/OpenMediationNetwork/OMInitRequest.m @@ -7,11 +7,10 @@ #import "OMConfig.h" #import "OMMediations.h" -#define OPENMEDIATION_INIT_HOST @"https://omtest.adtiming.com" @implementation OMInitRequest -+(void)configureWithAppKey:(NSString *)appKey completionHandler:(configureCompletionHandler)completionHandler { ++(void)configureWithAppKey:(NSString *)appKey baseHost:(NSString*)host completionHandler:(configureCompletionHandler)completionHandler { if (!appKey) { OMLogD(@"appkey nil"); return; @@ -19,6 +18,7 @@ +(void)configureWithAppKey:(NSString *)appKey completionHandler:(configureComple [OMConfig sharedInstance].initState = OMInitStateInitializing; OMLogD(@"init key = %@" ,appKey); + [OMConfig sharedInstance].baseHost = host; [OMConfig sharedInstance].appKey = appKey; [UIDevice omStoreSessionID]; NSDictionary *parameters = [self initParameters]; @@ -43,7 +43,7 @@ +(void)configureWithAppKey:(NSString *)appKey completionHandler:(configureComple } + (NSString*)initUrl { - return [NSString stringWithFormat:@"%@/init?v=1&plat=0&sdkv=%@&k=%@",OPENMEDIATION_INIT_HOST,OPENMEDIATION_SDK_VERSION,[OMConfig sharedInstance].appKey]; + return [NSString stringWithFormat:@"%@/init?v=1&plat=0&sdkv=%@&k=%@",[OMConfig sharedInstance].baseHost,OPENMEDIATION_SDK_VERSION,[OMConfig sharedInstance].appKey]; } diff --git a/OpenMediation/OpenMediationNetwork/OMLrRequest.m b/OpenMediation/OpenMediationNetwork/OMLrRequest.m index 9acafb3..5d3b790 100644 --- a/OpenMediation/OpenMediationNetwork/OMLrRequest.m +++ b/OpenMediation/OpenMediationNetwork/OMLrRequest.m @@ -16,8 +16,8 @@ + (void)postWithType:(OMLRType)type scene:(NSString *)sceneID abt:(NSInteger)abTest bid:(BOOL)bid { - - if ((type == OMLRTypeSDKInit || type == OMLRTypeWaterfallLoad)) { + OMUnit *unit = [[OMConfig sharedInstance].adUnitMap objectForKey:pid]; + if ((type == OMLRTypeSDKInit || type == OMLRTypeWaterfallLoad || (unit.adFormat == OpenMediationAdFormatCrossPromotion && (type == OMLRTypeInstanceLoad || type == OMLRTypeInstanceReady || type == OMLRTypeWaterfallReady)))) { return; } NSDictionary *parameters = [self lrParametersWithType:type pid:pid adnID:adnID instanceID:instanceID action:action scene:sceneID abt:abTest bid:bid]; diff --git a/OpenMediation/OpenMediationNetwork/OMNetworkUmbrella.h b/OpenMediation/OpenMediationNetwork/OMNetworkUmbrella.h index a330f29..c518300 100644 --- a/OpenMediation/OpenMediationNetwork/OMNetworkUmbrella.h +++ b/OpenMediation/OpenMediationNetwork/OMNetworkUmbrella.h @@ -14,5 +14,6 @@ #import "OMIAPRequest.h" #import "OMEventRequest.h" #import "OMHbRequest.h" +#import "OMCDRequest.h" #endif /* OMNetworkUmbrella_h */ diff --git a/OpenMediation/OpenMediationNetwork/OMRequest.m b/OpenMediation/OpenMediationNetwork/OMRequest.m index 0ee67cb..6252b4e 100644 --- a/OpenMediation/OpenMediationNetwork/OMRequest.m +++ b/OpenMediation/OpenMediationNetwork/OMRequest.m @@ -57,9 +57,13 @@ + (NSDictionary*)commonDeviceInfo { [deviceInfo setValue:[NSNumber numberWithInteger:[UIDevice omFreeRamSize]] forKey:@"fm"]; [deviceInfo setValue:[NSNumber numberWithInteger:[UIDevice omBatteryLevel]] forKey:@"battery"]; [deviceInfo setValue:[NSNumber numberWithInt:(int)[UIDevice omLowPowerMode]] forKey:@"lowp"]; - [deviceInfo setValue:[NSNumber numberWithLongLong:[UIDevice omRamSize]] forKey:@"ram"]; + [deviceInfo setValue:[NSNumber numberWithLongLong:[UIDevice omMemorySize]] forKey:@"ram"]; [deviceInfo setValue:[NSNumber numberWithLongLong:[UIDevice omBootTime]] forKey:@"btime"]; + if (!OM_STR_EMPTY([UIDevice omAFUid])) { + [deviceInfo setValue:[UIDevice omAFUid] forKey:@"afid"]; + } + if ([self regs]) { [deviceInfo setValue:[self regs] forKey:@"regs"]; } diff --git a/OpenMediation/OpenMediationNetwork/OMWaterfallRequest.m b/OpenMediation/OpenMediationNetwork/OMWaterfallRequest.m index 405ef81..d60590b 100644 --- a/OpenMediation/OpenMediationNetwork/OMWaterfallRequest.m +++ b/OpenMediation/OpenMediationNetwork/OMWaterfallRequest.m @@ -20,7 +20,7 @@ + (void)requestDataWithPid:(NSString *)pid NSDictionary *parameters = [self wfParametersWithPid:pid size:size actionType:actionType bidResponses:bidResponses tokens:tokens instanceState:instanceState]; NSError *jsonError; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&jsonError]; - if (jsonData && !jsonError && [[OMConfig sharedInstance].clUrl length]>0) { + if (jsonData && !jsonError && [[OMConfig sharedInstance].wfUrl length]>0) { [OMRequest postWithUrl:[self waterfallUrl] data:jsonData completionHandler:^(NSObject *object, NSError *error) { if (!error) { if ([object isKindOfClass:[NSDictionary class]]) { @@ -36,7 +36,7 @@ + (void)requestDataWithPid:(NSString *)pid } + (NSString*)waterfallUrl { - return [NSString stringWithFormat:@"%@?v=1&plat=0&sdkv=%@",[OMConfig sharedInstance].clUrl,OPENMEDIATION_SDK_VERSION]; + return [NSString stringWithFormat:@"%@?v=1&plat=0&sdkv=%@",[OMConfig sharedInstance].wfUrl,OPENMEDIATION_SDK_VERSION]; } + (NSDictionary*)wfParametersWithPid:(NSString*)pid diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.h new file mode 100644 index 0000000..82f00de --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.h @@ -0,0 +1,22 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import "OMBannerCustomEvent.h" +#import "OMCrossPromotionCampaign.h" +#import "OMCrossPromotionJSBridge.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionBanner : UIView + +@property (nonatomic, assign) CGSize bannerSize; +@property(nonatomic, weak, nullable) id delegate; +- (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParameter rootViewController:(UIViewController *)rootViewController; + +- (void)loadAdWithBidPayload:(NSString*)bidPayload; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.m new file mode 100644 index 0000000..3578901 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBanner.m @@ -0,0 +1,249 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionBanner.h" +#import +#import "OMToolUmbrella.h" +#import "OMCrossPromotionJSBridge.h" +#import "OMCrossPromotionCampaignManager.h" +#import "OMCrossPromotionExposureMonitor.h" +#import "OMCrossPromotionClRequest.h" + + +@protocol PromotionEventDelegate + +@optional + +- (void)customEventAddEvent:(NSObject*)adapter event:(NSDictionary*)eventBody; + +@end + +@interface OMCrossPromotionBanner () + +@property (nonatomic, strong) OMCrossPromotionJSBridge *jsBridge; +@property (nonatomic, strong) WKWebView *adWebView; +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; +@property (nonatomic, weak) UIViewController *rootViewController; +@property (nonatomic, strong) NSString *placementID; +@property (nonatomic, assign) BOOL impr; + +@end + +@implementation OMCrossPromotionBanner + + +- (instancetype)initWithFrame:(CGRect)frame adParameter:(NSDictionary *)adParameter rootViewController:(UIViewController *)rootViewController { + if (self = [super initWithFrame:frame]) { + if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { + _placementID = [adParameter objectForKey:@"pid"]; + _rootViewController = rootViewController; + _bannerSize = frame.size; + } + } + return self; +} + +- (void)bannerRefresh { + if (OM_STR_EMPTY(self.placementID)) { + return; + } + __weak __typeof(self) weakSelf = self; + [[OMCrossPromotionCampaignManager sharedInstance] loadPid:self.placementID size:_bannerSize action:4 completionHandler:^(OMCrossPromotionCampaign *campaign, NSError *error) { + if (error) { + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [weakSelf.delegate customEvent:self didFailToLoadWithError:error]; + } + } else { + weakSelf.campaign = campaign; + weakSelf.campaign.clickHanlerDelegate = weakSelf; + [campaign cacheMaterielCompletion:^{ + if(weakSelf) { + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [weakSelf.delegate customEvent:self didLoadAd:nil]; + } + weakSelf.impr = NO; + [weakSelf addSubview:self.adWebView]; + weakSelf.jsBridge.campaign = campaign; + [weakSelf.adWebView loadHTMLString:[weakSelf.campaign webHtmlStr] baseURL:[NSURL fileURLWithPath:[NSString omUrlCachePath:[weakSelf.campaign webUrl]]]]; + } + }]; + } + }]; +} + +- (void)loadAdWithBidPayload:(NSString*)bidPayload { + NSString *payload = @""; + if ([bidPayload length]>0) { + NSData *data = [bidPayload dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *admBody = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if([admBody isKindOfClass:[NSDictionary class]]) { + payload = admBody[@"payload"]; + } + } + if (![payload length]) { + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + NSError *error = [[NSError alloc]initWithDomain:@"com.crosspromotion.ads" code:501 userInfo: @{NSLocalizedDescriptionKey:@"Invalid bid payload"}]; + [_delegate customEvent:self didFailToLoadWithError:error]; + } + return; + } + + __weak __typeof(self) weakSelf = self; + [[OMCrossPromotionCampaignManager sharedInstance] loadAdWithPid:self.placementID size:_bannerSize action:4 payload:payload completionHandler:^(OMCrossPromotionCampaign *campaign, NSError *error) { + if (error) { + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [weakSelf.delegate customEvent:self didFailToLoadWithError:error]; + } + } else { + weakSelf.campaign = campaign; + weakSelf.campaign.clickHanlerDelegate = weakSelf; + [campaign cacheMaterielCompletion:^{ + if(weakSelf) { + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [weakSelf.delegate customEvent:self didLoadAd:nil]; + } + weakSelf.impr = NO; + [self addSubview:self.adWebView]; + self.jsBridge.campaign = campaign; + [self.adWebView loadHTMLString:[weakSelf.campaign webHtmlStr] baseURL:[NSURL fileURLWithPath:[NSString omUrlCachePath:[weakSelf.campaign webUrl]]]]; + } + }]; + } + }]; +} + +- (void)drawRect:(CGRect)rect { + [[OMCrossPromotionExposureMonitor sharedInstance]addObserver:self forView:self]; + [super drawRect:rect]; +} + +- (void)observeView:(UIView*)view visible:(BOOL)visible { + if(visible) { + if(!_impr) { + _impr =YES; + [self impression]; + [_jsBridge sendEvent:OMCrossPromotionJSEventShow]; + } + } + +} + +- (void)impression { + [self.campaign impression:@""]; +} + + +- (WKWebView*)adWebView { + if(!_adWebView) { + WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init]; + if (@available(iOS 13.0, *)) { + config.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile; + } + WKPreferences *preference = [[WKPreferences alloc]init]; + preference.javaScriptEnabled = YES; + [preference setValue:@YES forKey:@"allowFileAccessFromFileURLs"]; + config.preferences = preference; + config.allowsInlineMediaPlayback = YES; + config.requiresUserActionForMediaPlayback = NO; + + WKUserContentController * wkUController = [[WKUserContentController alloc] init]; + config.userContentController = wkUController; + + _adWebView = [[WKWebView alloc] initWithFrame:self.bounds configuration:config]; + _adWebView.backgroundColor = [UIColor whiteColor]; + _adWebView.opaque = NO; + _adWebView.UIDelegate = self; + _adWebView.navigationDelegate = self; + _jsBridge = [[OMCrossPromotionJSBridge alloc]initWithBindWebView:_adWebView placementID:self.placementID]; + _jsBridge.jsMessageHandler = self; + } + return _adWebView; +} + +#pragma mark - WKNavigationDelegate + +-(void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + NSURL *url = navigationAction.request.URL; + if ([url.scheme containsString:@"itms-apps"] ) { + [[UIApplication sharedApplication] openURL:url]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + decisionHandler(WKNavigationActionPolicyAllow); +} + +#pragma mark -- OMCrossPromotionJSBridgeDelegate + +- (void)jsBridgePushEvent:(NSString*)eventBody { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if(!OM_STR_EMPTY(eventBody)) { + NSData *data = [eventBody dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if(!jsonErr) { + id delegate = (id)weakSelf.delegate; + NSMutableDictionary *body = [NSMutableDictionary dictionaryWithDictionary:dict]; + if(delegate && [delegate respondsToSelector:@selector(customEventAddEvent:event:)]) { + [delegate customEventAddEvent:weakSelf event:body]; + } + } + } + }); +} + +- (void)jsBridgeClick:(BOOL)trackClick { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(bannerCustomEventDidClick:)]) { + [weakSelf.delegate bannerCustomEventDidClick:self]; + } + if (weakSelf.rootViewController && trackClick) { + [weakSelf.campaign clickAndShowAd:weakSelf.rootViewController sceneID:@""]; + } + }); +} + +- (void)jsBridgWillOpenBrowser { + [self campaignClickHandlerLeaveApplication]; +} + +- (void)jsBridgeRefreshAd:(NSInteger)millisecond { + __weak __typeof(self) weakSelf = self; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(millisecond * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ + [OMCrossPromotionClRequest requestCampaignWithPid:weakSelf.placementID size:weakSelf.bannerSize actionType:2 payload:nil completionHandler:^(NSDictionary *insAndCampaigns, NSError *error) { + if(!error) { + NSArray *campaigns = [insAndCampaigns objectForKey:@"campaigns"]; + if(campaigns && [campaigns isKindOfClass:[NSArray class]]) { + [[OMCrossPromotionCampaignManager sharedInstance]addCampaignsWithData:campaigns pid:weakSelf.placementID]; + } + [weakSelf bannerRefresh]; + } + }]; + }); + +} + +#pragma mark -- AdTimingCampaignClickHandlerDelegate + +- (void)campaignClickHandlerWillPresentScreen { + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillPresentScreen:)]) { + [_delegate bannerCustomEventWillPresentScreen:self]; + } +} + +- (void)campaignClickHandlerDisDismissScrren { + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventDismissScreen:)]) { + [_delegate bannerCustomEventDismissScreen:self]; + } +} + +- (void)campaignClickHandlerLeaveApplication { + if(_delegate && [_delegate respondsToSelector:@selector(bannerCustomEventWillLeaveApplication:)]) { + [_delegate bannerCustomEventWillLeaveApplication:self]; + } +} + + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.h new file mode 100644 index 0000000..a303c47 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.h @@ -0,0 +1,12 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionBid : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.m new file mode 100644 index 0000000..f4bc0fe --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionBid.m @@ -0,0 +1,58 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionBid.h" +#import "OpenMediationConstant.h" +#import "OMToolUmbrella.h" +#import "OMAudience.h" + +@implementation OMCrossPromotionBid + ++ (NSString*)bidderToken { + NSMutableDictionary *body = [NSMutableDictionary dictionary]; + [body setValue:OPENMEDIATION_SDK_VERSION forKey:@"sdkv"]; + [body setValue:[UIDevice omInstallTime] forKey:@"fit"]; + [body setValue:[UIDevice omFirstLaunchTime] forKey:@"flt"]; + [body setValue:[UIDevice omSessionID] forKey:@"session"]; + [body setValue:[UIDevice omUserID] forKey:@"uid"]; + [body setValue:[UIDevice omIdfa] forKey:@"did"]; + [body setValue:[UIDevice omDeviveIDType] forKey:@"dtype"]; + [body setValue:[UIDevice omMinutesFromGMT] forKey:@"zo"]; + [body setValue:[NSNumber numberWithInteger:[UIDevice omFreeRamSize]] forKey:@"fm"]; + [body setValue:[NSNumber numberWithInteger:[UIDevice omBatteryLevel]] forKey:@"battery"]; + [body setValue:[UIDevice omCountryCode] forKey:@"lcy"]; + + if([OMAudience sharedInstance].purchaseAmount > 0) { + [body setValue:[NSNumber numberWithFloat:[OMAudience sharedInstance].purchaseAmount] forKey:@"iap"]; + } + + + if([[UIDevice omAFUid]length]>0) { + [body setValue:[UIDevice omAFUid] forKey:@"afid"]; + } + + if([UIDevice omJailbreak]) { + [body setValue:[NSNumber numberWithInt:(int)[UIDevice omJailbreak]] forKey:@"jb"]; + } + + if([UIDevice omLowPowerMode]) { + [body setValue:[NSNumber numberWithInt:(int)[UIDevice omLowPowerMode]] forKey:@"lowp"]; + } + + + NSError *jsonError; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:body options:0 error:&jsonError]; + + NSString *token = @""; + if(!jsonError && jsonData) { + jsonData = [jsonData omZlibDeflate]; + if(jsonData && [jsonData length]) { + token = [jsonData base64EncodedStringWithOptions:0]; + } + } + + return token; + +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.h new file mode 100644 index 0000000..624a689 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.h @@ -0,0 +1,24 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMCrossPromotionCustomEvent.h" +#import "OMCrossPromotionCampaign.h" +#import "OMCrossPromotionJSBridge.h" + + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionCP : UIView + +@property(nonatomic, weak, nullable) id delegate; + +- (instancetype)initWithParameter:(NSDictionary*)adParameter; +- (void)loadAd; +- (BOOL)isReady; +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString*)sceneName; +- (void)hideAd; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.m new file mode 100644 index 0000000..3192d9e --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCP.m @@ -0,0 +1,231 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionCP.h" +#import +#import "OMNetworkUmbrella.h" +#import "OMModelUmbrella.h" +#import "OMCrossPromotionCampaignManager.h" +#import "OMToolUmbrella.h" +#import "OMModelUmbrella.h" +#import "OMCrossPromotionClRequest.h" +#import "OMCrossPromotionExposureMonitor.h" +#import "OMCrossPromotionJSBridge.h" + +@protocol PromotionEventDelegate + +@optional + +- (void)customEventAddEvent:(NSObject*)adapter event:(NSDictionary*)eventBody; + +@end + +@interface OMCrossPromotionCP () + +@property (nonatomic, strong) OMCrossPromotionJSBridge *jsBridge; +@property (nonatomic, strong) WKWebView *adWebView; +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; +@property (nonatomic, weak) UIViewController *rootViewController; +@property (nonatomic, strong) NSString *placementID; +@property (nonatomic, assign) BOOL impr; +@property (nonatomic, copy) NSString *showSceneID; + +@end + +@implementation OMCrossPromotionCP + +- (instancetype)initWithParameter:(NSDictionary*)adParameter { + if (self = [super initWithFrame:CGRectMake(0, 0, 1, 1)]) { + self.hidden = YES; + self.layer. shouldRasterize = YES; + self.layer.allowsEdgeAntialiasing = YES; + if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { + _placementID = [adParameter objectForKey:@"pid"]; + } + _rootViewController = [UIViewController omCurrentWindow].rootViewController; + [_rootViewController.view addSubview:self]; + } + return self; +} + +- (void)loadAd { + if (OM_STR_EMPTY(self.placementID)) { + return; + } + __weak __typeof(self) weakSelf = self; + [[OMCrossPromotionCampaignManager sharedInstance] loadPid:self.placementID size:[UIScreen mainScreen].bounds.size action:4 completionHandler:^(OMCrossPromotionCampaign *campaign, NSError *error) { + if (error) { + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [weakSelf.delegate customEvent:weakSelf didFailToLoadWithError:error]; + } + } else { + weakSelf.campaign = campaign; + weakSelf.campaign.clickHanlerDelegate = weakSelf; + [campaign cacheMaterielCompletion:^{ + if(weakSelf) { + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [weakSelf.delegate customEvent:self didLoadAd:nil]; + } + weakSelf.impr = NO; + [self addSubview:self.adWebView]; + self.jsBridge.campaign = campaign; + [self.adWebView loadHTMLString:[weakSelf.campaign webHtmlStr] baseURL:[NSURL fileURLWithPath:[NSString omUrlCachePath:[weakSelf.campaign webUrl]]]]; + } + }]; + } + }]; + + +} + +- (void)checkCampgian { + [[OMCrossPromotionCampaignManager sharedInstance] loadPid:self.placementID size:[UIScreen mainScreen].bounds.size action:4 completionHandler:^(OMCrossPromotionCampaign *campaign, NSError *error) { + + }]; +} + +- (BOOL)isReady { + if(self.campaign && [self.campaign isReady]) { + [self checkCampgian]; + return YES; + } + return NO; +} + +- (void)showAdWithSize:(CGSize)adSize screenPoint:(CGPoint)scaleXY xAngle:(CGFloat) xAngle zAngle:(CGFloat)zAngle scene:(NSString*)sceneName { + if (_delegate && [_delegate respondsToSelector:@selector(promotionCustomEventWillAppear:)]) { + [_delegate promotionCustomEventWillAppear:self]; + } + + self.frame = CGRectMake(0,0, adSize.width, adSize.height); + _adWebView.frame = CGRectMake(0,0, adSize.width, adSize.height); + self.center = CGPointMake(scaleXY.x *_rootViewController.view.frame.size.width, scaleXY.y *_rootViewController.view.frame.size.height); + self.layer.anchorPoint = CGPointMake(0.5, 0); + self.transform = CGAffineTransformMakeRotation(xAngle/180.0*M_PI); + + CATransform3D transform = CATransform3DRotate(CATransform3DIdentity,(xAngle)/180.0*M_PI,0,0,1) ; + transform.m34 = -1.0/500; + self.layer.transform =CATransform3DRotate(transform,(zAngle)/180.0*M_PI,1,0,0); + self.hidden = NO; + [_rootViewController.view addSubview:self]; +} + +- (void)hideAd { + [self removeFromSuperview]; + if (_delegate && [_delegate respondsToSelector:@selector(promotionCustomEventDidDisAppear:)]) { + [_delegate promotionCustomEventDidDisAppear:self]; + } +} + +- (void)drawRect:(CGRect)rect { + [[OMCrossPromotionExposureMonitor sharedInstance]addObserver:self forView:self]; + [super drawRect:rect]; +} + +- (void)observeView:(UIView*)view visible:(BOOL)visible { + if(visible) { + if(!_impr) { + _impr =YES; + [self impression]; + [_jsBridge sendEvent:OMCrossPromotionJSEventShow]; + } + } + +} + +- (void)impression { + [self.campaign impression:OM_SAFE_STRING(self.showSceneID)]; +} + + +- (WKWebView*)adWebView { + if(!_adWebView) { + WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init]; + if (@available(iOS 13.0, *)) { + config.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile; + } + WKPreferences *preference = [[WKPreferences alloc]init]; + preference.javaScriptEnabled = YES; + [preference setValue:@YES forKey:@"allowFileAccessFromFileURLs"]; + config.preferences = preference; + config.allowsInlineMediaPlayback = YES; + config.requiresUserActionForMediaPlayback = NO; + + WKUserContentController * wkUController = [[WKUserContentController alloc] init]; + config.userContentController = wkUController; + + _adWebView = [[WKWebView alloc] initWithFrame:self.bounds configuration:config]; + _adWebView.backgroundColor = [UIColor whiteColor]; + _adWebView.opaque = NO; + _adWebView.UIDelegate = self; + _adWebView.navigationDelegate = self; + _jsBridge = [[OMCrossPromotionJSBridge alloc]initWithBindWebView:_adWebView placementID:self.placementID]; + _jsBridge.jsMessageHandler = self; + + } + return _adWebView; +} + +#pragma mark - WKNavigationDelegate + +-(void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + NSURL *url = navigationAction.request.URL; + if ([url.scheme containsString:@"itms-apps"] ) { + [[UIApplication sharedApplication] openURL:url]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + decisionHandler(WKNavigationActionPolicyAllow); +} + +#pragma mark -- AdTimingJSDelegate + +- (void)jsBridgeRefreshAd:(NSInteger)millisecond { + __weak __typeof(self) weakSelf = self; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(millisecond * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ + [OMCrossPromotionClRequest requestCampaignWithPid:weakSelf.placementID size:[UIScreen mainScreen].bounds.size actionType:2 payload:nil completionHandler:^(NSDictionary *insAndCampaigns, NSError *error) { + if(!error) { + NSArray *campaigns = [insAndCampaigns objectForKey:@"campaigns"]; + if(campaigns && [campaigns isKindOfClass:[NSArray class]]) { + [[OMCrossPromotionCampaignManager sharedInstance]addCampaignsWithData:campaigns pid:weakSelf.placementID]; + } + [weakSelf loadAd]; + } + }]; + }); + +} + +- (void)jsBridgeClick:(BOOL)clickTrack { + //click + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(promotionCustomEventDidClick:)]) { + [weakSelf.delegate promotionCustomEventDidClick:self]; + } + if (weakSelf.rootViewController && clickTrack) { + [weakSelf.campaign clickAndShowAd:weakSelf.rootViewController sceneID:self.showSceneID]; + } + }); +} + +- (void)jsBridgePushEvent:(NSString*)eventBody { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if(!OM_STR_EMPTY(eventBody)) { + NSData *data = [eventBody dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if(!jsonErr) { + id delegate = (id)(weakSelf.delegate); + NSMutableDictionary *body = [NSMutableDictionary dictionaryWithDictionary:dict]; + [body setObject:OM_SAFE_STRING(self.showSceneID) forKey:@"scene"]; + if(delegate && [delegate respondsToSelector:@selector(customEventAddEvent:event:)]) { + [delegate customEventAddEvent:weakSelf event:body]; + } + } + } + }); +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.h new file mode 100644 index 0000000..b436eb1 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.h @@ -0,0 +1,15 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMToolUmbrella.h" +#import "OMCrossPromotionHTTPCacheControl.h" +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionCacheFile : NSObject ++ (BOOL)cacheFresh:(NSString*)url; ++ (NSDictionary*)cacheHeader:(NSString*)url; ++ (NSString*)localHtmlStr:(NSString*)url; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.m new file mode 100644 index 0000000..9460292 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCacheFile.m @@ -0,0 +1,44 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionCacheFile.h" +#import "OMCrossPromotionHTTPCacheControl.h" +#import "OMToolUmbrella.h" + +@implementation OMCrossPromotionCacheFile + ++ (BOOL)cacheFresh:(NSString*)url { + BOOL cacheReady = [NSString omUrlCacheReady:url]; + BOOL expires = [OMCrossPromotionHTTPCacheControl cacheExpire:url]; + return (cacheReady && !expires); +} + ++ (NSDictionary*)cacheHeader:(NSString*)url { + if(!OM_STR_EMPTY(url) && [NSString omUrlCacheReady:url]) { + NSDictionary *headers =[OMCrossPromotionHTTPCacheControl cacheHeaders:url]; + return headers; + }else{ + return [NSDictionary dictionary]; + } +} + ++ (NSString*)localHtmlStr:(NSString*)url { + NSString *htmlContent = @""; + + if (!OM_STR_EMPTY(url)) { + if([NSString omUrlCacheReady:url]) { + NSString *urlCachePath = [NSString omUrlCachePath:url]; + NSData *fileData = [NSData dataWithContentsOfFile:urlCachePath]; + if(!OM_DATA_EMPTY(fileData)) { + NSString *fileContent = [[NSString alloc]initWithData:fileData encoding:NSUTF8StringEncoding]; + if(!OM_STR_EMPTY(fileContent)) { + htmlContent = fileContent; + } + } + } + + } + return htmlContent; +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.h new file mode 100644 index 0000000..665ce03 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.h @@ -0,0 +1,64 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OpenMediationConstant.h" +#import "OpenMediationAdFormats.h" +#import "OMCrossPromotionCampaignModel.h" +#import "OMNetworkUmbrella.h" +#import "OMCrossPromotionClickHandler.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, OMCrossPromotionCampaignState) { + OMCrossPromotionCampaignStateDefault = 0, + OMCrossPromotionCampaignStateDataReady, + OMCrossPromotionCampaignStateImpression, + OMCrossPromotionCampaignStateClick, +}; + +@protocol OMCrossPromotionCampaignClickHandlerDelegate + +@optional + +- (void)campaignClickHandlerWillPresentScreen; +- (void)campaignClickHandlerDisDismissScrren; +- (void)campaignClickHandlerLeaveApplication; +@end + +typedef void(^cacheCompletionHandler)(void); + +@interface OMCrossPromotionCampaign : NSObject + +@property (nonatomic, strong) OMCrossPromotionCampaignModel *model; +@property (nonatomic, assign) NSTimeInterval expireTime; +@property (nonatomic, strong) NSString *pid; +@property (nonatomic, assign) OpenMediationAdFormat adFormat; +@property (nonatomic, assign) OMCrossPromotionCampaignState state; +@property (nonatomic, strong) OMCrossPromotionClickHandler *clickHandler; +@property (nonatomic, copy, nullable) cacheCompletionHandler cacheReadyCompletion; +@property (nonatomic, weak) id clickHanlerDelegate; +- (instancetype)initWithCampaignData:(NSDictionary*)cData pid:(NSString*)pid; +- (BOOL)isReady; +- (void)cacheMaterielCompletion:(cacheCompletionHandler)completionHandler; +- (BOOL)iconReady; +- (NSString*)iconCachePath; +- (BOOL)mainImgReady; +- (BOOL)videoReady; +- (NSString*)mainImgCachePath; +- (NSString*)videoCachePath; +- (BOOL)resourceReady; +- (NSString*)webUrl; +- (NSString*)webHtmlStr; +- (void)impression; +- (void)impression:(nullable NSString*)sceneID; +- (void)clickAndShowAd:(UIViewController*)rootVC; +- (void)clickAndShowAd:(UIViewController*)rootVC sceneID:(nullable NSString*)sceneID; +- (BOOL)expire; +- (NSDictionary*)originData; +- (UIImage*)logoImage; +- (void)iconClick; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.m new file mode 100644 index 0000000..c9cbe0b --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaign.m @@ -0,0 +1,316 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionCampaign.h" +#import "OMToolUmbrella.h" +#import "OMCrossPromotionCacheFile.h" +#import "OMCrossPromotionCampaignModel.h" +#import "OMCrossPromotionClickHandler.h" +#import "OMNetworkUmbrella.h" +#import "OMCrossPromotionDownloadManager.h" + +@implementation OMCrossPromotionCampaign + +- (instancetype)initWithCampaignData:(NSDictionary*)cData pid:(NSString*)pid { + + if (self = [super init]) { + _model = [[OMCrossPromotionCampaignModel alloc]initWithCampaignData:cData]; + _expireTime = [[NSDate date]timeIntervalSince1970] + _model.expire; + _pid = pid; + _adFormat = _model.adFormat; + _state = OMCrossPromotionCampaignStateDataReady; + } + return self; +} + +- (BOOL)isExpire { + return ([[NSDate date]timeIntervalSince1970] > _expireTime); +} + +- (BOOL)isReady { + return (_state == OMCrossPromotionCampaignStateDataReady && ![self isExpire] && [self iconReady] && [self mainImgReady] && [self videoReady] && [self resourceReady] && [self adMarkReady]); +} + +- (BOOL)mainImgReady { + BOOL imgReady = YES; + for (NSString *img in _model.imgs) { + if(![OMCrossPromotionCacheFile cacheFresh:img]) { + imgReady = NO; + } + } + return imgReady; +} + +- (BOOL)videoReady { + return [OMCrossPromotionCacheFile cacheFresh:OM_SAFE_STRING(_model.video[@"url"])]; +} + +- (BOOL)resourceReady { + BOOL isReady = YES; + for (NSString* resource in _model.resources) { + if(!OM_STR_EMPTY(resource)) { + if(![OMCrossPromotionCacheFile cacheFresh:resource]) { + isReady = NO; + } + } + } + return isReady; +} + +- (BOOL)adMarkReady { + BOOL isReady = YES; + if(_model.adMark && _model.adMark[@"logo"]) { + isReady = [OMCrossPromotionCacheFile cacheFresh:_model.adMark[@"logo"]]; + } + return isReady; +} +- (NSString*)webHtmlStr { + if([self resourceReady]) { + return [OMCrossPromotionCacheFile localHtmlStr:[self webUrl]]; + }else{ + return @""; + } +} + +- (void)cacheMaterielCompletion:(cacheCompletionHandler)completionHandler { + _cacheReadyCompletion = completionHandler; + if(!self.clickHandler) { + self.clickHandler = [[OMCrossPromotionClickHandler alloc]initWithAppID:_model.app[@"id"] ska:_model.ska adURL:_model.link]; + self.clickHandler.campainID = _model.cid; + self.clickHandler.delegate = self; + } + if([self isReady]) { + __weak __typeof(self) weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + if(weakSelf && weakSelf.cacheReadyCompletion) { + weakSelf.cacheReadyCompletion(); + weakSelf.cacheReadyCompletion = nil; + } + }); + }else{ + NSDictionary *downloadExtraValue = @{@"pid":self.pid,@"campaignId":self.model.cid,@"creativeId":self.model.crid}; + if(![self iconImgEmpty] && ![self iconReady]) { + OMLogD(@"campaign download icon image"); + [[OMCrossPromotionDownloadManager sharedInstance]downloadUrl:_model.app[@"icon"] extra:downloadExtraValue completion:^(NSError *error) { + if(!error) { + OMLogD(@"campaign download icon image success"); + [self checkCacheReady]; + } + }]; + } + if(![self mainImgEmpty] && ![self mainImgReady]) { + OMLogD(@"campaign download main image"); + + for (NSString *img in _model.imgs) { + [[OMCrossPromotionDownloadManager sharedInstance]downloadUrl:img extra:downloadExtraValue completion:^(NSError *error) { + if(!error) { + OMLogD(@"campaign download image %@",img); + [self checkCacheReady]; + } + }]; + } + } + if(![self videoEmpty] && ![self videoReady]) { + OMLogD(@"campaign download video "); + [[OMCrossPromotionDownloadManager sharedInstance]downloadUrl:_model.video[@"url"] extra:downloadExtraValue completion:^(NSError *error) { + if(!error) { + OMLogD(@"campaign download video success"); + [self checkCacheReady]; + } + }]; + } + if(![self adMarkReady]) { + OMLogD(@"campaign download admark %@",_model.adMark[@"logo"]); + [[OMCrossPromotionDownloadManager sharedInstance]downloadUrl:_model.adMark[@"logo"] extra:downloadExtraValue completion:^(NSError *error) { + if(!error) { + OMLogD(@"campaign download admark success"); + [self checkCacheReady]; + } + }]; + } + for (NSString* resource in _model.resources) { + if(!OM_STR_EMPTY(resource)) { + [[OMCrossPromotionDownloadManager sharedInstance]downloadUrl:resource extra:downloadExtraValue completion:^(NSError *error) { + if(!error) { + OMLogD(@"campaign download admark success"); + [self checkCacheReady]; + } + }]; + } + } + } + + +} + +- (void)checkCacheReady { + if([self isReady]) { + __weak __typeof(self) weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + if(weakSelf.cacheReadyCompletion) { + weakSelf.cacheReadyCompletion(); + weakSelf.cacheReadyCompletion = nil; + } + }); + } +} + +- (BOOL)iconImgEmpty { + return OM_STR_EMPTY(_model.app[@"icon"]); +} + +- (BOOL)iconReady{ + return [OMCrossPromotionCacheFile cacheFresh: _model.app[@"icon"]]; +} + +- (NSString*)iconCachePath { + return [NSString omUrlCachePath:_model.app[@"icon"]]; +} + +- (BOOL)mainImgEmpty { + return (_model.imgs.count == 0); +} + +- (NSString*)mainImgCachePath { + NSString *mainImg = @""; + if (_model.imgs.count >0) { + mainImg = [NSString omUrlCachePath:_model.imgs[0]]; + } + return mainImg; +} + + +- (BOOL)videoEmpty { + return OM_STR_EMPTY(_model.video[@"url"]); +} + + +- (NSString*)videoCachePath { + return [NSString omUrlCachePath:_model.video[@"url"]]; +} + + +- (NSString*)webUrl { + NSString *url = @""; + if(_model.resources.count > 0) { + url = [_model.resources firstObject]; + } + return url; +} + +- (void)impression { + [self impression:nil]; +} + +- (void)impression:(NSString*)sceneID { + if(_state < OMCrossPromotionCampaignStateImpression) { + _state = OMCrossPromotionCampaignStateImpression; + [self imprTrack:sceneID]; + } +} + +- (void)imprTrack { + [self imprTrack:nil]; +} + +- (void)imprTrack:(NSString*)sceneID { + + for (NSString* url in _model.imptks) { + NSString *trackUrl = [NSString stringWithFormat:@"%@&con_type=%@",url,[[OMNetMonitor sharedInstance] getNetWorkType]]; + if([trackUrl containsString:@"{scene}"]) { + trackUrl = [trackUrl stringByReplacingOccurrencesOfString:@"{scene}" withString:OM_SAFE_STRING(sceneID)]; + } + [OMBaseRequest getWithUrl:trackUrl type:OMRequestTypeNormal body:[NSData data] completionHandler:^(NSObject * _Nullable object, NSError * _Nullable error) { + if(!error) { + }else{ + OMLogD(@"itrak fail"); + } + }]; + } + +} + +- (void)clickAndShowAd:(UIViewController*)rootVC { + [self clickAndShowAd:rootVC sceneID:nil]; +} + +- (void)clickAndShowAd:(UIViewController*)rootVC sceneID:(NSString*)sceneID { + _state = OMCrossPromotionCampaignStateClick; + if (_model.clktks.count>0) { + OMLogD(@"clicks task -- %@",_model.clktks); + [self requestClksWithScene:sceneID]; + } + if(rootVC) { + if(_model.iswv) { + [_clickHandler clickWebAd:rootVC scene:sceneID]; + }else{ + [_clickHandler clickAppAd:rootVC scene:sceneID]; + } + } +} + + +- (BOOL)expire { + return ([[NSDate date]timeIntervalSince1970]>_expireTime); +} + +- (NSDictionary*)originData { + return _model.originData; +} + +-(void)requestClksWithScene:(NSString*)sceneID { + for (NSString *url in _model.clktks) { + NSString *clickUrl = url; + if([clickUrl containsString:@"{scene}"]) { + clickUrl = [clickUrl stringByReplacingOccurrencesOfString:@"{scene}" withString:OM_SAFE_STRING(sceneID)]; + } + [OMBaseRequest getWithUrl:clickUrl type:OMRequestTypeNormal body:[NSData data] completionHandler:^(NSObject * _Nullable object, NSError * _Nullable error) { + if(!error) { + }else{ + OMLogD(@"itrak fail"); + } + }]; + } +} + +- (UIImage*)logoImage { + if ([_model.adMark isKindOfClass:[NSNull class]] || [_model.adMark isEqual:[NSNull null]]) { + return nil; + } + if (!OM_STR_EMPTY(_model.adMark[@"logo"])) { + UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_model.adMark[@"logo"]]]]; + return image; + }else{ + UIImage *image = [UIImage new]; + return image; + } +} + +- (void)iconClick { + if (_model.adMark && [_model.adMark isKindOfClass:[NSDictionary class]] && !OM_STR_EMPTY(_model.adMark[@"link"])) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_model.adMark[@"link"]]]; + } +} + + +#pragma mark -- AdTimingClickHandlerDelegate + +- (void)clickHandlerWillPresentScreen { + if(_clickHanlerDelegate && [_clickHanlerDelegate respondsToSelector:@selector(campaignClickHandlerWillPresentScreen)]) { + [_clickHanlerDelegate campaignClickHandlerWillPresentScreen]; + } +} + +- (void)clickHandlerDisDismissScrren { + if(_clickHanlerDelegate && [_clickHanlerDelegate respondsToSelector:@selector(campaignClickHandlerDisDismissScrren)]) { + [_clickHanlerDelegate campaignClickHandlerDisDismissScrren]; + } +} + +- (void)clickHandlerLeaveApplication { + if(_clickHanlerDelegate && [_clickHanlerDelegate respondsToSelector:@selector(campaignClickHandlerLeaveApplication)]) { + [_clickHanlerDelegate campaignClickHandlerLeaveApplication]; + } +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.h new file mode 100644 index 0000000..59bcbe3 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.h @@ -0,0 +1,37 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import "OMCrossPromotionCampaign.h" + +typedef void(^loadCompletionHandler)( OMCrossPromotionCampaign * _Nullable campaign,NSError * _Nullable error); + + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionCampaignManager : NSObject + +@property (nonatomic, strong) NSMutableDictionary *placmentAdsMap; + ++ (instancetype)sharedInstance; + +- (void)loadPid:(NSString*)pid + size:(CGSize)size + action:(NSInteger)action +completionHandler:(loadCompletionHandler)completionHandler; + +- (void)loadAdWithPid:(NSString*)pid + size:(CGSize)size + action:(NSInteger)action + payload:(nullable NSString*)payload +completionHandler:(loadCompletionHandler)completionHandler; + +- (void)addCampaignsWithData:(NSArray*)campaignsData pid:(NSString*)pid; + +- (OMCrossPromotionCampaign*)getCampaignWithPid:(NSString*)pid; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.m new file mode 100644 index 0000000..62b3359 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignManager.m @@ -0,0 +1,157 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionCampaignManager.h" +#import "OMCrossPromotionClRequest.h" +#import "OMConfig.h" + + +static OMCrossPromotionCampaignManager * _instance = nil; + +@implementation OMCrossPromotionCampaignManager + ++ (instancetype)sharedInstance { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] init]; + }); + return _instance; +} + +- (instancetype)init { + if (self = [super init]) { + _placmentAdsMap = [NSMutableDictionary dictionary]; + } + return self; +} + +- (void)loadPid:(NSString*)pid + size:(CGSize)size + action:(NSInteger)action +completionHandler:(loadCompletionHandler)completionHandler { + [self loadAdWithPid:pid size:size action:action payload:nil completionHandler:completionHandler]; +} + +- (void)loadAdWithPid:(NSString*)pid + size:(CGSize)size + action:(NSInteger)action + payload:(NSString*)payload +completionHandler:(loadCompletionHandler)completionHandler { + + if ([payload length] > 0) { + [self cleanAds:pid]; + } + + NSMutableArray *ads = [NSMutableArray array]; + if ([_placmentAdsMap objectForKey:pid]) { + ads = [NSMutableArray arrayWithArray:[_placmentAdsMap objectForKey:pid]]; + } + [self passExpireAds:ads]; + + NSInteger cacheCount = 1; + OMUnit *unit = [[OMConfig sharedInstance].adUnitMap objectForKey:pid]; + if (unit && unit.adFormat == OpenMediationAdFormatCrossPromotion) { + cacheCount = unit.cacheCount; + } + if (ads.count > 0) { + completionHandler(ads[0],nil); + if (ads.count < cacheCount) { + [OMCrossPromotionClRequest requestCampaignWithPid:pid size:size actionType:action payload:payload completionHandler:^(NSDictionary * _Nullable campaignsData, NSError * _Nullable error) { + if (!error) { + NSArray *campaigns = [campaignsData objectForKey:@"campaigns"]; + if (campaigns && [campaigns isKindOfClass:[NSArray class]]) { + [self addCampaignsWithData:campaigns pid:pid]; + } + } + [self cacheCampaignMateriel:pid count:cacheCount]; + }]; + } else { + [self cacheCampaignMateriel:pid count:cacheCount]; + } + } else { + [OMCrossPromotionClRequest requestCampaignWithPid:pid size:size actionType:action payload:payload completionHandler:^(NSDictionary * _Nullable campaignsData, NSError * _Nullable error) { + if (!error) { + NSArray *campaigns = [campaignsData objectForKey:@"campaigns"]; + if (campaigns && [campaigns isKindOfClass:[NSArray class]]) { + [self addCampaignsWithData:campaigns pid:pid]; + } + OMCrossPromotionCampaign *ad = [self getCampaignWithPid:pid]; + if (ad) { + completionHandler(ad,nil); + [self cacheCampaignMateriel:pid count:cacheCount]; + } else { + completionHandler(nil,[[NSError alloc]initWithDomain:@"com.om.promotion" code:1001 userInfo: @{NSLocalizedDescriptionKey:@"no fill"}]); + } + } else { + completionHandler(nil,[[NSError alloc]initWithDomain:@"com.om.promotion" code:1000 userInfo: @{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"request error:%@",OM_SAFE_STRING([error description])]}]); + } + + }]; + } +} + +- (void)addCampaignsWithData:(NSArray*)campaignsData pid:(NSString*)pid { + if([campaignsData isKindOfClass:[NSArray class]] && [campaignsData count] > 0) { + NSMutableArray *loadAds = [NSMutableArray arrayWithArray:[_placmentAdsMap objectForKey:pid]]; + if(!loadAds) { + loadAds = [NSMutableArray array]; + } + for (NSDictionary *cData in campaignsData) { + OMCrossPromotionCampaign *c = [[OMCrossPromotionCampaign alloc]initWithCampaignData:cData pid:pid]; + [loadAds addObject:c]; + } + [_placmentAdsMap setObject:loadAds forKey:pid]; + } +} + +- (void)cacheCampaignMateriel:(NSString*)pid count:(NSInteger)count { + NSMutableArray *ads = [NSMutableArray array]; + if ([_placmentAdsMap objectForKey:pid]) { + ads = [NSMutableArray arrayWithArray:[_placmentAdsMap objectForKey:pid]]; + } + + if (count >1) { + for (int i=1; (i 0) { + c = ads[0]; + } + return c; +} + +- (void)passExpireAds:(NSMutableArray*)ads { + + NSMutableArray *expiredAds = [NSMutableArray array]; + for (int i=0; i< [ads count]; i++) { + OMCrossPromotionCampaign *c = ads[i]; + if(c.state >= OMCrossPromotionCampaignStateImpression || [c expire]) { + [expiredAds addObject:c]; + }else{ + break; + } + } + [ads removeObjectsInArray:expiredAds]; +} + +- (void)cleanAds:(NSString*)pid { + [_placmentAdsMap setObject:[NSArray array] forKey:pid]; +} + + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.h new file mode 100644 index 0000000..6dfa990 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.h @@ -0,0 +1,35 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionCampaignModel : NSObject + +@property (nonatomic, strong) NSDictionary *originData; +@property (nonatomic, strong) NSString *cid; //Campaign ID +@property (nonatomic, strong) NSString *crid; //Creative ID +@property (nonatomic, strong) NSString *title; //Title +@property (nonatomic, strong) NSArray *imgs; //Main image +@property (nonatomic, strong) NSDictionary *video; //Video Object +@property (nonatomic, assign) NSInteger adFormat; //Ad type +@property (nonatomic, strong) NSString *link; //click through url +@property (nonatomic, assign) BOOL iswv; //Open link with webview, 0:No,1:Yes +@property (nonatomic, strong) NSArray *clktks; //click track urls +@property (nonatomic, strong) NSArray *imptks; //impression track urls +@property (nonatomic, strong) NSDictionary *app; //App information +@property (nonatomic, strong) NSString *descn; //Description +@property (nonatomic, strong) NSArray *resources; //List of resources to be loaded +@property (nonatomic, strong) NSString *ps; +@property (nonatomic, strong) NSDictionary *adMark; //AdMark, no need to display admark if this field is empty +@property (nonatomic, assign) NSInteger expire; //campaign expire time in seconds +@property (nonatomic, assign) NSInteger rt; //Retargeting flag +@property (nonatomic, strong) NSDictionary *ska; //ios 14 SKAdNetwork + + +- (instancetype)initWithCampaignData:(NSDictionary*)cData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.m new file mode 100644 index 0000000..ecbb735 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionCampaignModel.m @@ -0,0 +1,70 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionCampaignModel.h" +#import "OMToolUmbrella.h" + +@implementation OMCrossPromotionCampaignModel + +- (instancetype)initWithCampaignData:(NSDictionary*)cData { + if (self = [super init]) { + if(cData) { + _cid = OM_SAFE_STRING(cData[@"cid"]); + _crid = OM_SAFE_STRING(cData[@"crid"]); + _title = OM_SAFE_STRING(cData[@"title"]); + _adFormat = (1<<[[cData objectForKey:@"adtype"]integerValue]); + _link = OM_SAFE_STRING(cData[@"link"]); + _iswv = [cData[@"iswv"]boolValue]; + _descn = OM_SAFE_STRING(cData[@"descn"]); + _ps = OM_SAFE_STRING(cData[@"ps"]); + _expire = [cData[@"expire"]integerValue]; + _rt = [cData[@"rt"]integerValue]; + + _imgs = [NSArray array]; + if (cData[@"imgs"] && [cData[@"imgs"] isKindOfClass:[NSArray class]]) { + _imgs = cData[@"imgs"]; + } + + _video = [NSDictionary dictionary]; + if (cData[@"video"] && [cData[@"video"] isKindOfClass:[NSDictionary class]]) { + _video = cData[@"video"]; + } + + _clktks = [NSArray array]; + if (cData[@"clktks"] && [cData[@"clktks"] isKindOfClass:[NSArray class]]) { + _clktks = cData[@"clktks"]; + } + + _imptks = [NSArray array]; + if (cData[@"imptks"] && [cData[@"imptks"] isKindOfClass:[NSArray class]]) { + _imptks = cData[@"imptks"]; + } + + _app = [NSDictionary dictionary]; + if (cData[@"app"] && [cData[@"app"] isKindOfClass:[NSDictionary class]]) { + _app = cData[@"app"]; + } + + _resources = [NSArray array]; + if(cData[@"resources"] && [cData[@"resources"] isKindOfClass:[NSArray class]]) { + _resources = cData[@"resources"]; + } + + _adMark = [NSDictionary dictionary]; + if (cData[@"mk"] && [cData[@"mk"] isKindOfClass:[NSDictionary class]]) { + _adMark = cData[@"mk"]; + } + + _ska = cData[@"ska"]; + if (_ska && [_ska objectForKey:@"adNetworkNonce"]) { + NSMutableDictionary * ska = [NSMutableDictionary dictionaryWithDictionary:_ska]; + [ska setObject:[[NSUUID alloc] initWithUUIDString:[_ska objectForKey:@"adNetworkNonce"]] forKey:@"adNetworkNonce"]; + _ska = [ska copy]; + } + _originData = cData; + } + } + return self; +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.h new file mode 100644 index 0000000..1a920d3 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.h @@ -0,0 +1,16 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import + +typedef void(^clCompletionHandler)(NSDictionary *_Nullable campaigns, NSError *_Nullable error); + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionClRequest : NSObject + ++ (void)requestCampaignWithPid:(NSString *)pid size:(CGSize)size actionType:(NSInteger)actionType payload:(nullable NSString*)payload completionHandler:(clCompletionHandler)completionHandler; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.m new file mode 100644 index 0000000..c49296d --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClRequest.m @@ -0,0 +1,53 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionClRequest.h" +#import "OMRequest.h" +#import "OMToolUmbrella.h" +#import "OMAudience.h" +#import "OMLoadFrequencryControl.h" +#import "OMCrossPromotionCampaignManager.h" +#import "OMConfig.h" + +@implementation OMCrossPromotionClRequest + ++ (void)requestCampaignWithPid:(NSString *)pid size:(CGSize)size actionType:(NSInteger)actionType payload:(NSString*)payload completionHandler:(clCompletionHandler)completionHandler { + if (OM_STR_EMPTY(pid)) { + OMLogD(@"adn cl p empty"); + return; + } + NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:[self clParametersWithPid:pid size:size actionType:actionType payload:payload]]; + NSError *jsonError; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&jsonError]; + if (!jsonError && jsonData) { + [OMRequest postWithUrl:[self requestUrl:([payload length]>0)] data:jsonData completionHandler:^(NSObject *object, NSError *error) { + if (!error) { + completionHandler((NSDictionary*)object,nil); + + } else { + completionHandler([NSDictionary dictionary],error); + } + }]; + } +} + ++ (NSString*)requestUrl:(BOOL)bidMode { + return [NSString stringWithFormat:@"%@?v=1&plat=0&sdkv=%@",(bidMode?[OMConfig sharedInstance].plUrl:[OMConfig sharedInstance].clUrl),OPENMEDIATION_SDK_VERSION]; +} + ++ (NSDictionary*)clParametersWithPid:(NSString*)pid size:(CGSize)size actionType:(NSInteger)actionType payload:(NSString*)payload { + NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:[OMRequest commonDeviceInfo]]; + parameters[@"width"] = [NSNumber numberWithInt:size.width]; + parameters[@"height"] = [NSNumber numberWithInt:size.height]; + parameters[@"pid"] = @([pid integerValue]); + if([payload length]>0) { //bidding payload + parameters[@"token"] = payload; + }else{ + parameters[@"iap"] = [NSNumber numberWithFloat:[OMAudience sharedInstance].purchaseAmount]; + parameters[@"imprTimes"] = [NSNumber numberWithInteger:[[OMLoadFrequencryControl sharedInstance]todayimprCountOnPlacment:pid]]; + parameters[@"act"] = [NSNumber numberWithInteger:actionType]; + + } + return [parameters copy]; +} +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.h new file mode 100644 index 0000000..3e743a4 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.h @@ -0,0 +1,38 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import +#import +#import "OMCrossPromotionWebController.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol OMClickHandlerDelegate + +@optional + +- (void)clickHandlerWillPresentScreen; +- (void)clickHandlerDisDismissScrren; +- (void)clickHandlerLeaveApplication; +@end + +@interface OMCrossPromotionClickHandler : NSObject + +@property (nonatomic, strong) NSString *appID; +@property (nonatomic, strong) NSString *campainID; +@property (nonatomic, strong) NSDictionary *ska; +@property (nonatomic, strong) NSString *adUrl; +@property (nonatomic, strong) WKWebView *webView; +@property (nonatomic, assign) BOOL storeLoadComplete; +@property (nonatomic, strong, nullable) SKStoreProductViewController *storeVC; +@property (nonatomic, weak) id delegate; + +- (instancetype)initWithAppID:(NSString*)appID ska:(NSDictionary*)skaParameter adURL:(NSString*)url; +- (void)clickAppAd:(UIViewController*)rootVC scene:(NSString*)sceneID; +- (void)clickWebAd:(UIViewController*)rootVC scene:(NSString*)sceneID; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.m new file mode 100644 index 0000000..f623979 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionClickHandler.m @@ -0,0 +1,175 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionClickHandler.h" +#import "OMToolUmbrella.h" +#import "OMConfig.h" +#import "OMEventManager.h" + +@implementation OMCrossPromotionClickHandler + +- (instancetype)initWithAppID:(NSString*)appID ska:(NSDictionary*)skaParameter adURL:(NSString*)url { + if (self = [super init]) { + _appID = appID; + _ska = skaParameter; + _adUrl = url; + if(!OM_STR_EMPTY(_appID)) { + NSMutableDictionary *productParameter = [NSMutableDictionary dictionary]; + productParameter[SKStoreProductParameterITunesItemIdentifier] = [NSNumber numberWithInteger:[_appID integerValue]]; + if (@available(iOS 14.0, *)) { + if(_ska) { + [productParameter addEntriesFromDictionary:_ska]; + } + } + [self.storeVC loadProductWithParameters:productParameter completionBlock:^(BOOL result, NSError * _Nullable error) { + if(result && !error) { + self.storeLoadComplete = YES; + } + }]; + } + + } + return self; +} + + + +- (void)clickAppAd:(UIViewController*)rootVC scene:(NSString*)sceneID { + + if(!(OM_STR_EMPTY(_adUrl))) { + if([_adUrl containsString:@"{scene}"]) { + _adUrl = [_adUrl stringByReplacingOccurrencesOfString:@"{scene}" withString:OM_SAFE_STRING(sceneID)]; + } + [rootVC.view addSubview:self.webView]; + [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_adUrl]]]; + } + + [rootVC presentViewController:self.storeVC animated:YES + completion:^{ + self.storeLoadComplete = NO; + }]; + if(_delegate && [_delegate respondsToSelector:@selector(clickHandlerWillPresentScreen)]) { + [_delegate clickHandlerWillPresentScreen]; + } +} + +- (void)clickWebAd:(UIViewController*)rootVC scene:(NSString*)sceneID { + if(!OM_STR_EMPTY(_adUrl)) { + OMCrossPromotionWebController *webVC = [[OMCrossPromotionWebController alloc]init]; + webVC.delegate = self; + if([_adUrl containsString:@"{scene}"]) { + _adUrl = [_adUrl stringByReplacingOccurrencesOfString:@"{scene}" withString:sceneID]; + } + webVC.url = _adUrl; + [rootVC presentViewController:[[UINavigationController alloc]initWithRootViewController:webVC] animated:YES completion:^{ + + }]; + if(_delegate && [_delegate respondsToSelector:@selector(clickHandlerWillPresentScreen)]) { + [_delegate clickHandlerWillPresentScreen]; + } + } +} + +- (WKWebView*)webView { + if(!_webView) { + WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]init]; + if (@available(iOS 13.0, *)) { + configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile; + } + _webView = [[WKWebView alloc]initWithFrame:CGRectZero configuration:configuration]; + _webView.UIDelegate = self; + _webView.navigationDelegate = self; + } + return _webView; +} + +- (SKStoreProductViewController*)storeVC { + if(!_storeVC) { + _storeVC = [[SKStoreProductViewController alloc]init]; + _storeVC.view.frame = [UIScreen mainScreen].bounds; + _storeVC.delegate = self; + } + return _storeVC; +} + +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + NSString *url = navigationAction.request.URL.absoluteString; + if([url containsString:@"itunes.apple.com"]) { + decisionHandler(WKNavigationActionPolicyCancel); + }else{ + decisionHandler(WKNavigationActionPolicyAllow); + } + +} + + +- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { + + decisionHandler(WKNavigationResponsePolicyAllow); +} + +- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *__nullable credential))completionHandler { + + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling ,nil); +} + + +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation { + +} + + +- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(null_unspecified WKNavigation *)navigation { + // 重定向时调用 +} + + +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { + [_webView removeFromSuperview]; +} + + +- (void)webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation { +} + + +- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation { + if(!_webView.isLoading) { + [_webView removeFromSuperview]; + } +} + + +- (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { + +} + + +- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView { +} + + +- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController { + __weak __typeof(self) weakSelf = self; + [_storeVC dismissViewControllerAnimated:YES completion:^{ + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(clickHandlerDisDismissScrren)]) { + [weakSelf.delegate clickHandlerDisDismissScrren]; + } + weakSelf.storeVC = nil; + if(weakSelf.appID) { + [weakSelf.storeVC loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:weakSelf.appID} completionBlock:^(BOOL result, NSError * _Nullable error) { + if(result && !error) { + weakSelf.storeLoadComplete = YES; + } + }]; + } + }]; +} + +- (void)webViewControllerDismiss { + if(self.delegate && [self.delegate respondsToSelector:@selector(clickHandlerDisDismissScrren)]) { + [self.delegate clickHandlerDisDismissScrren]; + } +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.h new file mode 100644 index 0000000..12dc018 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.h @@ -0,0 +1,27 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMCrossPromotionDownloader.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionDownloadManager : NSObject + +@property (nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (nonatomic, strong) NSURLSession *session; +@property (nonatomic, strong) dispatch_queue_t downloadQueue; +@property (nonatomic, strong) NSOperationQueue *operationQueue; +@property (nonatomic, strong) NSMutableArray *queuedTasks; +@property (nonatomic, strong) NSMutableArray *duplicateTasks; +@property (nonatomic, strong) NSMutableDictionary *activeTasks; + ++ (instancetype)sharedInstance; +-(void)downloadUrl:(NSString *)url extra:(NSDictionary*)extraValue completion:(downloadCompletionHandler)completion; +-(void)downloadUrl:(NSString *)url extra:(NSDictionary*)extraValue toPath:(NSString *)filePath completion:(downloadCompletionHandler)completion; +-(void)cancelDownloadTask:(NSString *)url; +-(void)cancelAllTasks; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.m new file mode 100644 index 0000000..84f7e3a --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloadManager.m @@ -0,0 +1,162 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionDownloadManager.h" +#import "OMToolUmbrella.h" + +#define kFGDwonloadMaxTaskCount 3 + +static OMCrossPromotionDownloadManager * _instance = nil; + +@implementation OMCrossPromotionDownloadManager + ++ (instancetype)sharedInstance { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] init]; + }); + return _instance; +} + + +-(instancetype)init { + if(self=[super init]) { + _activeTasks = [NSMutableDictionary dictionary]; + _queuedTasks = [NSMutableArray array]; + _duplicateTasks = [NSMutableArray array]; + self.operationQueue = [[NSOperationQueue alloc]init]; + self.operationQueue.maxConcurrentOperationCount = 1; + self.downloadQueue = dispatch_queue_create("com.om.download", DISPATCH_QUEUE_SERIAL); + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskDidFinishDownload:) name:OMCrossPromotionTaskFinishNotification object:nil]; + + } + return self; +} + +-(void)downloadUrl:(NSString *)url extra:(NSDictionary*)extraValue completion:(downloadCompletionHandler)completion { + NSString *urlCachePath = [NSString omUrlCachePath:url]; + [self downloadUrl:url extra:extraValue toPath:urlCachePath completion:completion]; +} + +-(void)downloadUrl:(NSString *)url extra:(NSDictionary*)extraValue toPath:(NSString *)filePath completion:(downloadCompletionHandler)completion { + if(!OM_STR_EMPTY(url) && !OM_STR_EMPTY(filePath) && completion) { + @synchronized (_queuedTasks) { + NSDictionary *dict=@{@"url":url, + @"filePath":filePath, + @"extra":extraValue, + @"completion":completion}; + [_queuedTasks addObject:dict]; + } + [self runQueuedTask]; + } + +} + +-(void)cancelDownloadTask:(NSString *)url { + if(!OM_STR_EMPTY(url)) { + OMCrossPromotionDownloader *downloader=[_activeTasks objectForKey:[url omMd5]]; + if(downloader) { + [downloader cancel]; + } + @synchronized (_activeTasks) { + [_activeTasks removeObjectForKey:[url omMd5]]; + } + [self runQueuedTask]; + } +} + +-(void)cancelAllTasks { + @synchronized(_activeTasks) { + NSMutableArray *keys = [NSMutableArray array]; + [_activeTasks enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { + OMCrossPromotionDownloader *downloader=obj; + [downloader cancel]; + [keys addObject:key]; + }]; + [_activeTasks removeObjectsForKeys:keys]; + } +} + +- (void)runQueuedTask { + if(_activeTasks.count < kFGDwonloadMaxTaskCount) { + @synchronized(_queuedTasks) { + if(_queuedTasks.count > 0) { + NSDictionary *task=[_queuedTasks objectAtIndex:0]; + NSString *url = task[@"url"]; + NSString *filePath = task[@"filePath"]; + downloadCompletionHandler completion = task[@"completion"]; + if([self activeTasksContainUrl:url]) { + @synchronized (_duplicateTasks) { + [_duplicateTasks addObject:task]; + } + }else{ + OMCrossPromotionDownloader *downloader=[OMCrossPromotionDownloader downloader]; + @synchronized (_activeTasks) { + [_activeTasks setObject:downloader forKey:[url omMd5]]; + } + __weak __typeof(self) weakSelf = self; + dispatch_async(_downloadQueue, ^{ + NSMutableDictionary *extra = [NSMutableDictionary dictionaryWithDictionary:task[@"extra"]]; + NSInteger nowTime = (NSInteger)([[NSDate date]timeIntervalSince1970]*1000.0); + [extra setObject:[NSNumber numberWithInteger:nowTime] forKey:@"startTime"]; + [downloader downloadUrl:url toPath:filePath extra:extra completion:completion delegateQueue:weakSelf.operationQueue]; + }); + } + [_queuedTasks removeObjectAtIndex:0]; + } + } + } +} + +- (BOOL)activeTasksContainUrl:(NSString*)url { + BOOL contain = NO; + @synchronized (_activeTasks) { + for (NSString *urlKey in _activeTasks) { + if([[url omMd5] isEqualToString:urlKey]) { + contain = YES; + } + } + } + return contain; +} + +-(void)downloadTaskDidFinishDownload:(NSNotification *)sender { + NSString *url=[sender.userInfo objectForKey:@"url"]; + NSError *error =[sender.userInfo objectForKey:@"error"]; + [self finishDownloadTask:url error:error]; +} + +- (void)finishDownloadTask:(NSString*)url error:(NSError*)error { + @synchronized (_activeTasks) { + NSString *urlKey = [url omMd5]; + OMCrossPromotionDownloader *finishTask = [_activeTasks objectForKey:urlKey]; + if(finishTask) { + NSString *finishTaskFilePath = finishTask.filePath; + @synchronized (_duplicateTasks) { + NSMutableArray *removeDuplicateTasks = [NSMutableArray array]; + for (NSDictionary *duplicateTask in _duplicateTasks) { + if([duplicateTask[@"url"] isEqualToString:url]) { + NSString *duplicateTaskFilePath = duplicateTask[@"filePath"]; + if(![duplicateTaskFilePath isEqualToString:finishTaskFilePath]) { + [[NSFileManager defaultManager]copyItemAtPath:finishTaskFilePath toPath:duplicateTaskFilePath error:nil]; + } + downloadCompletionHandler completion = duplicateTask[@"completion"]; + if(completion) { + completion(error); + } + [removeDuplicateTasks addObject:duplicateTask]; + } + } + [_duplicateTasks removeObjectsInArray:removeDuplicateTasks]; + } + [_activeTasks removeObjectForKey:urlKey]; + } + } + + [self runQueuedTask]; +} + +-(void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.h new file mode 100644 index 0000000..1cd0121 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.h @@ -0,0 +1,33 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +#define OM_DOWNLOAD_RESPONSE_NO_DATA -200 + +typedef void (^downloadCompletionHandler)(NSError *_Nullable error); +NS_ASSUME_NONNULL_BEGIN + +static NSString *const OMCrossPromotionTaskFinishNotification=@"OMCrossPromotionTaskFinishNotification"; + +@interface OMCrossPromotionDownloader : NSObject + +@property (nonatomic, strong) NSString *url; +@property (nonatomic, strong) NSString *filePath; +@property (nonatomic, copy) NSDictionary *extraValue; +@property (nonatomic, assign) NSInteger dataSize; +@property (nonatomic, strong) NSFileHandle *writeHandle; +@property (nonatomic,strong, nullable) NSURLSession *session; +@property (nonatomic,copy) downloadCompletionHandler completion; + ++ (instancetype)downloader; +-(void)downloadUrl:(NSString *)url + toPath:(NSString *)path + extra:(NSDictionary*)extraValue + completion:(downloadCompletionHandler)completion + delegateQueue:(NSOperationQueue *)delegateQueue; +- (void)cancel; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.m new file mode 100644 index 0000000..02b0af8 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionDownloader.m @@ -0,0 +1,198 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionDownloader.h" +#import "OMToolUmbrella.h" +#import "OMCrossPromotionCacheFile.h" +#import "OMErrorRequest.h" + +@implementation OMCrossPromotionDownloader + ++(instancetype)downloader { + return [[[self class] alloc]init]; +} + + +-(void)downloadUrl:(NSString *)url + toPath:(NSString *)path + extra:(NSDictionary*)extraValue + completion:(downloadCompletionHandler)completion + delegateQueue:(NSOperationQueue *)delegateQueue { + if(url && path) { + _url = url; + _filePath = path; + _extraValue = extraValue; + _dataSize = 0; + _completion=completion; + BOOL cacheFresh = [OMCrossPromotionCacheFile cacheFresh:_url]; + + if(cacheFresh) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:OMCrossPromotionTaskFinishNotification object:nil userInfo:@{@"url":self.url}]; + self.completion(nil); + }); + }else{ + NSURL *url=[NSURL URLWithString:_url]; + NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadRevalidatingCacheData timeoutInterval:30.0]; + if([NSString omUrlCacheReady:_url]) { + // add cache header key + NSDictionary *headers = [OMCrossPromotionCacheFile cacheHeader:_url]; + for (NSString *key in headers) { + [request setValue:[headers objectForKey:key] forHTTPHeaderField:key]; + } + }else{ + // tmpcache + NSInteger fileCurrentSize = 0; + NSFileManager *fileManager=[NSFileManager defaultManager]; + NSString *tmpFile = [NSString stringWithFormat:@"%@.tmp",_filePath]; + if([fileManager fileExistsAtPath:tmpFile]) { + fileCurrentSize = [[[fileManager attributesOfItemAtPath:tmpFile error:nil] objectForKey:NSFileSize] integerValue]; + if(fileCurrentSize > 0) { + NSString *rangeString=[NSString stringWithFormat:@"bytes=%lld-",(long long)fileCurrentSize]; + [request setValue:rangeString forHTTPHeaderField:@"Range"]; + _dataSize = fileCurrentSize; + } + } + + } + _session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:delegateQueue]; + NSURLSessionDataTask *downloadTask = [_session dataTaskWithRequest:request]; + [downloadTask resume]; + } + + + + } +} + +-(void)cancel { + [self.session invalidateAndCancel]; + self.session = nil; +} + +#pragma mark -- NSURLSessionDataDelegate +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest * _Nullable))completionHandler { + completionHandler(nil); +} + +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler { + NSInteger statusCode = 0; + if([response respondsToSelector:@selector(statusCode)]) { + statusCode = [(NSHTTPURLResponse*)response statusCode]; + } + + if(statusCode != 206) { + NSString *tmpFile = [NSString stringWithFormat:@"%@.tmp",_filePath]; + [[NSFileManager defaultManager]removeItemAtPath:tmpFile error:nil]; + _dataSize = 0; + } + + NSString *tmpFile = [NSString stringWithFormat:@"%@.tmp",_filePath]; + if(![[NSFileManager defaultManager] fileExistsAtPath:tmpFile]) { + [[NSFileManager defaultManager] createFileAtPath:tmpFile contents:nil attributes:nil]; + } + _writeHandle=[NSFileHandle fileHandleForWritingAtPath:tmpFile]; + NSMutableDictionary *cacheInfo = [NSMutableDictionary dictionary]; + NSMutableDictionary *responseHeader = [NSMutableDictionary dictionary]; + if(statusCode == 304) { + NSString *cacheInfoPath = [NSString omUrlCacheInfoPath:_url]; + if([[NSFileManager defaultManager]fileExistsAtPath:cacheInfoPath]) { + NSDictionary *cacheDic = [NSDictionary dictionaryWithContentsOfFile:cacheInfoPath]; + if([cacheDic objectForKey:@"responseHeader"]) { + responseHeader = [cacheDic objectForKey:@"responseHeader"]; + } + } + }else{ + if([response respondsToSelector:@selector(allHeaderFields)]) { + NSDictionary *header = [(NSHTTPURLResponse*)response allHeaderFields]; + [responseHeader addEntriesFromDictionary:header]; + } + [cacheInfo setObject:[NSString stringWithFormat:@"%zd",statusCode] forKey:@"code"]; + } + + + [cacheInfo setObject:responseHeader forKey:@"responseHeader"]; + [cacheInfo setObject:[NSString stringWithFormat:@"%lf",[[NSDate date]timeIntervalSince1970]] forKey:@"responseDate"]; + [cacheInfo setObject:response.URL.absoluteString forKey:@"baseUrl"]; + [cacheInfo writeToFile:[NSString omUrlCacheInfoPath:_url] atomically:YES]; + + completionHandler(NSURLSessionResponseAllow); + + +} + +- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data { + _dataSize += [data length]; + [_writeHandle seekToEndOfFile]; + @try { + [_writeHandle writeData:data]; + } @catch (NSException *exception) { + [_session invalidateAndCancel]; + } @finally { + + } + +} + +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task +didCompleteWithError:(nullable NSError *)error { + [_session finishTasksAndInvalidate]; + [_writeHandle closeFile]; + _writeHandle = nil; + NSInteger statusCode = 0; + NSString *cacheInfoPath = [NSString omUrlCacheInfoPath:_url]; + if([[NSFileManager defaultManager] fileExistsAtPath:cacheInfoPath]) { + NSDictionary *cacheInfo = [NSDictionary dictionaryWithContentsOfFile:cacheInfoPath]; + statusCode = [[cacheInfo objectForKey:@"code"]integerValue]; + } + if(!error && (statusCode == 200 || statusCode == 206 || statusCode == 416) ) { + NSString *fileSizeKey = [self.url omMd5]; + if(_dataSize == 0) { + _dataSize =OM_DOWNLOAD_RESPONSE_NO_DATA; + } + [[NSUserDefaults standardUserDefaults]setInteger:_dataSize forKey:fileSizeKey]; + NSString *tmpFile = [NSString stringWithFormat:@"%@.tmp",_filePath]; + [[NSFileManager defaultManager]removeItemAtPath:_filePath error:nil]; + [[NSFileManager defaultManager]moveItemAtPath:tmpFile toPath:_filePath error:nil]; + } + + NSMutableDictionary *info = [NSMutableDictionary dictionary]; + [info setObject:_url forKey:@"url"]; + if(error) { + [info setObject:error forKey:@"error"]; + } + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:OMCrossPromotionTaskFinishNotification object:nil userInfo:info]; + self.completion(error); + }); + + if(error || (statusCode != 200 && statusCode != 206)) { + NSError * responseError = error; + if(!responseError) { + responseError = [NSError errorWithDomain:NSURLErrorDomain code:statusCode userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"response status code: %zd",statusCode]}]; + } + NSDictionary *extra = self.extraValue; + if(extra) { + NSString *pid = OM_SAFE_STRING(extra[@"pid"]); + NSString *creativeId = OM_SAFE_STRING(extra[@"creativeId"]); + NSString *campaignId = OM_SAFE_STRING(extra[@"campaignId"]); + NSInteger startTime = [extra[@"downloadTime"]integerValue]; + NSInteger nowTime = (NSInteger)([[NSDate date]timeIntervalSince1970]*1000.0); + NSString *error = [NSString stringWithFormat:@"Download %@ error:%@ ,cost time %ld creative id %@,campaign id %@",_url,[responseError description],(nowTime - startTime),creativeId,campaignId]; + + [OMErrorRequest postWithErrorMsg:@{@"pid":pid,@"tag":@"downlaoder",@"error":error} completionHandler:^(NSObject * _Nullable object, NSError * _Nullable error) { + if(!error) { + OMLogD(@"post download error: %@,%@",self.url,[responseError description]); + } + }]; + } + } + +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.h new file mode 100644 index 0000000..04e99ae --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.h @@ -0,0 +1,16 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionExposureMonitor : NSObject +@property (nonatomic, strong) NSMapTable *monitoredViewMap;//key observer ,value view ++ (instancetype)sharedInstance; +- (void)addObserver:(NSObject*)observer forView:(UIView*)view; +- (void)removeObserver:(NSObject*)observer; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.m new file mode 100644 index 0000000..d2b86c6 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionExposureMonitor.m @@ -0,0 +1,115 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionExposureMonitor.h" + +@interface OMCrossPromotionViewObserver : NSObject +- (void)observeView:(UIView*)view visible:(BOOL)visible; +@end + +@interface OMCrossPromotionExposureMonitor() { + CFRunLoopObserverRef _observer; +} +@end + +static OMCrossPromotionExposureMonitor * _instance = nil; + +@implementation OMCrossPromotionExposureMonitor + ++ (instancetype)sharedInstance { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] init]; + }); + return _instance; +} + + +-(instancetype)init { + if(self=[super init]) { + _monitoredViewMap = [NSMapTable weakToWeakObjectsMapTable]; + [self addObserverForMainRunloop]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addObserverForMainRunloop) name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeObserverForMainRunloop) name:UIApplicationWillResignActiveNotification object:nil]; + } + return self; +} + +- (void)addObserverForMainRunloop { + if (_observer || [UIApplication sharedApplication].applicationState != UIApplicationStateActive) { + return; + } + __weak __typeof(self) weakSelf = self; + _observer = CFRunLoopObserverCreateWithHandler(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, YES, 0, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) { + if (weakSelf && activity == kCFRunLoopBeforeWaiting) { + [weakSelf checkMonitoredViews]; + } + }); + CFRunLoopAddObserver([NSRunLoop mainRunLoop].getCFRunLoop, _observer, kCFRunLoopCommonModes); +} + +- (void)removeObserverForMainRunloop { + if (_observer) { + CFRunLoopRemoveObserver([NSRunLoop mainRunLoop].getCFRunLoop, _observer, kCFRunLoopCommonModes); + } + _observer = nil; +} + +- (void)checkMonitoredViews { + + NSEnumerator *enumerator = [_monitoredViewMap keyEnumerator]; + OMCrossPromotionViewObserver *observer; + + while ((observer = [enumerator nextObject])) { + if(observer && [observer respondsToSelector:@selector(observeView:visible:)] && [_monitoredViewMap objectForKey:observer]) { + UIView *monitorView = [_monitoredViewMap objectForKey:observer]; + [observer observeView:monitorView visible:[self visible:monitorView]]; + } + } +} + +- (BOOL)visible:(UIView*)view { + UIWindow *window = view.window; + BOOL isHidden = view.isHidden; + UIView*superView =view.superview; + BOOL superViewHidden = NO; + while(!superViewHidden && superView) { + superViewHidden = superView.isHidden; + superView = superView.superview; + } + if(superViewHidden) { + isHidden = YES; + } + CGFloat alpha = view.alpha; + superView =view.superview; + while(superView) { + if(superView.alpha < alpha) { + alpha = superView.alpha; + } + superView = superView.superview; + } + if (!window || isHidden || alpha < 0.05) { + return NO; + } + CGRect frame = view.frame; + CGRect rectInWindow = CGRectIntegral([view.superview convertRect:frame toView:window]); + CGRect intersectionRect = CGRectIntersection(rectInWindow, window.frame); + if (CGRectIsNull(intersectionRect) || CGRectIsEmpty(intersectionRect)|| (intersectionRect.size.width*intersectionRect.size.height < 10)) { + return NO; + } + return YES; +} + +- (void)addObserver:(NSObject*)observer forView:(UIView*)view { + @synchronized (_monitoredViewMap) { + [_monitoredViewMap setObject:view forKey:observer]; + } +} + +- (void)removeObserver:(NSObject*)observer { + @synchronized (_monitoredViewMap) { + [_monitoredViewMap removeObjectForKey:observer]; + } +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.h new file mode 100644 index 0000000..5398829 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.h @@ -0,0 +1,29 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +#define CROSSPROMOTION_MIN_CACHE_MAXAGE (60*60) +#define CROSSPROMOTION_MAX_CACHE_MAXAGE (60*60*24) + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, OMCrossPromotionHTTPCacheControlType) { + OMCrossPromotionHTTPCacheControlTypeMustRevalidate = 0, + OMCrossPromotionHTTPCacheControlTypeNoCache = 1, + OMCrossPromotionHTTPCacheControlTypeNoStore = 2, +}; + +@interface OMCrossPromotionHTTPCacheControl : NSObject ++ (NSDictionary*)urlCacheInfo:(NSString*)url; ++ (NSDictionary*)urlResponseHeader:(NSString*)url; ++ (OMCrossPromotionHTTPCacheControlType)cacheType:(NSString*)url; ++ (NSTimeInterval)cacheExpireTime:(NSString*)url; ++ (BOOL)cacheExpire:(NSString*)url; ++ (NSString*)eTag:(NSString*)url; ++ (NSString*)lastModified:(NSString*)url; ++ (NSDictionary*)cacheHeaders:(NSString*)url; ++ (NSInteger)responseCode:(NSString*)url; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.m new file mode 100644 index 0000000..7e23e07 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionHTTPCacheControl.m @@ -0,0 +1,174 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionHTTPCacheControl.h" +#import "OMToolUmbrella.h" +@implementation OMCrossPromotionHTTPCacheControl + ++ (NSDictionary*)urlCacheInfo:(NSString*)url { + NSDictionary *info = [NSDictionary dictionary]; + if(!OM_STR_EMPTY(url) && [NSURL URLWithString:url]) { + NSString *cacheInfoPath = [NSString omUrlCacheInfoPath:url]; + if(cacheInfoPath && [[NSFileManager defaultManager]fileExistsAtPath:cacheInfoPath]) { + NSDictionary *cacheInfo = [NSDictionary dictionaryWithContentsOfFile:cacheInfoPath]; + if(cacheInfo && [cacheInfo isKindOfClass:[NSDictionary class]]) { + info = cacheInfo; + } + } + } + return info; +} + ++ (NSDictionary*)urlResponseHeader:(NSString*)url { + NSDictionary *responseHeader = [NSDictionary dictionary]; + if(!OM_STR_EMPTY(url) && [NSURL URLWithString:url]) { + NSString *cacheInfoPath = [NSString omUrlCacheInfoPath:url]; + if(cacheInfoPath && [[NSFileManager defaultManager]fileExistsAtPath:cacheInfoPath]) { + NSDictionary *cacheInfo = [NSDictionary dictionaryWithContentsOfFile:cacheInfoPath]; + if(cacheInfo && [cacheInfo isKindOfClass:[NSDictionary class]] && [cacheInfo objectForKey:@"responseHeader"]) { + responseHeader = [cacheInfo objectForKey:@"responseHeader"]; + } + } + } + return responseHeader; +} + ++ (OMCrossPromotionHTTPCacheControlType)cacheType:(NSString*)url { + OMCrossPromotionHTTPCacheControlType cacheType = OMCrossPromotionHTTPCacheControlTypeMustRevalidate; +// NSDictionary *cacheInfo = [self urlResponseHeader:url]; +// NSString *cacheControl = [cacheInfo objectForKey:@"Cache-Control"]; +// if(!OM_STR_EMPTY(cacheControl)) { +// NSArray *directives = [cacheControl componentsSeparatedByString:@","]; +// for (NSString *directive in directives) { +// if([directive isEqualToString:@"no-store"]) { +// cacheType = OMCrossPromotionHTTPCacheControlTypeNoStore; +// }else if([directive isEqualToString:@"no-cache"]) { +// cacheType = OMCrossPromotionHTTPCacheControlTypeNoStore; +// }else if([directive isEqualToString:@"must-revalidation"]) { +// cacheType = OMCrossPromotionHTTPCacheControlTypeMustRevalidate; +// } +// +// } +// } + cacheType = OMCrossPromotionHTTPCacheControlTypeMustRevalidate; + return cacheType; +} + ++ (NSTimeInterval)cacheExpireTime:(NSString*)url { + NSInteger maxAge = 0; + NSTimeInterval expire = 0; + NSDictionary *cacheInfo = [self urlCacheInfo:url]; + if([cacheInfo objectForKey:@"FileExpireTime"]) { + expire = [[cacheInfo objectForKey:@"FileExpireTime"]doubleValue]; + }else{ + NSDictionary *responseHeader = [self urlResponseHeader:url]; + NSString *cacheControl = [responseHeader objectForKey:@"Cache-Control"]; + if(!OM_STR_EMPTY(cacheControl) && [cacheControl containsString:@"max-age"] ) { + NSArray *directives = [cacheControl componentsSeparatedByString:@","]; + for (NSString *directive in directives) { + if([directive containsString:@"max-age"]) { + NSArray *maxAgeGroup = [directive componentsSeparatedByString:@"="]; + if(maxAgeGroup.count == 2) { + maxAge = [[maxAgeGroup lastObject]integerValue]; + } + } + + } + } + + NSString *dateStr = [responseHeader objectForKey:@"Date"]; + if(!OM_STR_EMPTY(dateStr) && maxAge > 0) { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + dateFormatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss z"; + dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; + NSDate *date = [dateFormatter dateFromString:dateStr]; + expire = [date timeIntervalSince1970] + maxAge; + }else{ + NSString *dateStr = [responseHeader objectForKey:@"Expires"]; + if(!OM_STR_EMPTY(dateStr)) { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + dateFormatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss z"; + dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; + NSDate *date = [dateFormatter dateFromString:dateStr]; + expire = [date timeIntervalSince1970]; + } + } + + NSTimeInterval responseTime = [[cacheInfo objectForKey:@"responseDate"]doubleValue]; + NSTimeInterval minExpire = responseTime + CROSSPROMOTION_MIN_CACHE_MAXAGE; + NSTimeInterval maxExpire = responseTime + CROSSPROMOTION_MAX_CACHE_MAXAGE; + if(expire < minExpire) { + expire = minExpire; + } + if(expire > maxExpire) { + expire = maxExpire; + } + NSMutableDictionary *cacheInfoContainExpire = [NSMutableDictionary dictionaryWithDictionary:cacheInfo]; + [cacheInfoContainExpire setObject:[NSString stringWithFormat:@"%lf",expire] forKey:@"FileExpireTime"]; + [cacheInfoContainExpire writeToFile:[NSString omUrlCacheInfoPath:url] atomically:YES]; + } + + + + return expire; +} + ++ (BOOL)cacheExpire:(NSString*)url { + if(OM_STR_EMPTY(url) || ![NSURL URLWithString:url] || (![url hasPrefix:@"http"] && ![url hasPrefix:@"https"])) { + return NO; + } + OMCrossPromotionHTTPCacheControlType cacheType = [self cacheType:url]; + NSTimeInterval expireTime = [self cacheExpireTime:url]; + switch (cacheType) { + case OMCrossPromotionHTTPCacheControlTypeMustRevalidate: + return ([[NSDate date]timeIntervalSince1970] >= expireTime); + break; + case OMCrossPromotionHTTPCacheControlTypeNoCache: + return YES; + break; + case OMCrossPromotionHTTPCacheControlTypeNoStore: + return YES; + break; + default: + break; + } + +} + ++ (NSString*)eTag:(NSString*)url { + NSDictionary *responseHeader = [self urlResponseHeader:url]; + return OM_SAFE_STRING([responseHeader objectForKey:@"Etag"]); +} + ++ (NSString*)lastModified:(NSString*)url { + NSDictionary *responseHeader = [self urlResponseHeader:url]; + return OM_SAFE_STRING([responseHeader objectForKey:@"Last-Modified"]); +} + ++ (NSDictionary*)cacheHeaders:(NSString*)url { + NSMutableDictionary *cacheHeader = [NSMutableDictionary dictionary]; + OMCrossPromotionHTTPCacheControlType cacheType = [self cacheType:url]; + if ((cacheType == OMCrossPromotionHTTPCacheControlTypeMustRevalidate && [self cacheExpire:url]) || cacheType == OMCrossPromotionHTTPCacheControlTypeNoCache) { + NSString *etag = [self eTag:url]; + NSString *lastModified = [self lastModified:url]; + if(!OM_STR_EMPTY(etag)) { + [cacheHeader setObject:etag forKey:@"If-None-Match"]; + } + if (!OM_STR_EMPTY(lastModified)) { + [cacheHeader setObject:lastModified forKey:@"If-Modified-Since"]; + } + } + + return [cacheHeader copy]; +} + ++ (NSInteger)responseCode:(NSString*)url { + NSInteger statusCode = 0; + NSDictionary *cacheInfo = [self urlCacheInfo:url]; + NSInteger code = [[cacheInfo objectForKey:@"code"]integerValue]; + if(code > 0) { + statusCode = code; + } + return statusCode; +} +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.h new file mode 100644 index 0000000..ea0cd37 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.h @@ -0,0 +1,54 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import "OMCrossPromotionCampaign.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, OMCrossPromotionJSEvent) { + OMCrossPromotionJSEventInit = 0 , + OMCrossPromotionJSEventShow, + OMCrossPromotionJSEventPause, + OMCrossPromotionJSEventResume, + OMCrossPromotionJSEventMuted, + OMCrossPromotionJSEventUnmute, +}; + +@protocol OMCrossPromotionJSBridgeDelegate + +@optional + +- (void)jsBridgePushEvent:(NSString*)eventBody; + +- (void)jsBridgeSetCloseVisible:(BOOL)visible; + +- (void)jsBridgeClose; + +- (void)jsBridgeClick:(BOOL)trackClick; + +- (void)jsBridgWillOpenBrowser; + +- (void)jsBridgeVideoPlayProgress:(NSInteger)percentage; + +- (void)jsBridgeAddRewarded; + +- (void)jsBridgeRefreshAd:(NSInteger)millisecond; + +@end + +@interface OMCrossPromotionJSBridge : NSObject + +@property (nonatomic, copy) NSArray *eventNames; +@property (nonatomic, weak) WKWebView *bindWebView; +@property (nonatomic, strong) NSString *placementID; +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; +@property (nonatomic, strong) id jsMessageHandler; + +- (instancetype)initWithBindWebView:(WKWebView*)bindWebView placementID:(NSString*)placementID; + +- (void)sendEvent:(OMCrossPromotionJSEvent)event; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.m new file mode 100644 index 0000000..e6b395d --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionJSBridge.m @@ -0,0 +1,193 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionJSBridge.h" +#import "OMConfig.h" +#import "OMRequest.h" + +@implementation OMCrossPromotionJSBridge + +- (instancetype)initWithBindWebView:(WKWebView*)bindWebView placementID:(NSString*)placementID { + if (self = [super init]) { + self.eventNames = @[@"wv.init",@"wv.show",@"wv.pause",@"wv.resume",@"wv.muted",@"wv.unmute"]; + self.bindWebView = bindWebView; + [bindWebView.configuration.userContentController addScriptMessageHandler:self name:@"sdk"]; + self.placementID = placementID; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil]; + } + return self; +} + +- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { + + if ([message.name isEqualToString:@"sdk"]) { + NSString *bodyStr = message.body; + NSDictionary *body = [NSDictionary dictionary]; + if (!OM_STR_EMPTY(bodyStr)) { + NSData *data = [bodyStr dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if (!jsonErr && dict) { + body = [dict copy]; + } + } + NSString *msg = @""; + NSDictionary *parm = [NSDictionary dictionary]; + if([body isKindOfClass:[NSDictionary class]]) { + msg = body[@"m"]; + if ([body objectForKey:@"d"]) { + parm = body[@"d"]; + } + } + + if ([msg isEqual:@"jsLoaded"]) { + [self sendEvent:OMCrossPromotionJSEventInit]; + + } else if ([msg isEqualToString:@"pushEvent"]) { + NSString *p = parm[@"e"]; + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgePushEvent:)]) { + [self.jsMessageHandler jsBridgePushEvent:p]; + } + } else if ([msg isEqualToString:@"setCloseVisible"]) { + NSNumber *p = parm[@"visible"]; + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeSetCloseVisible:)]) { + [self.jsMessageHandler jsBridgeSetCloseVisible:[p boolValue]]; + } + } else if ([msg isEqualToString:@"close"]) { + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeClose)]) { + [self.jsMessageHandler jsBridgeClose]; + } + } else if ([msg isEqualToString:@"click"]) { + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeClick:)]) { + [self.jsMessageHandler jsBridgeClick:YES]; + } + } else if ([msg isEqualToString:@"wvclick"]) { + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeClick:)]) { + [self.jsMessageHandler jsBridgeClick:NO]; + } + } else if ([msg isEqualToString:@"openBrowser"]) { + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgWillOpenBrowser)]) { + [self.jsMessageHandler jsBridgWillOpenBrowser]; + } + NSString *p = parm[@"url"]; + if (!OM_STR_EMPTY(p)) { + NSURL *url = [NSURL URLWithString:p]; + [[UIApplication sharedApplication]openURL:url]; + } + } else if ([msg isEqualToString:@"reportVideoProgress"]) { + NSNumber *p = parm[@"progress"]; + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeVideoPlayProgress:)]) { + [self.jsMessageHandler jsBridgeVideoPlayProgress:[p integerValue]]; + } + } else if ([msg isEqualToString:@"addRewarded"]) { + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeAddRewarded)]) { + [self.jsMessageHandler jsBridgeAddRewarded]; + } + } else if ([msg isEqualToString:@"refreshAd"]) { + NSNumber *p = parm[@"delay"]; + if(self.jsMessageHandler && [self.jsMessageHandler respondsToSelector:@selector(jsBridgeRefreshAd:)]) { + [self.jsMessageHandler jsBridgeRefreshAd:[p integerValue]]; + } + } + } +} + + +- (void)sendEvent:(OMCrossPromotionJSEvent)event { + + if (self.bindWebView) { + NSMutableDictionary *eventData = [NSMutableDictionary dictionary]; + + if (event < self.eventNames.count) { + [eventData setObject:self.eventNames[event] forKey:@"type"]; + } + + if (event == OMCrossPromotionJSEventInit) { + + NSMutableDictionary *base = [NSMutableDictionary dictionaryWithDictionary:[OMRequest commonDeviceInfo]]; + [base setObject:[OMConfig sharedInstance].appKey forKey:@"appk"]; + [base setObject:OPENMEDIATION_SDK_VERSION forKey:@"sdkv"]; + BOOL abTest = [[NSUserDefaults standardUserDefaults]boolForKey:[NSString stringWithFormat:@"%@_abt",self.placementID]]; + [base setObject:[NSNumber numberWithInteger:(abTest?1:0)] forKey:@"abt"]; + + [eventData setObject:base forKey:@"bfs"]; + + OMUnit *unit = [[OMConfig sharedInstance].adUnitMap objectForKey:self.placementID]; + if (unit) { + [eventData setObject:unit.unitModel forKey:@"placement"]; + NSString *sceneID = [[NSUserDefaults standardUserDefaults]stringForKey:[NSString stringWithFormat:@"%@_scene",self.placementID]]; + OMScene *scene = [unit getSceneById:sceneID]; + if (scene) { + [eventData setObject:@{@"id":[NSNumber numberWithInteger:[scene.sceneID integerValue]],@"name":scene.sceneName} forKey:@"scene"]; + } + } + + if (self.campaign) { + + NSMutableDictionary *campaignData = [NSMutableDictionary dictionaryWithDictionary:[self.campaign originData]]; + if (self.campaign.model.app[@"icon"]) { + + NSMutableDictionary *app = [NSMutableDictionary dictionaryWithDictionary:[campaignData objectForKey:@"app"]]; + [app setObject:[NSURL fileURLWithPath:[self.campaign iconCachePath]].absoluteString forKey:@"icon"]; + [campaignData setObject:app forKey:@"app"]; + } + + NSMutableArray *imgs = [NSMutableArray array]; + for (NSString *img in self.campaign.model.imgs) { + [imgs addObject:[NSString omUrlCachePath:img]]; + } + [campaignData setObject:[imgs copy] forKey:@"imgs"]; + + if (self.campaign.model.video[@"url"]) { + NSMutableDictionary *app = [NSMutableDictionary dictionaryWithDictionary:[campaignData objectForKey:@"video"]]; + [app setObject:[NSURL fileURLWithPath:[self.campaign videoCachePath]].absoluteString forKey:@"url"]; + [campaignData setObject:app forKey:@"video"]; + } + if (self.campaign.model.resources.count >0) { + NSMutableArray *resourceLocalPaths = [NSMutableArray array]; + for (NSString *resource in self.campaign.model.resources) { + [resourceLocalPaths addObject:[NSString omUrlCachePath:resource]]; + } + [campaignData setObject:resourceLocalPaths forKey:@"resources"]; + } + + [eventData setObject:campaignData forKey:@"campaign"]; + } + } + + NSString *eventMsg = [self obj2JsonStr:eventData]; + + NSString *criptJS = [NSString stringWithFormat:@"window.postMessage(%@, '*')",eventMsg]; + + [self.bindWebView evaluateJavaScript:criptJS completionHandler:nil]; + } + +} + +- (void)handleApplicationDidBecomeActive { + [self sendEvent:OMCrossPromotionJSEventResume]; +} + +- (void)handleApplicationWillResignActive { + [self sendEvent:OMCrossPromotionJSEventPause]; +} + +- (NSString*)obj2JsonStr:(NSObject*)object { + NSString *jsonStr = @"{}"; + if(object && ([object isKindOfClass:[NSDictionary class]] || [object isKindOfClass:[NSArray class]])) { + NSError *error = nil; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object options:0 error:&error]; + if(!error && jsonData) { + jsonStr = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding]; + } + } + return jsonStr; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter]removeObserver:self name:UIApplicationDidBecomeActiveNotification object:self]; + [[NSNotificationCenter defaultCenter]removeObserver:self name:UIApplicationWillResignActiveNotification object:self]; +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.h new file mode 100644 index 0000000..313ff68 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.h @@ -0,0 +1,21 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMCrossPromotionNativeAd.h" +#import "OMNativeCustomEvent.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionNative : NSObject + +@property (nonatomic, copy) NSString *pid; +@property (nonatomic, weak) UIViewController *rootVC; +@property (nonatomic, weak) id delegate; + +- (instancetype)initWithParameter:(NSDictionary*)adParameter rootVC:(UIViewController*)rootViewController; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.m new file mode 100644 index 0000000..207911d --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNative.m @@ -0,0 +1,86 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionNative.h" +#import "OpenMediationConstant.h" +#import "OMCrossPromotionCampaignManager.h" + +@interface OMNativeAd : NSObject +@property (nonatomic, copy) NSString *title; +@property (nonatomic, copy) NSString *body; +@property (nonatomic, copy) NSString *iconUrl; +@property (nonatomic, copy) NSString *callToAction; +@property (nonatomic, assign) double rating; +- (instancetype)initWithPlatform:(OMAdNetwork)adnID didLoadAd:(id)ad; +@end + +@implementation OMCrossPromotionNative + +- (instancetype)initWithParameter:(NSDictionary*)adParameter rootVC:(UIViewController*)rootViewController { + if (self = [super init]) { + if(adParameter && [adParameter isKindOfClass:[NSDictionary class]]) { + _pid = [adParameter objectForKey:@"pid"]; + } + _rootVC = rootViewController; + } + return self; +} + +- (void)loadAdWithBidPayload:(NSString*)bidPayload { + NSString *payload = @""; + if ([bidPayload length]>0) { + NSData *data = [bidPayload dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *admBody = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if([admBody isKindOfClass:[NSDictionary class]]) { + payload = admBody[@"payload"]; + } + } + if (![payload length]) { + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + NSError *error = [[NSError alloc]initWithDomain:@"com.crosspromotion.ads" code:501 userInfo: @{NSLocalizedDescriptionKey:@"Invalid bid payload"}]; + [_delegate customEvent:self didFailToLoadWithError:error]; + } + return; + } + + __weak __typeof(self) weakSelf = self; + [[OMCrossPromotionCampaignManager sharedInstance] loadAdWithPid:_pid size:CGSizeMake(1200, 627) action:4 payload:payload completionHandler:^(OMCrossPromotionCampaign *campaign, NSError *error) { + if(!error) { + [campaign cacheMaterielCompletion:^{ + if(weakSelf) { + OMCrossPromotionNativeAd* nativeAd = [[OMCrossPromotionNativeAd alloc]initWithCampaign:campaign]; + nativeAd.adDelegate = weakSelf; + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [weakSelf.delegate customEvent:weakSelf didLoadAd:nativeAd]; + } + } + }]; + + }else{ + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [weakSelf.delegate customEvent:self didFailToLoadWithError:error]; + } + } + }]; +} + + +#pragma mark -- OMCrossPromotionNativeAdDelegate +- (void)OMCrossPromotionNativeAdWillShow:(OMCrossPromotionNativeAd*)natvieAd { + [natvieAd.campaign impression:@""]; + if (_delegate && [_delegate respondsToSelector:@selector(nativeCustomEventWillShow:)]) { + [_delegate nativeCustomEventWillShow:self]; + } +} + +- (void)OMCrossPromotionNativeAdDidClick:(OMCrossPromotionNativeAd*)natvieAd{ + [natvieAd showAd:_rootVC]; + if (_delegate && [_delegate respondsToSelector:@selector(nativeCustomEventDidClick:)]) { + [_delegate nativeCustomEventDidClick:self]; + } +} + + + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.h new file mode 100644 index 0000000..72ec5a9 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.h @@ -0,0 +1,35 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMCrossPromotionCampaignManager.h" +#import "OMNativeCustomEvent.h" +#import "OMMediatedNativeAd.h" +@class OMCrossPromotionNativeAd; + +NS_ASSUME_NONNULL_BEGIN + + +@protocol OMCrossPromotionNativeAdDelegate + +- (void)OMCrossPromotionNativeAdWillShow:(OMCrossPromotionNativeAd*)nativeAd; +- (void)OMCrossPromotionNativeAdDidClick:(OMCrossPromotionNativeAd*)nativeAd; + +@end + +@interface OMCrossPromotionNativeAd : NSObject + +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; +@property (nonatomic, strong) id adDelegate; +@property (nonatomic, copy) NSString *title; +@property (nonatomic, copy) NSString *body; +@property (nonatomic, copy) NSString *iconUrl; +@property (nonatomic, copy) NSString *callToAction; +@property (nonatomic, assign) double rating; +@property (nonatomic, copy) NSString *nativeViewClass; +@property (nonatomic, assign) BOOL impr; +- (instancetype)initWithCampaign:(OMCrossPromotionCampaign *)campaign; +- (void)showAd:(UIViewController*)rootViewController; +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.m new file mode 100644 index 0000000..9adf665 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeAd.m @@ -0,0 +1,26 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionNativeAd.h" +#import "OMToolUmbrella.h" + +@implementation OMCrossPromotionNativeAd + +- (instancetype)initWithCampaign:(OMCrossPromotionCampaign *)campaign { + if (self = [super init]) { + _campaign = campaign; + _title = OM_SAFE_STRING(campaign.model.app[@"title"]); + _body = campaign.model.descn; + _iconUrl = OM_SAFE_STRING(campaign.model.app[@"icon"]); + _callToAction = @"INSTALL"; + _rating = [campaign.model.app[@"rating"] floatValue]; + _nativeViewClass = @"OMCrossPromotionNativeView"; + } + return self; +} + +- (void)showAd:(UIViewController*)rootViewController { + [_campaign clickAndShowAd:rootViewController sceneID:@""]; +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.h new file mode 100644 index 0000000..f34f013 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.h @@ -0,0 +1,15 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "OMCrossPromotionNativeAd.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionNativeMediaView : UIView +@property (nonatomic, strong) OMCrossPromotionNativeAd *nativeAd; +@property (nonatomic, strong) UIImageView *imgView; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.m new file mode 100644 index 0000000..ac629d4 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeMediaView.m @@ -0,0 +1,30 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionNativeMediaView.h" +#import "OMToolUmbrella.h" + +@implementation OMCrossPromotionNativeMediaView + +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; + [self addSubview:self.imgView]; + [_imgView addConstraintEqualSuperView]; + UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click)]; + [self addGestureRecognizer:gesture]; + } + return self; +} + +- (void)setNativeAd:(OMCrossPromotionNativeAd *)nativeAd { + _nativeAd = nativeAd; + _imgView.image = [UIImage imageWithData:[NSData dataWithContentsOfFile:[nativeAd.campaign mainImgCachePath]]]; +} + +- (void)click { + if(_nativeAd && _nativeAd.adDelegate && [_nativeAd.adDelegate respondsToSelector:@selector(OMCrossPromotionNativeAdDidClick:)]) { + [_nativeAd.adDelegate OMCrossPromotionNativeAdDidClick:_nativeAd]; + } +} +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.h new file mode 100644 index 0000000..6973889 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.h @@ -0,0 +1,24 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import "OMCrossPromotionNative.h" +#import "OMCrossPromotionNativeView.h" +#import "OMCrossPromotionNativeMediaView.h" +#import "OMCrossPromotionNativeAd.h" +#import "OMNativeViewCustomEvent.h" +#import "OMCrossPromotionCampaignManager.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionNativeView : UIView + +@property (nonatomic, strong) OMCrossPromotionNativeAd *nativeAd; +@property (nonatomic, strong) OMCrossPromotionNativeMediaView *mediaView; +@property (nonatomic, strong) UIImageView *adChoicesView; +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.m new file mode 100644 index 0000000..8abbe3e --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionNativeView.m @@ -0,0 +1,118 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionNativeView.h" +#import "OMCrossPromotionExposureMonitor.h" + +@implementation OMCrossPromotionNativeView + +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + self.clipsToBounds = YES; + self.backgroundColor = [UIColor clearColor]; + UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click)]; + [self addGestureRecognizer:gesture]; + + } + return self; +} + +- (void)setNativeAd:(OMCrossPromotionNativeAd *)nativeAd { + _nativeAd = nativeAd; + _campaign = _nativeAd.campaign; + if(_mediaView) { + _mediaView.nativeAd = _nativeAd; + } + [self addAdChoicesView]; + self.adChoicesView.image = [_campaign logoImage]; +} + +- (void)drawRect:(CGRect)rect { + [[OMCrossPromotionExposureMonitor sharedInstance]addObserver:self forView:self]; + [super drawRect:rect]; +} + +- (void)removeFromSuperview { + [super removeFromSuperview]; + [[OMCrossPromotionExposureMonitor sharedInstance]removeObserver:self]; +} + +- (void)observeView:(UIView*)view visible:(BOOL)visible { + if(visible) { + if(!_nativeAd.impr) { + _nativeAd.impr =YES; + [self recordImpr]; + } + } +} + +- (void)recordImpr { + if(_nativeAd && _nativeAd.adDelegate && [_nativeAd.adDelegate respondsToSelector:@selector(OMCrossPromotionNativeAdWillShow:)]) { + [_nativeAd.adDelegate OMCrossPromotionNativeAdWillShow:_nativeAd]; + } +} + +- (void)click { + if(_nativeAd && _nativeAd.adDelegate && [_nativeAd.adDelegate respondsToSelector:@selector(OMCrossPromotionNativeAdDidClick:)]) { + [_nativeAd.adDelegate OMCrossPromotionNativeAdDidClick:_nativeAd]; + } +} + +- (void)adIconClick { + [self.campaign iconClick]; +} + +- (void)addAdChoicesView { + [self addSubview:self.adChoicesView]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:_adChoicesView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.0 + constant:16.0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:_adChoicesView + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.0 + constant:16.0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:_adChoicesView + attribute:NSLayoutAttributeRight + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeRight + multiplier:1.0 + constant:0.0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:_adChoicesView + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeTop + multiplier:1.0 + constant:0.0]]; +} + + +- (UIImageView*)adChoicesView { + if (!_adChoicesView) { + _adChoicesView = [[UIImageView alloc] init]; + _adChoicesView.userInteractionEnabled = YES; + _adChoicesView.translatesAutoresizingMaskIntoConstraints = NO; + UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(adIconClick)]; + [_adChoicesView addGestureRecognizer:gesture]; + } + return _adChoicesView; +} + +- (void)addSubview:(UIView *)view { + [super addSubview:view]; + [self bringSubviewToFront:self.adChoicesView]; +} + +- (void)setMediaViewWithFrame:(CGRect)frame { + _mediaView = [[OMCrossPromotionNativeMediaView alloc]initWithFrame:frame]; +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.h new file mode 100644 index 0000000..b403402 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.h @@ -0,0 +1,24 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import + +#import "OMToolUmbrella.h" +#import "OMCrossPromotionVideoController.h" +#import "OMCustomEventDelegate.h" +#import "OMRewardedVideoCustomEvent.h" +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionRewardedVideo : NSObject +@property (nonatomic, strong) OMCrossPromotionVideoController *crossPromotionVideo; +@property (nonatomic, copy) NSString *pid; +@property (nonatomic, copy) NSString *showSceneID; +@property (nonatomic, weak) id delegate; +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; +@property (nonatomic, assign) BOOL autorotate; +- (instancetype)initWithParameter:(NSDictionary*)adParameter; +- (void)loadAdWithBidPayload:(NSString*)bidPayload; +- (BOOL)isReady; +- (void)show:(UIViewController*)vc; +@end +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.m new file mode 100644 index 0000000..d7cdb18 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionRewardedVideo.m @@ -0,0 +1,142 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionRewardedVideo.h" + +@protocol PromotionEventDelegate + +@optional + +- (void)customEventAddEvent:(NSObject*)adapter event:(NSDictionary*)eventBody; + +@end + +@implementation OMCrossPromotionRewardedVideo + +- (instancetype)initWithParameter:(NSDictionary*)adParameter { + if (self = [super init]) { + _pid = [adParameter objectForKey:@"pid"]; + } + return self; +} + +- (void)loadAdWithBidPayload:(NSString*)bidPayload { + NSString *payload = @""; + if ([bidPayload length]>0) { + NSData *data = [bidPayload dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *admBody = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if([admBody isKindOfClass:[NSDictionary class]]) { + payload = admBody[@"payload"]; + } + } + if (![payload length]) { + if(_delegate && [_delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + NSError *error = [[NSError alloc]initWithDomain:@"com.crosspromotion.ads" code:501 userInfo: @{NSLocalizedDescriptionKey:@"Invalid bid payload"}]; + [_delegate customEvent:self didFailToLoadWithError:error]; + } + return; + } + + __weak __typeof(self) weakSelf = self; + [[OMCrossPromotionCampaignManager sharedInstance] loadAdWithPid:_pid size:CGSizeMake(1200, 627) action:4 payload:payload completionHandler:^(OMCrossPromotionCampaign *campaign, NSError *error) { + if(weakSelf) { + if (!error) { + weakSelf.campaign = campaign; + [campaign cacheMaterielCompletion:^{ + if(weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didLoadAd:)]) { + [weakSelf.delegate customEvent:weakSelf didLoadAd:nil]; + } + }]; + }else{ + if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customEvent:didFailToLoadWithError:)]) { + [weakSelf.delegate customEvent:weakSelf didFailToLoadWithError:error]; + } + } + } + }]; +} + +- (BOOL)isReady { + if(self.campaign && [self.campaign isReady]) { + return YES; + } + return NO; +} + +- (void)show:(UIViewController*)vc { + if (!vc) { + return; + } + self.crossPromotionVideo = [[OMCrossPromotionVideoController alloc]initWithCampaign:_campaign scene:self.showSceneID]; + _crossPromotionVideo.delegate = self; + + [vc presentViewController:self.crossPromotionVideo animated:YES completion:^{ + + }]; +} + +#pragma mark -- adtimingVideoPlayDelegate + +- (void)promotionVideoOpen { + [_campaign impression:OM_SAFE_STRING(self.showSceneID)]; + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidOpen:)]) { + [_delegate rewardedVideoCustomEventDidOpen:self]; + } +} + +- (void)promotionVideoPlayStart { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoStart:)]) { + [_delegate rewardedVideoCustomEventVideoStart:self]; + } +} + +- (void)promotionVideoPlayEnd { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventVideoEnd:)]) { + [_delegate rewardedVideoCustomEventVideoEnd:self]; + } +} + + + +- (void)promotionVideoClick:(BOOL)trackClick { + if(trackClick) { + [_campaign clickAndShowAd:self.crossPromotionVideo sceneID:OM_SAFE_STRING(self.showSceneID)]; + } + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClick:)]) { + [_delegate rewardedVideoCustomEventDidClick:self]; + } +} + +- (void)promotionVideoClose { + + _crossPromotionVideo = nil; + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidClose:)]) { + [_delegate rewardedVideoCustomEventDidClose:self]; + } +} + +- (void)promotionVideoReward { + if(_delegate && [_delegate respondsToSelector:@selector(rewardedVideoCustomEventDidReceiveReward:)]) { + [_delegate rewardedVideoCustomEventDidReceiveReward:self]; + } +} + +- (void)promotionVideoAddEvent:(NSString*)eventBody { + if(!OM_STR_EMPTY(eventBody)) { + NSData *data = [eventBody dataUsingEncoding:NSUTF8StringEncoding]; + NSError *jsonErr = nil; + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonErr]; + if(!jsonErr) { + id delegate = (id)_delegate; + NSMutableDictionary *body = [NSMutableDictionary dictionaryWithDictionary:dict]; + [body setObject:OM_SAFE_STRING(self.showSceneID) forKey:@"scene"]; + if(delegate && [delegate respondsToSelector:@selector(customEventAddEvent:event:)]) { + [delegate customEventAddEvent:self event:body]; + } + } + } +} + + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.h new file mode 100644 index 0000000..d4f218e --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.h @@ -0,0 +1,37 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import +#import "OMToolUmbrella.h" +#import "OMCrossPromotionCampaignManager.h" +#import "OMCrossPromotionJSBridge.h" + +NS_ASSUME_NONNULL_BEGIN + +@protocol promotionVideoDelegate + +- (void)promotionVideoOpen; +- (void)promotionVideoPlayStart; +- (void)promotionVideoClick:(BOOL)trackClick; +- (void)promotionVideoPlayEnd; +- (void)promotionVideoClose; +- (void)promotionVideoReward; +- (void)promotionVideoAddEvent:(NSString*)eventBody; + +@end + +@interface OMCrossPromotionVideoController : UIViewController + +@property (nonatomic, strong) OMCrossPromotionCampaign *campaign; +@property (nonatomic, strong) OMCrossPromotionJSBridge *jsBridge; +@property (nonatomic, strong) WKWebView *wkView; +@property (nonatomic, strong) UIButton *lpCloseItem; +@property (nonatomic, assign) BOOL appSettingStatusBarHidden; +@property (nonatomic, weak) id delegate; + +- (instancetype)initWithCampaign:(OMCrossPromotionCampaign*)campaign scene:(NSString*)sceneID; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.m new file mode 100644 index 0000000..265fc84 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionVideoController.m @@ -0,0 +1,247 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionVideoController.h" +#import "OMToolUmbrella.h" +#import +#import "OMEventManager.h" + +#define CLOSE_ICON_WIDTH (([UIScreen mainScreen].bounds.size.width < [UIScreen mainScreen].bounds.size.height)?([UIScreen mainScreen].bounds.size.width/320.0*16.0):([UIScreen mainScreen].bounds.size.height/320*16.0)) + +static NSString *const close_image_string = @"iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDoxYzVlZDUwOS1kZjFjLTQ2MWQtYmM5OS05Njk2OGVmYTk4MzUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RTg0NjYxODU2QjM3MTFFNjlGMDFENzQwNjQzNkQ5RkQiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RTg0NjYxODQ2QjM3MTFFNjlGMDFENzQwNjQzNkQ5RkQiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6YjI3NDZmMjItYmNjNC00N2RhLTg2ZDItMjkxYmJlMzdjNzU4IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjFjNWVkNTA5LWRmMWMtNDYxZC1iYzk5LTk2OTY4ZWZhOTgzNSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PmTscY4AAAhzSURBVHja5FtpTFVHFL489kXeE1lcWGrVWmWRpz4oggISlSiaSBX9UTGkEKKtojW41KIJlpoGFKoYFGwQbQ1R0Zga11gFQcqigIAC2lIQLSJFdlBZes5zhl7Rt9/7gHiSE5j7Zs6Z787MWebO6DH8kR6wOfAoYFNgI2BD8lyX1OkF7gF+CdwN3AHcBtxKnnNOOhzLQ0DWwJYErLry+wnoRuDn5GUMK8AiYDtgCx5eIoJvAn4M3DzUgBHoRGAhox1qAa7WBLi6gA2AJwHbMENDz4D/BH6lDcBWwFOJ8RlKQqNWSdY4L4AFZFQnMMOLnpDR7uMSMLoRJ+DRzPAkXNPlwK+5AKwP7EL86XCmduASRaAFSgQPIwEskhnwDEW2RaDgN8cRApYN2lEeLnmAJw3jNSuPRpO+qwTYSpY1Pnr0qFtzc3NSUVFRqJ6eno42kaC+4uLiUNB/ODk5ebacqhNIiKuU0cJ4WCJrLSBYoVD4Kf5///79DEdHx0RtAQZ9G6ZNmxYoDblaWipEItE6BX66gCQmckd4iryFX1NTU0z/nz59+uelpaXh2gALetZRsIP7IcfgTlE0pUUk05FJnp6eKbW1tb/TspOT0+rCwsIQPsHevXs3BPQE0TLov4H9UKKp5WA7NBjwRIXOrr29D6ZxTF1dXRZ9NmvWrOC8vLwv+ACbn58fLBaLg2kZ9N5ycXGJwX4oKeIjWYBFymY9qGz27Nl76uvrc+kzNze3L7Ozs4O4BIvyJBLJwOwBfX+A3mhYv70qiBESbO8AtlMpXXn2rMfV1XUX/C1gTfd1N2/eDOQCLMpBeSx9hTCTUJ86OyF2gwEbkOSdURW0l5dXVGNjYxF95u3t/fXly5cDNAGL7VEOLYP8YtDz3dOnT1+rKdKCYBwAbK1ubvzo0aOXHh4eO5qamkqpq1u0aNE3Fy5c8FdHHrbD9rQ/ILcMwO5APRpudFizAVtpMiLYmYULF+548eLFA6pg8eLFkRkZGfNVkYP1sR0FC/IqQO72yspKLva0rChguruoEd25c6djwYIFkWBQHkoR6+gIli9fvjM9PX2eMu2xHtbHdlhubW196O/vH4lyObKBiFFPwGi2u/gOaOh0ZFtb218U9MqVK6OOHTvmIa8d/o71KFhsHxgYuBVcUjuHRh8xmgu4zoZu3LjRAqC3dHR01EinkECgt2bNmuiUlBTJ++rjc/wd62EZ2tWuWLFiy/Xr15sZ7mmULgm0TbmUWl1d3Q1x761ly5Z56uvrm+PIzZgxY56VlVX5pUuX6mm9gwcPisPCwmJ0dXWlFrSzs/NJcHAwGrwmnoK217rERxlyLbmioqKrqqrq1tKlS70A9CgcQfCjPubm5iVXr15tiIuLc96wYcOPAFaqu6urqz4kJGTzmTNnnjP8US/Oaw8+AFNau3btuMOHD/9kZGQktZI9PT0d165dOwQG7itI96Qzq7u7+/n69esjUlNT/+E5B3mJgOcy/3/r4YVg2k44cOAAgh5DHvVTQ/nq1at/N27cuOnIkSN1Wki6ehHox3xrgWwHDG9bHoyqH0xtQwoWRrtt27ZtmxITEx9rKaUWCJghpt7eXm2q66NGi1fg4eHhtvFAYLxE7CmNo+3r6zu3oaEhB2eBFgD3CBievsNSAss7LiEhYb+BgcEYMo07ITmIQ+OFZVzXsL7j0bhpaw1b82Wlg4KCrCGwSDA2NrYh0/clgNsOvjZbKBSWuru7z0d3hdYaEoY5EDNngf/u5BFwpy7ZAjHlWjKEhpZpaWnxJiYm4ynY5OTkbyMiIqR7UeiLMRBB34yg0VcHBATMAcCZ6MN5AtyCgE0YjvefIcMRQTIQb2pqKk28+/r6eiBejoK1XMiuh1GXnZ1dpaurqy9GYxiVQaDinpeXdxOjNR4AN+Aa5tRY+Pn5iSBa2gdg7SnYkydP7g4NDc2X4aMLTpw4sQvrYRnaOZw7d24fGDM+PrK36ZD00JOLjMnNzc0Moqj9ED5Kt0f7+/v7Tp8+Hb1q1apMZdJDWPO7acaEaSa8vM0cpofoGXKolW7VVBqsRVOwvrFssOfPn/9BGbBIq1evzoKRjcF20p03oXAKvLxYlMsRYOnJIDqqtsCT1ZU0depUo9u3b8daWFg40bd58eLF2CVLllxSZ4sH2m1lbfGgNY/UcItHujEDXEcDjgYy5CrT5MmTDbOzs/eywcLIxKsDFgks9eUrV67sp/0Buc65ubl7UY+G07mBvaeFh0NUzkHHjx+vD2C/t7S0dKXPsrKyDoGV/k2TofD397+QmZk58M0K5ItBzx4bGxt1z5U0EYxvhZQqBfCoHAxKNPwd+IqXk5NzxNvbO4OLBefj43MW5CWx9EmKi4uj1QQ9gI0NGLdUWpRpDQZFt7CwcNfYsWM/o8+gnOrl5ZXOpQ8BeacKCgpSaRn0eYCeKDMzM1Vi/xaGda5rcMO/FbVGZffu3dtpa2s7lz6DN/+LRCI5zkdoBK7ueFFR0YBs0DuvvLx8pwqg38I0uNEL5s35RpkE0yzM3t7el5ZB+WmxWPwznxH/zJkzU8vKyk7RMuifD/0IVaJpI8EkEzDSQ3kZlIODgytr3+oshIVJ2khknZ2dkx48eHCW1Q+xolSQYGEUAUZ/VyVLCoSNqfj1HabZCehEIqR5/YyWyMXFJbGkpORX1A9BSpqC6lXMoK//jIJw8hP0PMzIpKeyBk2gIDJpHoFgm0nfGVUBY0yLx/k6RhDYDtLnPnUAI+H3WDzO1z5CwCo8eqhsSojRDcbKomEKFoOLMoajw6Xs2fDBHB9m0wdzQJxNQ30FoIFYYq1cAWDTB3PJ433AP4hrPIPJiKxx5FGMZhe12sj6HJYXtWS5MvZVPGPmzXWC913FQ3fSxWjhKt5/AgwAI3JQfgU5cW4AAAAASUVORK5CYII="; + +@implementation WKPreferences (promotionKVC) +-(void)setValue:(id)value forUndefinedKey:(NSString *)key { + +} +@end + + +@implementation OMCrossPromotionVideoController + +- (instancetype)initWithCampaign:(OMCrossPromotionCampaign*)campaign scene:(NSString*)sceneID { + if ([super init]) { + _campaign = campaign; + self.modalPresentationStyle = UIModalPresentationFullScreen; + [self.wkView loadHTMLString:[_campaign webHtmlStr] baseURL:[NSURL fileURLWithPath:[NSString omUrlCachePath:[_campaign webUrl]]]]; + } + return self; +} +- (void)viewDidLoad { + [super viewDidLoad]; + [self.view addSubview:self.wkView]; + [self.view addSubview:self.lpCloseItem]; + [self.view addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + self.wkView.frame = self.view.bounds; +} + +- (void)close { + [self dismissViewControllerAnimated:YES completion:^{ + + }]; +} + +- (void)showLpCloseItem { + [UIView animateWithDuration:2 animations:^{ + self.lpCloseItem.alpha = 1.0; + }]; +} + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )coordinator { + _wkView.frame = CGRectMake(0, 0, size.width, size.height); + _lpCloseItem.frame = CGRectMake((_lpCloseItem.frame.origin.x 0) { + _lpCloseItem.frame = CGRectMake(10, 10, CLOSE_ICON_WIDTH, CLOSE_ICON_WIDTH); + } else { + _lpCloseItem.frame = CGRectMake(self.view.frame.size.width - 30, 10, CLOSE_ICON_WIDTH, CLOSE_ICON_WIDTH); + } + } + return _lpCloseItem; +} + +- (void)dealloc{ + [self.view removeObserver:self forKeyPath:@"frame"]; + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} + + +#pragma mark -- OMCrossPromotionJSBridgeDelegate + +- (void)jsBridgeSetCloseVisible:(BOOL)visible { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if (weakSelf) { + if (visible) { + [self showLpCloseItem]; + } else { + weakSelf.lpCloseItem.alpha = 0; + } + } + }); +} + + +- (void)jsBridgeClick:(BOOL)trackClick { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if (weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(promotionVideoClick:)]) { + [weakSelf.delegate promotionVideoClick:trackClick]; + } + }); +} + +- (void)jsBridgeVideoPlayProgress:(NSInteger)percentage { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if(percentage == 0) { + if(weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(promotionVideoPlayStart)]) { + [weakSelf.delegate promotionVideoPlayStart]; + } + }else if(percentage == 100) { + if(weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(promotionVideoPlayEnd)]) { + [weakSelf.delegate promotionVideoPlayEnd]; + } + } + }); +} + +- (void)jsBridgeAddRewarded { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if (weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(promotionVideoReward)]) { + [weakSelf.delegate promotionVideoReward]; + } + }); +} + +- (void)jsBridgeClose { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if (weakSelf) { + [weakSelf close]; + } + }); +} + + +- (void)jsBridgePushEvent:(NSString*)eventBody { + __weak __typeof(self) weakSelf = self; + dispatch_sync_on_main_queue(^{ + if (weakSelf && weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(promotionVideoAddEvent:)]) { + [weakSelf.delegate promotionVideoAddEvent:eventBody]; + } + }); +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.h b/OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.h new file mode 100644 index 0000000..46ae3d8 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.h @@ -0,0 +1,27 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import + +@protocol OMWebViewControllerDelegate + +@optional + +- (void)webViewControllerDismiss; +@end + +NS_ASSUME_NONNULL_BEGIN + +@interface OMCrossPromotionWebController : UIViewController + +@property (nonatomic, strong) NSString *url; +@property (nonatomic, strong) WKWebView *webView; +@property (nonatomic, strong) UIProgressView *progressView; +@property (nonatomic, strong) UIButton *closeItem; +@property (nonatomic, assign) BOOL appSettingStatusBarHidden; +@property (nonatomic, assign) id delegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.m b/OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.m new file mode 100644 index 0000000..1e141f9 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMCrossPromotionWebController.m @@ -0,0 +1,150 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "OMCrossPromotionWebController.h" +#import "OMToolUmbrella.h" + +@implementation OMCrossPromotionWebController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.view.backgroundColor = [UIColor whiteColor]; + [self.view addSubview:self.webView]; + [self.view addSubview:self.progressView]; + UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)]; + self.navigationItem.leftBarButtonItem = leftButton; + if(!OM_STR_EMPTY(_url)) { + [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]]; + } +} + +- (void)cancel { + [self dismissViewControllerAnimated:YES completion:^{ + if(self.delegate && [self.delegate respondsToSelector:@selector(webViewControllerDismiss)]) { + [self.delegate webViewControllerDismiss]; + } + }]; +} + +- (WKWebView*)webView { + if(!_webView) { + WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]init]; + if (@available(iOS 13.0, *)) { + configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile; + } + _webView = [[WKWebView alloc]initWithFrame:self.view.bounds configuration:configuration]; + _webView.UIDelegate = self; + _webView.navigationDelegate = self; + [_webView addObserver:self forKeyPath:@"estimatedProgress"options:NSKeyValueObservingOptionNew context:nil]; + } + return _webView; +} + +- (UIProgressView *)progressView { + if (_progressView == nil) { + _progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, [UIApplication sharedApplication].statusBarFrame.size.height+ self.navigationController.navigationBar.frame.size.height, [UIScreen mainScreen].bounds.size.width, 1)]; + _progressView.tintColor = self.view.tintColor; + _progressView.trackTintColor = [UIColor whiteColor]; + } + + return _progressView; +} + + + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if (object == self.webView && [keyPath isEqualToString:@"estimatedProgress"]) { + CGFloat newprogress = [[change objectForKey:NSKeyValueChangeNewKey] doubleValue]; + self.progressView.alpha = 1.0f; + [self.progressView setProgress:newprogress animated:YES]; + if (newprogress >= 1.0f) { + [UIView animateWithDuration:0.3f + delay:0.3f + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + self.progressView.alpha = 0.0f; + } + completion:^(BOOL finished) { + [self.progressView setProgress:0 animated:NO]; + }]; + } + + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + + +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + decisionHandler(WKNavigationActionPolicyAllow); +} + + +- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { + + decisionHandler(WKNavigationResponsePolicyAllow); +} + +- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *__nullable credential))completionHandler { + + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling ,nil); +} + + +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation { + +} + + +- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(null_unspecified WKNavigation *)navigation { + // 重定向时调用 +} + + +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { + +} + + +- (void)webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation { +} + + +- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation { + UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(cancel)]; + self.navigationItem.leftBarButtonItem = leftButton; +} + + +- (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { + +} + + +- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView { +} + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )coordinator { + _webView.frame = CGRectMake(0, 0, size.width, size.height); +} + +- (void)viewWillAppear:(BOOL)animated { + _appSettingStatusBarHidden = [[UIApplication sharedApplication]isStatusBarHidden]; + [UIApplication sharedApplication].statusBarHidden = NO; +} +- (void)viewWillDisappear:(BOOL)animated { + [UIApplication sharedApplication].statusBarHidden = _appSettingStatusBarHidden; + [super viewWillDisappear:animated]; +} + +- (BOOL)prefersStatusBarHidden { + return NO; +} + +- (void)dealloc { + [_webView removeObserver:self forKeyPath:@"estimatedProgress"]; + [_webView setNavigationDelegate:nil]; + [_webView setUIDelegate:nil]; +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMPromotionConfig.h b/OpenMediation/OpenMediationPromotion/OMPromotionConfig.h new file mode 100644 index 0000000..abc507c --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMPromotionConfig.h @@ -0,0 +1,24 @@ +// +// OMPromotionConfig.h +// OMPromotionAdapter +// +// Created by ylm on 2020/11/11. +// Copyright © 2020 AdTiming. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OMPromotionConfig : NSObject + +@property (nonatomic, strong) NSMutableArray *placementList; +@property (nonatomic, strong) NSMutableDictionary *placementMap; + ++ (instancetype) sharedInstance; + +- (void)loadConfig:(NSDictionary*)configData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMPromotionConfig.m b/OpenMediation/OpenMediationPromotion/OMPromotionConfig.m new file mode 100644 index 0000000..3d9c96d --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMPromotionConfig.m @@ -0,0 +1,35 @@ +// +// OMPromotionConfig.m +// OMPromotionAdapter +// +// Created by ylm on 2020/11/11. +// Copyright © 2020 AdTiming. All rights reserved. +// + +#import "OMPromotionConfig.h" + +static OMPromotionConfig * _instance = nil; + +@implementation OMPromotionConfig + ++ (instancetype) sharedInstance{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _instance = [[self alloc] init]; + }); + return _instance; +} + +- (instancetype)init{ + if (self = [super init]) { + _placementList = [NSMutableArray array]; + _placementMap = [NSMutableDictionary dictionary]; + } + return self; +} + +- (void)loadConfig:(NSDictionary*)configData { + +} + +@end diff --git a/OpenMediation/OpenMediationPromotion/OMPromotionUnit.h b/OpenMediation/OpenMediationPromotion/OMPromotionUnit.h new file mode 100644 index 0000000..5eca383 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMPromotionUnit.h @@ -0,0 +1,23 @@ +// +// OMPromotionUnit.h +// OpenMediation +// +// Created by ylm on 2020/11/11. +// Copyright © 2020 AdTiming. All rights reserved. +// + +#import +#import "OpenMediationAdFormats.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OMPromotionUnit : NSObject + +@property (nonatomic, copy) NSString *unitID; +@property (nonatomic, assign) OpenMediationAdFormat adFormat; + +- (instancetype)initWithUnitData:(NSDictionary*)unitData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationPromotion/OMPromotionUnit.m b/OpenMediation/OpenMediationPromotion/OMPromotionUnit.m new file mode 100644 index 0000000..2e662a8 --- /dev/null +++ b/OpenMediation/OpenMediationPromotion/OMPromotionUnit.m @@ -0,0 +1,21 @@ +// +// OMPromotionUnit.m +// OpenMediation +// +// Created by ylm on 2020/11/11. +// Copyright © 2020 AdTiming. All rights reserved. +// + +#import "OMPromotionUnit.h" + +@implementation OMPromotionUnit + +- (instancetype)initWithUnitData:(NSDictionary*)unitData { + if (self = [super init]) { + _unitID = [NSString stringWithFormat:@"%@",[unitData objectForKey:@"id"]]; + _adFormat = (1<<[[unitData objectForKey:@"t"]integerValue]); + } + return self; +} + +@end diff --git a/OpenMediation/OpenMediationTool/NSData+OMGzip.h b/OpenMediation/OpenMediationTool/NSData+OMGzip.h index e7a1e23..aa58f26 100644 --- a/OpenMediation/OpenMediationTool/NSData+OMGzip.h +++ b/OpenMediation/OpenMediationTool/NSData+OMGzip.h @@ -12,7 +12,8 @@ NS_ASSUME_NONNULL_BEGIN - (NSData *)omGzipData; - (NSData *)omUnzipData; - (BOOL)omIsGzippedData; - +- (NSData *)omZlibInflate; +- (NSData *)omZlibDeflate; @end NS_ASSUME_NONNULL_END diff --git a/OpenMediation/OpenMediationTool/NSData+OMGzip.m b/OpenMediation/OpenMediationTool/NSData+OMGzip.m index 843892b..0ad07cb 100644 --- a/OpenMediation/OpenMediationTool/NSData+OMGzip.m +++ b/OpenMediation/OpenMediationTool/NSData+OMGzip.m @@ -88,4 +88,88 @@ - (BOOL)omIsGzippedData { return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b); } +- (NSData *)omZlibInflate { + if ([self length] == 0) return self; + + unsigned full_length = (unsigned)([self length]); + unsigned half_length = (unsigned)([self length] / 2); + + NSMutableData *decompressed = [NSMutableData dataWithLength: full_length + half_length]; + BOOL done = NO; + int status; + + z_stream strm; + strm.next_in = (Bytef *)[self bytes]; + strm.avail_in = (uint)[self length]; + strm.total_out = 0; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + + if (inflateInit (&strm) != Z_OK) return nil; + + while (!done) + { + // Make sure we have enough room and reset the lengths. + if (strm.total_out >= [decompressed length]) + [decompressed increaseLengthBy: half_length]; + strm.next_out = [decompressed mutableBytes] + strm.total_out; + strm.avail_out = (uint)[decompressed length] - (uint)strm.total_out; + + // Inflate another chunk. + status = inflate (&strm, Z_SYNC_FLUSH); + if (status == Z_STREAM_END) done = YES; + else if (status != Z_OK) break; + } + if (inflateEnd (&strm) != Z_OK) return nil; + + // Set real length. + if (done) + { + [decompressed setLength: strm.total_out]; + return [NSData dataWithData: decompressed]; + } + else return nil; +} + +- (NSData *)omZlibDeflate { + if ([self length] == 0) return self; + + z_stream strm; + + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + strm.total_out = 0; + strm.next_in=(Bytef *)[self bytes]; + strm.avail_in = (uint)[self length]; + + // Compresssion Levels: + // Z_NO_COMPRESSION + // Z_BEST_SPEED + // Z_BEST_COMPRESSION + // Z_DEFAULT_COMPRESSION + + if (deflateInit(&strm, Z_DEFAULT_COMPRESSION) != Z_OK) return nil; + + // 16K chuncks for expansion + NSMutableData *compressed = [NSMutableData dataWithLength:16384]; + + do { + + if (strm.total_out >= [compressed length]) + [compressed increaseLengthBy: 16384]; + + strm.next_out = [compressed mutableBytes] + strm.total_out; + strm.avail_out = (uint)[compressed length] - (uint)strm.total_out; + + deflate(&strm, Z_FINISH); + + } while (strm.avail_out == 0); + + deflateEnd(&strm); + + [compressed setLength: strm.total_out]; + return [NSData dataWithData: compressed]; +} + @end diff --git a/OpenMediation/OpenMediationTool/UIDevice+OMExtension.h b/OpenMediation/OpenMediationTool/UIDevice+OMExtension.h index 25d3945..5185f85 100644 --- a/OpenMediation/OpenMediationTool/UIDevice+OMExtension.h +++ b/OpenMediation/OpenMediationTool/UIDevice+OMExtension.h @@ -48,6 +48,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSString*)omCarrierInfo; ++ (long long)omMemorySize; + + (long long)omRamSize; + (NSInteger)omFreeRamSize; @@ -92,6 +94,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSNumber*)omFirstLaunchTime; ++ (NSString*)omAFUid; + + (long long)omBootTime; @end diff --git a/OpenMediation/OpenMediationTool/UIDevice+OMExtension.m b/OpenMediation/OpenMediationTool/UIDevice+OMExtension.m index b6f96a3..044fd10 100644 --- a/OpenMediation/OpenMediationTool/UIDevice+OMExtension.m +++ b/OpenMediation/OpenMediationTool/UIDevice+OMExtension.m @@ -16,6 +16,11 @@ #include #include +@interface AppsFlyerTracker : NSObject ++ (id)sharedTracker; +- (NSString *)getAppsFlyerUID; +@end + @implementation UIDevice (OMExtension) + (NSNumber*)omTimeStamp { @@ -140,6 +145,10 @@ + (NSString*)omCarrierInfo { return carrierInfo; } ++ (long long)omMemorySize { + return [NSProcessInfo processInfo].physicalMemory; +} + + (long long)omRamSize { long long ramSize = [[[[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil] objectForKey:NSFileSystemSize] longLongValue]; return ramSize; @@ -418,6 +427,16 @@ + (NSNumber*)omFirstLaunchTime { } ++ (NSString*)omAFUid { + NSString *uid = @""; + Class af = NSClassFromString(@"AppsFlyerTracker"); + if (af && [af respondsToSelector:@selector(sharedTracker)] && [af instancesRespondToSelector:@selector(getAppsFlyerUID)] ) { + AppsFlyerTracker *sdk = [af sharedTracker]; + uid = OM_SAFE_STRING([sdk getAppsFlyerUID]); + } + return uid; +} + + (long long)omBootTime { long long btime = 0; struct timeval boottime; diff --git a/OpenMediation/OpenMediationUmbrella.h b/OpenMediation/OpenMediationUmbrella.h index ee37bef..669f5f5 100644 --- a/OpenMediation/OpenMediationUmbrella.h +++ b/OpenMediation/OpenMediationUmbrella.h @@ -18,3 +18,6 @@ #import #import + +#import +#import diff --git a/OpenMediationDemo/AppDelegate.m b/OpenMediationDemo/AppDelegate.m index 1281bc7..e334b1b 100644 --- a/OpenMediationDemo/AppDelegate.m +++ b/OpenMediationDemo/AppDelegate.m @@ -19,8 +19,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( self.window.rootViewController = [[[UINavigationController alloc] initWithRootViewController:[WelcomeViewController alloc]]init]; [self.window makeKeyAndVisible]; - [OpenMediation initWithAppKey:@"mN5ML6VCxGbcmHZvW8tWVN8mkALGGnoW"]; - + [OpenMediation initWithAppKey:@"mN5ML6VCxGbcmHZvW8tWVN8mkALGGnoW" baseHost:@"https://omtest.adtiming.com"]; return YES; } diff --git a/OpenMediationDemo/CrossPromotionViewController.h b/OpenMediationDemo/CrossPromotionViewController.h new file mode 100644 index 0000000..671c95c --- /dev/null +++ b/OpenMediationDemo/CrossPromotionViewController.h @@ -0,0 +1,13 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import +#import "BaseViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface CrossPromotionViewController : BaseViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/OpenMediationDemo/CrossPromotionViewController.m b/OpenMediationDemo/CrossPromotionViewController.m new file mode 100644 index 0000000..143af7f --- /dev/null +++ b/OpenMediationDemo/CrossPromotionViewController.m @@ -0,0 +1,70 @@ +// Copyright 2020 ADTIMING TECHNOLOGY COMPANY LIMITED +// Licensed under the GNU Lesser General Public License Version 3 + +#import "CrossPromotionViewController.h" + +@interface CrossPromotionViewController () + +@end + +@implementation CrossPromotionViewController + +- (void)viewDidLoad { + self.title = @"CrossPromotion"; + self.adFormat = OpenMediationAdFormatCrossPromotion; + [super viewDidLoad]; + +} + +- (void)loadAd { + [[OMCrossPromotion sharedInstance] addDelegate:self]; + if ([[OMCrossPromotion sharedInstance]isReady]) { + self.showItem.enabled = YES; + } +} + + +-(void)showItemAction { + self.showItem.enabled = NO; + [[OMCrossPromotion sharedInstance]showAdWithScreenPoint:CGPointMake(0.5, 0.5) scene:self.loadID]; +} + +-(void)removeItemAction { + self.removeItem.enabled = NO; + [[OMCrossPromotion sharedInstance]hideAd]; +} + +- (void)omCrossPromotionChangedAvailability:(BOOL)available { + self.showItem.enabled = available; + if (available) { + [self showLog:@"CrossPromotion ad did load"]; + } +} + +/// Sent immediately when promotion ad will appear. +- (void)omCrossPromotionWillAppear:(OMScene*)scene { + [self showLog:@"CrossPromotion ad will appear"]; + self.removeItem.enabled = YES; +} + +/// Sent after a promotion ad has been clicked. +- (void)omCrossPromotionDidClick:(OMScene*)scene { + [self showLog:@"CrossPromotion ad click"]; +} + +/// Sent after a promotion ad did sdisappear. +- (void)omCrossPromotionDidDisappear:(OMScene*)scene { + [self showLog:@"CrossPromotion ad did disappear"]; +} + +/// Sent after a promotion video has failed to play. +- (void)omCrossPromotionDidFailToShow:(OMScene*)scene withError:(NSError *)error { + [self showLog:@"CrossPromotion fail show"]; +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [[OMCrossPromotion sharedInstance]hideAd]; +} + +@end diff --git a/OpenMediationDemo/Info.plist b/OpenMediationDemo/Info.plist index 4f60653..6500dde 100644 --- a/OpenMediationDemo/Info.plist +++ b/OpenMediationDemo/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.3.2 + 2.0.0 CFBundleVersion 1 GADApplicationIdentifier diff --git a/OpenMediationDemo/MainViewController.m b/OpenMediationDemo/MainViewController.m index e9738b0..1d22435 100644 --- a/OpenMediationDemo/MainViewController.m +++ b/OpenMediationDemo/MainViewController.m @@ -32,12 +32,15 @@ @interface MainViewController () @property(nonatomic,strong)UITableView *mainTableView; +@property(nonatomic,strong) NSArray *titles; +@property(nonatomic,strong) NSArray *controllers; @end @implementation MainViewController - (void)viewDidLoad { [super viewDidLoad]; + self.titles = @[@"Banner",@"Native",@"Interstitial",@"RewardedVideo",@"Splash",@"CrossPromotion"]; self.title = @"Main"; self.view.backgroundColor = [UIColor whiteColor]; [self createViews]; @@ -62,33 +65,12 @@ -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 5; + return self.titles.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]; - switch (indexPath.row) { - case 0: - cell.textLabel.text = @"Banner"; - break; - case 1: - cell.textLabel.text = @"Native"; - break; - case 2: - cell.textLabel.text = @"Interstitial"; - break; - case 3: - cell.textLabel.text = @"RewardedVideo"; - break; - case 4: - cell.textLabel.text = @"Splash"; - break; - case 5: - cell.textLabel.text = @"Iap test"; - break; - default: - break; - } + cell.textLabel.text = self.titles[indexPath.row]; return cell; } @@ -96,7 +78,7 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath * [tableView deselectRowAtIndexPath:indexPath animated:YES]; - NSArray *vcGroup = @[@"BannerViewController",@"NativeViewController",@"InterstitialViewController",@"RewardedVideoViewController",@"SplashViewController"]; + NSArray *vcGroup = @[@"BannerViewController",@"NativeViewController",@"InterstitialViewController",@"RewardedVideoViewController",@"SplashViewController",@"CrossPromotionViewController"]; if (indexPath.row < vcGroup.count) { Class vcClass = NSClassFromString(vcGroup[indexPath.row]); UIViewController *vc = [[vcClass alloc] init]; diff --git a/Podfile b/Podfile index 6ae88b8..f5c9486 100644 --- a/Podfile +++ b/Podfile @@ -3,27 +3,27 @@ platform :ios, '10.0' source 'https://github.com/CocoaPods/Specs.git' target 'OpenMediationDemo' do - pod 'AdTimingSDK', '4.3.2' - pod 'Google-Mobile-Ads-SDK', '7.64.0' - pod 'FBAudienceNetwork', '5.10.1' - pod 'UnityAds', '3.4.8' - pod 'VungleSDK-iOS', '6.7.0' - pod 'AdColony', '4.3.1' - pod 'AppLovinSDK', '6.13.1' - pod 'mopub-ios-sdk', '5.13.1' - pod 'TapjoySDK', '12.6.1' - pod 'ChartboostSDK', '8.2.0' - pod 'Bytedance-UnionAD', '3.1.0.5' - pod 'MintegralAdSDK/RewardVideoAd', '6.3.7' - pod 'MintegralAdSDK/InterstitialVideoAd', '6.3.7' - pod 'MintegralAdSDK/BannerAd', '6.3.7' - pod 'MintegralAdSDK/SplashAd', '6.3.7' - pod 'MintegralAdSDK/BidRewardVideoAd', '6.3.7' - pod 'MintegralAdSDK/BidInterstitialVideoAd', '6.3.7' - pod 'MintegralAdSDK/BidBannerAd', '6.3.7' - pod 'GDTMobSDK', '4.11.8' - pod 'IronSourceSDK','7.0.0' - pod 'ChartboostHelium', '2.0.0' + pod 'AdTimingSDK', '4.4.1' + pod 'Google-Mobile-Ads-SDK', '7.66.0' + pod 'FBAudienceNetwork', '6.2.0' + pod 'UnityAds', '3.5.1' + pod 'VungleSDK-iOS', '6.8.1' + pod 'AdColony', '4.4.0' + pod 'AppLovinSDK', '6.14.6' + pod 'mopub-ios-sdk', '5.14.1' + pod 'TapjoySDK', '12.7.0' + pod 'ChartboostSDK', '8.3.1' + pod 'Bytedance-UnionAD', '3.2.6.2' + pod 'MintegralAdSDK/RewardVideoAd', '6.6.9' + pod 'MintegralAdSDK/InterstitialVideoAd', '6.6.9' + pod 'MintegralAdSDK/BannerAd', '6.6.9' + pod 'MintegralAdSDK/SplashAd', '6.6.9' + pod 'MintegralAdSDK/BidRewardVideoAd', '6.6.9' + pod 'MintegralAdSDK/BidInterstitialVideoAd', '6.6.9' + pod 'MintegralAdSDK/BidBannerAd', '6.6.9' + pod 'GDTMobSDK', '4.11.12' + pod 'IronSourceSDK','7.0.3' + pod 'ChartboostHelium', '2.1.0' pod 'Fyber_Marketplace_SDK','7.5.4' end diff --git a/README.md b/README.md index f511f58..5df76ef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # OpenMediation SDK for iOS -[![CocoaPods Compatible](http://img.shields.io/badge/pod-v1.3.3-blue.svg)](https://github.com/AdTiming/OpenMediation-iOS) +[![CocoaPods Compatible](http://img.shields.io/badge/pod-v2.0.0-blue.svg)](https://github.com/AdTiming/OpenMediation-iOS) [![Platform](https://img.shields.io/badge/platform-iOS%209%2B-brightgreen.svg?style=flat)](https://github.com/AdTiming/OpenMediation-iOS) [![License](https://img.shields.io/github/license/AdTiming/OpenMediation-iOS)](https://github.com/AdTiming/OpenMediation-iOS/blob/master/LICENSE) @@ -26,7 +26,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '9.0' target 'TargetName' do - pod 'OpenMediation', '~> 1.3.3' + pod 'OpenMediation', '~> 2.0.0' end ```