diff --git a/AppNexusSDK.podspec b/AppNexusSDK.podspec index d00f17bac..8a53298d5 100644 --- a/AppNexusSDK.podspec +++ b/AppNexusSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "AppNexusSDK" - s.version = "7.8" + s.version = "7.9" s.platform = :ios, "9.0" s.summary = "AppNexus iOS Mobile Advertising SDK" @@ -22,14 +22,14 @@ DESC s.subspec 'AppNexusSDK' do |subspec| subspec.source_files = "sdk/sourcefiles/**/*.{h,m}" subspec.public_header_files = "sdk/sourcefiles/*.h","sdk/sourcefiles/native/*.h" - subspec.resources = "sdk/sourcefiles/**/*.{png,bundle,xib,nib,js,html,strings}" + subspec.resources = "sdk/sourcefiles/**/*.{png,bundle,xib,nib,js,html,strings}","sdk/AppNexusSDK/SDK-Info.plist" subspec.vendored_frameworks = "sdk/sourcefiles/Viewability/OMSDK_Appnexus.framework" subspec.frameworks = 'WebKit' end s.subspec 'GoogleAdapter' do |subspec| subspec.dependency 'AppNexusSDK/AppNexusSDK', "#{s.version}" - subspec.dependency 'Google-Mobile-Ads-SDK', '7.67.0' + subspec.dependency 'Google-Mobile-Ads-SDK', '7.69.0' subspec.source_files = "mediation/mediatedviews/GoogleAdMob/*.{h,m}" subspec.public_header_files = "mediation/mediatedviews/GoogleAdMob/ANAdAdapterNativeAdMob.h" subspec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/Google-Mobile-Ads-SDK/**' } @@ -37,7 +37,7 @@ DESC s.subspec 'FacebookCSRAdapter' do |subspec| subspec.dependency 'AppNexusSDK/AppNexusSDK', "#{s.version}" - subspec.dependency 'FBAudienceNetwork', '6.2.0' + subspec.dependency 'FBAudienceNetwork', '6.2.1' subspec.source_files = "csr/Facebook/*.{h,m}" subspec.public_header_files = "csr/Facebook/*.h" subspec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/FBAudienceNetwork/**' } @@ -45,7 +45,7 @@ DESC s.subspec 'FacebookAdapter' do |subspec| subspec.dependency 'AppNexusSDK/AppNexusSDK', "#{s.version}" - subspec.dependency 'FBAudienceNetwork', '6.2.0' + subspec.dependency 'FBAudienceNetwork', '6.2.1' subspec.source_files = "mediation/mediatedviews/Facebook/*.{h,m}" subspec.public_header_files = "mediation/mediatedviews/Facebook/ANAdAdapterNativeFacebook.h" subspec.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/FBAudienceNetwork/**' } diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index a6ba4c7b2..f7cf409ea 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,3 +1,13 @@ +## 7.9 +### New Feature ++ MS-4388 Support to disable passing device IDs in bid requests +### Mediation partner updates ++ MS-4663 Upgraded Google AdMob SDK from v7.67.0 to v7.69.0 ++ MS-4664 Upgraded Facebook SDK from v6.2.0 to v6.2.1 +### Improvements/Bug Fixes ++ MS-3911 Fetch SDK Version Dynamically in ad request + + ## 7.8 ### New Feature + MS-4387 Added support to pass traffic source and external inventory codes in Ad Request [https://wiki.xandr.com/x/5gEYBw] diff --git a/sdk/AppNexusNativeSDK/Info.plist b/sdk/AppNexusNativeSDK/SDK-Info.plist similarity index 88% rename from sdk/AppNexusNativeSDK/Info.plist rename to sdk/AppNexusNativeSDK/SDK-Info.plist index 82790df0f..65d826aa2 100644 --- a/sdk/AppNexusNativeSDK/Info.plist +++ b/sdk/AppNexusNativeSDK/SDK-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + corp.appnexus.AppNexusSDK CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - $(MARKETING_VERSION) + 7.9 CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/sdk/AppNexusSDK.xcodeproj/project.pbxproj b/sdk/AppNexusSDK.xcodeproj/project.pbxproj index e1894d18d..1363f2c82 100644 --- a/sdk/AppNexusSDK.xcodeproj/project.pbxproj +++ b/sdk/AppNexusSDK.xcodeproj/project.pbxproj @@ -388,9 +388,9 @@ 0E9F613420FFDC3B009AECD8 /* ANNativeMediatedAdResponse+PrivateMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ANNativeMediatedAdResponse+PrivateMethods.h"; sourceTree = ""; }; 0EA0790A2328E05200FB5764 /* OMSDK_Appnexus.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OMSDK_Appnexus.framework; sourceTree = ""; }; 0ECF335D22D79A61007DB185 /* AppNexusNativeSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppNexusNativeSDK.h; sourceTree = ""; }; - 0ECF335E22D79A61007DB185 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0ECF335E22D79A61007DB185 /* SDK-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SDK-Info.plist"; sourceTree = ""; }; 0ECF336022D79A62007DB185 /* AppNexusSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppNexusSDK.h; sourceTree = ""; }; - 0ECF336122D79A62007DB185 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0ECF336122D79A62007DB185 /* SDK-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SDK-Info.plist"; sourceTree = ""; }; 0EEE97DA21764ACD007DADE6 /* omsdk.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = omsdk.js; sourceTree = ""; }; 381A0181245B17850093EBB2 /* ANAudioVolumeChangeListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ANAudioVolumeChangeListener.h; sourceTree = ""; }; 381A0182245B17850093EBB2 /* ANAudioVolumeChangeListener.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ANAudioVolumeChangeListener.m; sourceTree = ""; }; @@ -702,7 +702,7 @@ isa = PBXGroup; children = ( 0ECF335D22D79A61007DB185 /* AppNexusNativeSDK.h */, - 0ECF335E22D79A61007DB185 /* Info.plist */, + 0ECF335E22D79A61007DB185 /* SDK-Info.plist */, ); path = AppNexusNativeSDK; sourceTree = ""; @@ -711,7 +711,7 @@ isa = PBXGroup; children = ( 0ECF336022D79A62007DB185 /* AppNexusSDK.h */, - 0ECF336122D79A62007DB185 /* Info.plist */, + 0ECF336122D79A62007DB185 /* SDK-Info.plist */, ); path = AppNexusSDK; sourceTree = ""; @@ -1502,7 +1502,7 @@ ); GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; HEADER_SEARCH_PATHS = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include; - INFOPLIST_FILE = AppNexusSDK/Info.plist; + INFOPLIST_FILE = "AppNexusSDK/SDK-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1539,7 +1539,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; HEADER_SEARCH_PATHS = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include; - INFOPLIST_FILE = AppNexusSDK/Info.plist; + INFOPLIST_FILE = "AppNexusSDK/SDK-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1691,7 +1691,7 @@ GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; HEADER_SEARCH_PATHS = ""; - INFOPLIST_FILE = AppNexusNativeSDK/Info.plist; + INFOPLIST_FILE = "AppNexusNativeSDK/SDK-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1699,7 +1699,7 @@ MARKETING_VERSION = 7.8; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.appnexus.AppNexusNativeSDK; + PRODUCT_BUNDLE_IDENTIFIER = corp.appnexus.AppNexusSDK; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1736,7 +1736,7 @@ GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; HEADER_SEARCH_PATHS = ""; - INFOPLIST_FILE = AppNexusNativeSDK/Info.plist; + INFOPLIST_FILE = "AppNexusNativeSDK/SDK-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1744,7 +1744,7 @@ MARKETING_VERSION = 7.8; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.appnexus.AppNexusNativeSDK; + PRODUCT_BUNDLE_IDENTIFIER = corp.appnexus.AppNexusSDK; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/sdk/AppNexusSDK/Info.plist b/sdk/AppNexusSDK/SDK-Info.plist similarity index 89% rename from sdk/AppNexusSDK/Info.plist rename to sdk/AppNexusSDK/SDK-Info.plist index ca23c84f4..2a22ce697 100644 --- a/sdk/AppNexusSDK/Info.plist +++ b/sdk/AppNexusSDK/SDK-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) + corp.appnexus.AppNexusSDK CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - $(MARKETING_VERSION) + 7.9 CFBundleSignature ???? CFBundleVersion diff --git a/sdk/sourcefiles/ANSDKSettings.h b/sdk/sourcefiles/ANSDKSettings.h index 1dbdf26f2..9c82dccf9 100644 --- a/sdk/sourcefiles/ANSDKSettings.h +++ b/sdk/sourcefiles/ANSDKSettings.h @@ -90,4 +90,9 @@ An AppNexus geoOverrideZipCode is a string value which allows publishers to ove */ @property (nonatomic, readwrite, strong, nullable) NSString *geoOverrideZipCode; +/** +An AppNexus disableIDFAUsage is a boolean value which exclude the IDFA field in ad request. Default value of disableIDFAUsage is set to NO +*/ +@property (nonatomic, readwrite) BOOL disableIDFAUsage; + @end diff --git a/sdk/sourcefiles/Viewability/ANOMIDImplementation.m b/sdk/sourcefiles/Viewability/ANOMIDImplementation.m index 67c9c547c..34f119faa 100644 --- a/sdk/sourcefiles/Viewability/ANOMIDImplementation.m +++ b/sdk/sourcefiles/Viewability/ANOMIDImplementation.m @@ -58,13 +58,13 @@ - (void) activateOMIDandCreatePartner // This Creates / updates a partner for each new activation of OMID SDK self.partner = [[OMIDAppnexusPartner alloc] initWithName: AN_OMIDSDK_PARTNER_NAME - versionString: AN_SDK_VERSION]; + versionString: [[ANSDKSettings sharedInstance] sdkVersion]]; } // IF partener is nil create partner if(!self.partner){ self.partner = [[OMIDAppnexusPartner alloc] initWithName: AN_OMIDSDK_PARTNER_NAME - versionString: AN_SDK_VERSION]; + versionString: [[ANSDKSettings sharedInstance] sdkVersion]]; } // If OMID JS is empty fetch OMIDJS. diff --git a/sdk/sourcefiles/internal/ANANJAMImplementation.m b/sdk/sourcefiles/internal/ANANJAMImplementation.m index 2147fb23f..191479166 100644 --- a/sdk/sourcefiles/internal/ANANJAMImplementation.m +++ b/sdk/sourcefiles/internal/ANANJAMImplementation.m @@ -150,15 +150,16 @@ + (void)callDispatchAppEvent:(ANAdWebViewController *)controller query:(NSDictio // Get Device ID + (void)callGetDeviceID:(ANAdWebViewController *)controller query:(NSDictionary *)query { - NSString *cb = [query valueForKey:@"cb"]; - - // send idName:idfa, id: idfa value - NSDictionary *paramsList = @{ - kANKeyCaller: kANCallGetDeviceID, - @"idname": @"idfa", - @"id": ANAdvertisingIdentifier() - }; - [ANANJAMImplementation loadResult:controller cb:cb paramsList:paramsList]; + + NSString *idfa = ANAdvertisingIdentifier(); + NSString *cb = [query valueForKey:@"cb"]; + // send idName:idfa, id: idfa value + NSDictionary *paramsList = @{ + kANKeyCaller: kANCallGetDeviceID, + @"idname": @"idfa", + @"id": (idfa ? idfa : @"") + }; + [ANANJAMImplementation loadResult:controller cb:cb paramsList:paramsList]; } // Get Custom Keywords diff --git a/sdk/sourcefiles/internal/ANAdViewInternalDelegate.h b/sdk/sourcefiles/internal/ANAdViewInternalDelegate.h index 118d8e69f..0273b6635 100644 --- a/sdk/sourcefiles/internal/ANAdViewInternalDelegate.h +++ b/sdk/sourcefiles/internal/ANAdViewInternalDelegate.h @@ -38,6 +38,7 @@ - (BOOL)valueOfEnableLazyLoad; - (BOOL)valueOfIsLazySecondPassThroughAdUnit; +- (BOOL) valueOfCountImpressionOnAdReceived; @required - (void)adRequestFailedWithError:(NSError *)error andAdResponseInfo:(ANAdResponseInfo *)adResponseInfo; diff --git a/sdk/sourcefiles/internal/ANAdWebViewController.m b/sdk/sourcefiles/internal/ANAdWebViewController.m index 59705a382..738283737 100644 --- a/sdk/sourcefiles/internal/ANAdWebViewController.m +++ b/sdk/sourcefiles/internal/ANAdWebViewController.m @@ -738,7 +738,7 @@ - (void)updateWebViewOnAudioVolumeChange:(NSNumber *)volumePercentage { - (void)updateCurrentAppOrientation { - UIInterfaceOrientation currentAppOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + UIInterfaceOrientation currentAppOrientation = ANStatusBarOrientation(); NSString *currentAppOrientationString = (UIInterfaceOrientationIsPortrait(currentAppOrientation)) ? kANPortrait : kANLandscape; NSArray *supportedOrientations = [[[NSBundle mainBundle] infoDictionary] diff --git a/sdk/sourcefiles/internal/ANBannerAdView.m b/sdk/sourcefiles/internal/ANBannerAdView.m index affe08ef9..dd6d1941a 100644 --- a/sdk/sourcefiles/internal/ANBannerAdView.m +++ b/sdk/sourcefiles/internal/ANBannerAdView.m @@ -380,8 +380,12 @@ - (void)setEnableLazyLoad:(BOOL)booleanValue - (void)fireTrackerAndOMID { - [ANTrackerManager fireTrackerURLArray:self.impressionURLs withBlock:nil]; - self.impressionURLs = nil; + if(self.impressionURLs != nil) { + //this check is needed to know if the impression was fired early or when attached to window. if impressionURL is nil then either it was fired early & removed or there was no urls in the response + ANLogDebug(@"Impression URL fired when adview is attaching to window"); + [ANTrackerManager fireTrackerURLArray:self.impressionURLs withBlock:nil]; + self.impressionURLs = nil; + } // Fire OMID - Impression event only for AppNexus WKWebview TRUE for RTB and SSM // @@ -812,7 +816,9 @@ - (BOOL)valueOfIsLazySecondPassThroughAdUnit return self.isLazySecondPassThroughAdUnit; } - +- (BOOL) valueOfCountImpressionOnAdReceived { + return self.countImpressionOnAdReceived; +} #pragma mark - UIView observer methods. diff --git a/sdk/sourcefiles/internal/ANBrowserViewController.m b/sdk/sourcefiles/internal/ANBrowserViewController.m index 60df990d3..9d932e455 100644 --- a/sdk/sourcefiles/internal/ANBrowserViewController.m +++ b/sdk/sourcefiles/internal/ANBrowserViewController.m @@ -199,7 +199,7 @@ - (BOOL)shouldStartLoadWithRequest:(NSURLRequest *)request { - (void)viewWillLayoutSubviews { CGFloat containerViewDistanceToTopOfSuperview; if ([self respondsToSelector:@selector(modalPresentationCapturesStatusBarAppearance)]) { - CGSize statusBarFrameSize = [[UIApplication sharedApplication] statusBarFrame].size; + CGSize statusBarFrameSize = ANStatusBarFrame().size; containerViewDistanceToTopOfSuperview = statusBarFrameSize.height; if (statusBarFrameSize.height > statusBarFrameSize.width) { containerViewDistanceToTopOfSuperview = statusBarFrameSize.width; @@ -270,7 +270,13 @@ - (void)refreshToolbarActivityIndicator { - (UIBarButtonItem *)refreshIndicatorItem { if (!_refreshIndicatorItem) { - UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + UIActivityIndicatorView *indicator; + if (@available(iOS 13.0, *)) + { + indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium]; + } else { + indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + } [indicator startAnimating]; _refreshIndicatorItem = [[UIBarButtonItem alloc] initWithCustomView:indicator]; } @@ -444,9 +450,17 @@ + (WKWebViewConfiguration *)defaultWebViewConfiguration { // See: https://bugs.webkit.org/show_bug.cgi?id=147512 if ([[NSProcessInfo processInfo] respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)] && [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10,0,0}]) { - configuration.requiresUserActionForMediaPlayback = NO; + if (@available(iOS 10.0, *)) { + configuration.mediaTypesRequiringUserActionForPlayback = NO; + }else { + configuration.requiresUserActionForMediaPlayback = NO; + } } else { - configuration.requiresUserActionForMediaPlayback = YES; + if (@available(iOS 10.0, *)) { + configuration.mediaTypesRequiringUserActionForPlayback = YES; + }else { + configuration.requiresUserActionForMediaPlayback = YES; + } } return configuration; diff --git a/sdk/sourcefiles/internal/ANGlobal.h b/sdk/sourcefiles/internal/ANGlobal.h index f40137400..0a9e59fd0 100644 --- a/sdk/sourcefiles/internal/ANGlobal.h +++ b/sdk/sourcefiles/internal/ANGlobal.h @@ -26,7 +26,7 @@ #define AN_ERROR_TABLE @"errors" #define AN_DEFAULT_PLACEMENT_ID @"default_placement_id" -#define AN_SDK_VERSION @"7.8" +#define AN_SDK_VERSION @"7.9" #define APPNEXUS_BANNER_SIZE CGSizeMake(320, 50) @@ -112,7 +112,7 @@ BOOL ANAdvertisingTrackingEnabled(void); BOOL ANIsFirstLaunch(void); NSString * __nonnull ANUUID(void); -NSString *__nonnull ANAdvertisingIdentifier(void); +NSString *__nullable ANAdvertisingIdentifier(void); NSString *__nonnull ANErrorString( NSString * __nonnull key); NSError *__nonnull ANError(NSString *__nonnull key, NSInteger code, ...) NS_FORMAT_FUNCTION(1,3); @@ -129,7 +129,9 @@ CGRect ANPortraitScreenBoundsApplyingSafeAreaInsets(void); NSURLRequest * __nonnull ANBasicRequestWithURL(NSURL * __nonnull URL); NSNumber * __nullable ANiTunesIDForURL(NSURL * __nonnull URL); BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController); - +CGRect ANStatusBarFrame(void); +BOOL ANStatusBarHidden(void); +UIInterfaceOrientation ANStatusBarOrientation(void); #pragma mark - Global class. @@ -145,7 +147,7 @@ BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController + (ANAdType) adTypeStringToEnum:(nonnull NSString *)adTypeString; -+ (nonnull NSString *) getUserAgent; ++ (nonnull NSString *) userAgent; + (nonnull UIWindow *) getKeyWindow; diff --git a/sdk/sourcefiles/internal/ANGlobal.m b/sdk/sourcefiles/internal/ANGlobal.m index 6877930cb..99987967f 100644 --- a/sdk/sourcefiles/internal/ANGlobal.m +++ b/sdk/sourcefiles/internal/ANGlobal.m @@ -37,6 +37,9 @@ NSMutableURLRequest *utMutableRequest = nil; +NSString *anUserAgent = nil; +WKWebView *webViewForUserAgent = nil; + NSString *__nonnull ANDeviceModel() { @@ -77,7 +80,8 @@ BOOL ANIsFirstLaunch() return [[[NSUUID alloc] init] UUIDString]; } -NSString *__nonnull ANAdvertisingIdentifier() { +NSString *__nullable ANAdvertisingIdentifier() { + if (ANSDKSettings.sharedInstance.disableIDFAUsage) { return nil; } NSString *advertisingIdentifier = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]; if (advertisingIdentifier) { ANLogInfo(@"IDFA = %@", advertisingIdentifier); @@ -140,7 +144,7 @@ BOOL ANIsFirstLaunch() CGRect ANAdjustAbsoluteRectInWindowCoordinatesForOrientationGivenRect(CGRect rect) { // If portrait, no adjustment is necessary. - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) { + if (ANStatusBarOrientation() == UIInterfaceOrientationPortrait) { return rect; } @@ -155,7 +159,7 @@ CGRect ANAdjustAbsoluteRectInWindowCoordinatesForOrientationGivenRect(CGRect rec CGFloat flippedOriginY = screenBounds.size.width - (rect.origin.x + rect.size.width); CGRect adjustedRect; - switch ([UIApplication sharedApplication].statusBarOrientation) { + switch (ANStatusBarOrientation()) { case UIInterfaceOrientationLandscapeLeft: adjustedRect = CGRectMake(flippedOriginX, rect.origin.x, rect.size.height, rect.size.width); break; @@ -202,10 +206,10 @@ void ANPostNotifications(NSString * __nonnull name, id __nullable object, NSDict CGRect ANPortraitScreenBounds() { CGRect screenBounds = [UIScreen mainScreen].bounds; - if ([UIApplication sharedApplication].statusBarOrientation != UIInterfaceOrientationPortrait) { + if (ANStatusBarOrientation() != UIInterfaceOrientationPortrait) { if (!CGPointEqualToPoint(screenBounds.origin, CGPointZero) || screenBounds.size.width > screenBounds.size.height) { // need to orient screen bounds - switch ([UIApplication sharedApplication].statusBarOrientation) { + switch (ANStatusBarOrientation()) { case UIInterfaceOrientationLandscapeLeft: return CGRectMake(0, 0, screenBounds.size.height, screenBounds.size.width); break; @@ -233,10 +237,10 @@ CGRect ANPortraitScreenBoundsApplyingSafeAreaInsets() { CGFloat rightPadding = window.safeAreaInsets.right; screenBounds = CGRectMake(leftPadding, topPadding, screenBounds.size.width - (leftPadding + rightPadding), screenBounds.size.height - (topPadding + bottomPadding)); } - if ([UIApplication sharedApplication].statusBarOrientation != UIInterfaceOrientationPortrait) { + if (ANStatusBarOrientation() != UIInterfaceOrientationPortrait) { if (!CGPointEqualToPoint(screenBounds.origin, CGPointZero) || screenBounds.size.width > screenBounds.size.height) { // need to orient screen bounds - switch ([UIApplication sharedApplication].statusBarOrientation) { + switch (ANStatusBarOrientation()) { case UIInterfaceOrientationLandscapeLeft: return CGRectMake(0, 0, screenBounds.size.height, screenBounds.size.width); break; @@ -258,7 +262,7 @@ CGRect ANPortraitScreenBoundsApplyingSafeAreaInsets() { NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:kAppNexusRequestTimeoutInterval]; - [request setValue:[ANGlobal getUserAgent] forHTTPHeaderField:@"User-Agent"]; + [request setValue:[ANGlobal userAgent] forHTTPHeaderField:@"User-Agent"]; return [request copy]; } @@ -282,21 +286,44 @@ BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController return viewController.view.window != nil ? YES : NO; } +CGRect ANStatusBarFrame(){ + CGRect statusBarFrame; + if (@available(iOS 13.0, *)) { + statusBarFrame = [[[[ANGlobal getKeyWindow] windowScene] statusBarManager] statusBarFrame]; + }else { + statusBarFrame = [[UIApplication sharedApplication] statusBarFrame]; + } + return statusBarFrame; +} +BOOL ANStatusBarHidden(){ + BOOL statusBarHidden; + if (@available(iOS 13.0, *)) { + statusBarHidden = [[[[ANGlobal getKeyWindow] windowScene] statusBarManager] isStatusBarHidden]; + }else { + statusBarHidden = [UIApplication sharedApplication].statusBarHidden; + } + return statusBarHidden; +} + +UIInterfaceOrientation ANStatusBarOrientation() +{ + UIInterfaceOrientation statusBarOrientation; + if (@available(iOS 13.0, *)) { + statusBarOrientation = [[[ANGlobal getKeyWindow] windowScene] interfaceOrientation]; + }else { + statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation]; + } + return statusBarOrientation; +} @implementation ANGlobal -+ (void)load { - - // No need for "dispatch once" since `load` is called only once during app launch. - [ANGlobal getUserAgent]; - [self constructAdServerRequestURL]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUserAgentDidChangeNotification:) name:@"kUserAgentDidChangeNotification" object:nil]; - -} - +(nullable NSMutableURLRequest *) adServerRequestURL { + if(utMutableRequest == nil){ + [ANGlobal constructAdServerRequestURL]; + } return utMutableRequest; } @@ -312,7 +339,7 @@ + (void) constructAdServerRequestURL { } + (void)handleUserAgentDidChangeNotification:(NSNotification *)notification { - [utMutableRequest setValue:[ANGlobal getUserAgent] forHTTPHeaderField:@"user-agent"]; + [utMutableRequest setValue:[ANGlobal userAgent] forHTTPHeaderField:@"user-agent"]; [[NSNotificationCenter defaultCenter] removeObserver:@"kUserAgentDidChangeNotification"]; } @@ -327,7 +354,6 @@ + (void) openURL: (nonnull NSString *)urlString [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; } - #pragma mark - Custom keywords. // See also [AdSettings -setCustomKeywordsAsMapInEntryPoint:]. @@ -396,55 +422,62 @@ + (ANAdType) adTypeStringToEnum:(nonnull NSString *)adTypeString // -+ (nonnull NSString *) getUserAgent ++ (void) getUserAgent { - static NSString *userAgent = nil; static BOOL userAgentQueryIsActive = NO; - + // Return customUserAgent if provided NSString *customUserAgent = ANSDKSettings.sharedInstance.customUserAgent; if(customUserAgent && customUserAgent.length != 0){ ANLogDebug(@"userAgent=%@", customUserAgent); - return customUserAgent; + anUserAgent = customUserAgent; + } - - if (!userAgent) { + + if (!anUserAgent) { if (!userAgentQueryIsActive) { @synchronized (self) { userAgentQueryIsActive = YES; } - + dispatch_async(dispatch_get_main_queue(), - ^{ - WKWebView *webViewForUserAgent = [[WKWebView alloc] init]; - UIWindow *currentWindow = [ANGlobal getKeyWindow]; - - [webViewForUserAgent setHidden:YES]; - [currentWindow addSubview:webViewForUserAgent]; - + ^{ + webViewForUserAgent = [WKWebView new]; [webViewForUserAgent evaluateJavaScript: @"navigator.userAgent" completionHandler: ^(id __nullable userAgentString, NSError * __nullable error) - { - ANLogDebug(@"userAgentString=%@", userAgentString); - userAgent = userAgentString; - - - [webViewForUserAgent stopLoading]; - [webViewForUserAgent removeFromSuperview]; - - [[NSNotificationCenter defaultCenter] postNotificationName:@"kUserAgentDidChangeNotification" object:nil userInfo:nil]; - @synchronized (self) { - userAgentQueryIsActive = NO; - } - } ]; + { + if (error != nil) { + ANLogError(@"%@ error: %@", NSStringFromSelector(_cmd), error); + } else if ([userAgentString isKindOfClass:NSString.class]) { + ANLogDebug(@"userAgentString=%@", userAgentString); + anUserAgent = userAgentString; + [[NSNotificationCenter defaultCenter] postNotificationName:@"kUserAgentDidChangeNotification" object:nil userInfo:nil]; + @synchronized (self) { + userAgentQueryIsActive = NO; + + } + } + webViewForUserAgent = nil; + }]; + + }); + } + // + ANLogDebug(@"userAgent=%@", anUserAgent); + } - - // - ANLogDebug(@"userAgent=%@", userAgent); - return userAgent; +} + ++ (NSString *) userAgent { + if(anUserAgent == nil){ + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUserAgentDidChangeNotification:) name:@"kUserAgentDidChangeNotification" object:nil]; + + [ANGlobal getUserAgent]; + } + return anUserAgent; } #pragma mark - Get KeyWindow diff --git a/sdk/sourcefiles/internal/ANInterstitialAdViewController.m b/sdk/sourcefiles/internal/ANInterstitialAdViewController.m index 27db11f2d..82807f6dc 100644 --- a/sdk/sourcefiles/internal/ANInterstitialAdViewController.m +++ b/sdk/sourcefiles/internal/ANInterstitialAdViewController.m @@ -40,7 +40,7 @@ - (instancetype)init { } self = [super initWithNibName:NSStringFromClass([self class]) bundle:ANResourcesBundle()]; self.originalHiddenState = NO; - self.orientation = [[UIApplication sharedApplication] statusBarOrientation]; + self.orientation = ANStatusBarOrientation(); self.needCloseButton = YES; return self; } @@ -82,7 +82,7 @@ - (void)setupCloseButtonImageWithCustomClose:(BOOL)useCustomClose { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - self.originalHiddenState = [UIApplication sharedApplication].statusBarHidden; + self.originalHiddenState = ANStatusBarHidden(); } @@ -253,12 +253,12 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { if (self.orientationProperties) { switch (self.orientationProperties.forceOrientation) { case ANMRAIDOrientationPortrait: - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) { + if (ANStatusBarOrientation() == UIInterfaceOrientationPortraitUpsideDown) { return UIInterfaceOrientationPortraitUpsideDown; } return UIInterfaceOrientationPortrait; case ANMRAIDOrientationLandscape: - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { + if (ANStatusBarOrientation() == UIInterfaceOrientationLandscapeRight) { return UIInterfaceOrientationLandscapeRight; } return UIInterfaceOrientationLandscapeLeft; @@ -272,7 +272,7 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { - (void)viewWillLayoutSubviews { CGFloat buttonDistanceToSuperview; if ([self respondsToSelector:@selector(modalPresentationCapturesStatusBarAppearance)]) { - CGSize statusBarFrameSize = [[UIApplication sharedApplication] statusBarFrame].size; + CGSize statusBarFrameSize = ANStatusBarFrame().size; buttonDistanceToSuperview = statusBarFrameSize.height; if (statusBarFrameSize.height > statusBarFrameSize.width) { buttonDistanceToSuperview = statusBarFrameSize.width; @@ -306,7 +306,7 @@ - (void)setOrientationProperties:(ANMRAIDOrientationProperties *)orientationProp if ([self.view an_isViewable]) { if (orientationProperties.allowOrientationChange && orientationProperties.forceOrientation == ANMRAIDOrientationNone) { [UIViewController attemptRotationToDeviceOrientation]; - } else if ([UIApplication sharedApplication].statusBarOrientation != [self preferredInterfaceOrientationForPresentation]) { + } else if (ANStatusBarOrientation() != [self preferredInterfaceOrientationForPresentation]) { [self.delegate dismissAndPresentAgainForPreferredInterfaceOrientationChange]; } } diff --git a/sdk/sourcefiles/internal/ANMediationAdViewController.m b/sdk/sourcefiles/internal/ANMediationAdViewController.m index 73538aa4f..788b5a695 100644 --- a/sdk/sourcefiles/internal/ANMediationAdViewController.m +++ b/sdk/sourcefiles/internal/ANMediationAdViewController.m @@ -190,7 +190,10 @@ - (BOOL)requestAd:(CGSize)size targetingParameters.externalUid = adView.externalUid; targetingParameters.gender = adView.gender; targetingParameters.location = adView.location; - targetingParameters.idforadvertising = ANAdvertisingIdentifier(); + NSString *idfa = ANAdvertisingIdentifier(); + if(idfa){ + targetingParameters.idforadvertising = idfa; + } // if ([adView isKindOfClass:[ANBannerAdView class]]) { @@ -349,6 +352,8 @@ - (void)didReceiveAd:(id)adObject containerView.controller = self; adObject = containerView; } + //fire impressionURLS much earlier in the lifecycle + [self.adFetcher fireImpressionTrackersEarly:self.mediatedAd]; [self finish:ANAdResponseCode.SUCCESS withAdObject:adObject]; diff --git a/sdk/sourcefiles/internal/ANSSMMediationAdViewController.m b/sdk/sourcefiles/internal/ANSSMMediationAdViewController.m index 5eb1a6dcc..be9539320 100644 --- a/sdk/sourcefiles/internal/ANSSMMediationAdViewController.m +++ b/sdk/sourcefiles/internal/ANSSMMediationAdViewController.m @@ -176,6 +176,9 @@ - (void)didReceiveAd:(NSString *)adContent // Allow ANJAM events to always be passed to the ANAdView self.ssmAdView.webViewController.adViewANJAMInternalDelegate = self.adViewDelegate; + //fire impressionURLS much earlier in the lifecycle + [self.adFetcher fireImpressionTrackersEarly:self.ssmMediatedAd]; + } - (void)didFailToReceiveAd:(ANAdResponseCode *)errorCode { diff --git a/sdk/sourcefiles/internal/ANUniversalAdFetcher.h b/sdk/sourcefiles/internal/ANUniversalAdFetcher.h index 841f7ba3d..42c71d098 100644 --- a/sdk/sourcefiles/internal/ANUniversalAdFetcher.h +++ b/sdk/sourcefiles/internal/ANUniversalAdFetcher.h @@ -50,6 +50,9 @@ - (BOOL)allocateAndSetWebviewFromCachedAdObjectHandler; +// fire impression trackers if the publisher wants to fire them early in the lifecycle +- (void) fireImpressionTrackersEarly:(nonnull ANBaseAdObject *) ad; + @end diff --git a/sdk/sourcefiles/internal/ANUniversalAdFetcher.m b/sdk/sourcefiles/internal/ANUniversalAdFetcher.m index ebb865551..ec186d23c 100644 --- a/sdk/sourcefiles/internal/ANUniversalAdFetcher.m +++ b/sdk/sourcefiles/internal/ANUniversalAdFetcher.m @@ -354,6 +354,9 @@ - (void)handleStandardAd:(ANStandardAd *)standardAd if (!returnValue) { ANLogError(@"FAILED to allocate self.adView."); + } else { + [self fireImpressionTrackersEarly:standardAd]; + } } @@ -418,6 +421,17 @@ -(void) renderNativeAd:(ANBaseAdObject *)nativeRenderingElement { self.nativeAdView.loadingDelegate = self; } +- (void) fireImpressionTrackersEarly:(ANBaseAdObject *) ad { + //fire the impression tracker earlier in the lifecycle. immediatley after creating the webView. + BOOL countImpressionOnAdReceived = [self.delegate respondsToSelector:@selector(valueOfCountImpressionOnAdReceived)] && [self.delegate valueOfCountImpressionOnAdReceived]; + if(countImpressionOnAdReceived){ + ANLogDebug(@"Impression URL fired when we have a valid ad & the view is created"); + [ANTrackerManager fireTrackerURLArray:ad.impressionUrls withBlock:nil]; + ad.impressionUrls = nil; + + } +} + - (void) didFailToLoadNativeWebViewController{ if ([self.adObjectHandler isKindOfClass:[ANNativeStandardAdResponse class]]) { diff --git a/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m b/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m index 9a2164252..ce2bb8062 100644 --- a/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m +++ b/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m @@ -253,7 +253,7 @@ - (NSDictionary *)requestBody requestDict[@"sdk"] = sdk; } - requestDict[@"sdkver"] = AN_SDK_VERSION; //LEGACY. Replaced by sdk object. + requestDict[@"sdkver"] = [[ANSDKSettings sharedInstance] sdkVersion]; //LEGACY. Replaced by sdk object. requestDict[@"supply_type"] = @"mobile_app"; @@ -581,7 +581,7 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ // - NSString *userAgent = [ANGlobal getUserAgent]; + NSString *userAgent = [ANGlobal userAgent]; if (userAgent) { deviceDict[@"useragent"] = userAgent; } @@ -777,7 +777,7 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ - (NSDictionary *)sdk { return @{ @"source" : @"ansdk", - @"version" : AN_SDK_VERSION + @"version" : [[ANSDKSettings sharedInstance] sdkVersion] }; } diff --git a/sdk/sourcefiles/internal/ANVideoPlayerSettings.m b/sdk/sourcefiles/internal/ANVideoPlayerSettings.m index 6aba8746a..b8c686e54 100644 --- a/sdk/sourcefiles/internal/ANVideoPlayerSettings.m +++ b/sdk/sourcefiles/internal/ANVideoPlayerSettings.m @@ -17,6 +17,7 @@ #import "ANGlobal.h" #import "ANOMIDImplementation.h" #import "ANVideoPlayerSettings+ANCategory.h" +#import "ANSDKSettings.h" NSString * const ANName = @"name"; NSString * const ANVersion = @"version"; @@ -61,7 +62,7 @@ + (nonnull instancetype)sharedInstance { videoSettings.showFullScreenControl = YES; videoSettings.initalAudio = Default; videoSettings.optionsDictionary = [[NSMutableDictionary alloc] init]; - NSDictionary *partner = @{ ANName : AN_OMIDSDK_PARTNER_NAME , ANVersion : AN_SDK_VERSION}; + NSDictionary *partner = @{ ANName : AN_OMIDSDK_PARTNER_NAME , ANVersion : [[ANSDKSettings sharedInstance] sdkVersion]}; [videoSettings.optionsDictionary setObject:partner forKey:ANPartner]; [videoSettings.optionsDictionary setObject:ANInstreamVideo forKey:ANEntry]; videoSettings.showAdText = YES; diff --git a/sdk/sourcefiles/internal/ANWebView.m b/sdk/sourcefiles/internal/ANWebView.m index a805049a5..5509fc660 100644 --- a/sdk/sourcefiles/internal/ANWebView.m +++ b/sdk/sourcefiles/internal/ANWebView.m @@ -161,15 +161,27 @@ + (void) addDefaultWebViewConfiguration // video always loads in full-screen. // See: https://bugs.webkit.org/show_bug.cgi?id=147512 if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { - configuration.requiresUserActionForMediaPlayback = NO; + if (@available(iOS 10.0, *)) { + configuration.mediaTypesRequiringUserActionForPlayback = NO; + }else { + configuration.requiresUserActionForMediaPlayback = NO; + } } else { if ( [[NSProcessInfo processInfo] respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)] && [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10,0,0}] ) { - configuration.requiresUserActionForMediaPlayback = NO; + if (@available(iOS 10.0, *)) { + configuration.mediaTypesRequiringUserActionForPlayback = NO; + }else { + configuration.requiresUserActionForMediaPlayback = NO; + } } else { - configuration.requiresUserActionForMediaPlayback = YES; + if (@available(iOS 10.0, *)) { + configuration.mediaTypesRequiringUserActionForPlayback = YES; + }else { + configuration.requiresUserActionForMediaPlayback = YES; + } } } diff --git a/sdk/sourcefiles/internal/MRAID/ANMRAIDExpandViewController.m b/sdk/sourcefiles/internal/MRAID/ANMRAIDExpandViewController.m index 666381367..a4120f758 100644 --- a/sdk/sourcefiles/internal/MRAID/ANMRAIDExpandViewController.m +++ b/sdk/sourcefiles/internal/MRAID/ANMRAIDExpandViewController.m @@ -147,17 +147,17 @@ - (NSUInteger)supportedInterfaceOrientations { - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { switch (self.orientationProperties.forceOrientation) { case ANMRAIDOrientationPortrait: - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) { + if (ANStatusBarOrientation() == UIInterfaceOrientationPortraitUpsideDown) { return UIInterfaceOrientationPortraitUpsideDown; } return UIInterfaceOrientationPortrait; case ANMRAIDOrientationLandscape: - if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { + if (ANStatusBarOrientation() == UIInterfaceOrientationLandscapeRight) { return UIInterfaceOrientationLandscapeRight; } return UIInterfaceOrientationLandscapeLeft; default: { - UIInterfaceOrientation currentOrientation = [UIApplication sharedApplication].statusBarOrientation; + UIInterfaceOrientation currentOrientation = ANStatusBarOrientation(); return currentOrientation; } } @@ -166,7 +166,7 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (![self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { - self.originalStatusBarHiddenState = [UIApplication sharedApplication].statusBarHidden; + self.originalStatusBarHiddenState = ANStatusBarHidden(); } } diff --git a/sdk/sourcefiles/internal/MRAID/ANMRAIDResizeViewManager.m b/sdk/sourcefiles/internal/MRAID/ANMRAIDResizeViewManager.m index c88c4d565..fb1623c2d 100644 --- a/sdk/sourcefiles/internal/MRAID/ANMRAIDResizeViewManager.m +++ b/sdk/sourcefiles/internal/MRAID/ANMRAIDResizeViewManager.m @@ -17,6 +17,7 @@ #import "ANLogging.h" #import "UIView+ANCategory.h" #import "ANMRAIDResizeView.h" +#import "ANGlobal.h" @interface ANMRAIDResizeViewManager () @@ -188,7 +189,7 @@ - (void)didMoveAnchorViewToWindow { - (CGAffineTransform)transformForOrientation { CGFloat radians = 0; - switch ([UIApplication sharedApplication].statusBarOrientation) { + switch (ANStatusBarOrientation()) { case UIInterfaceOrientationLandscapeLeft: radians = -(CGFloat)M_PI_2; break; @@ -235,4 +236,4 @@ - (void)dealloc { [self detachResizeView]; } -@end \ No newline at end of file +@end diff --git a/sdk/sourcefiles/internal/MRAID/ANMRAIDUtil.m b/sdk/sourcefiles/internal/MRAID/ANMRAIDUtil.m index d9f656a43..db138e76e 100644 --- a/sdk/sourcefiles/internal/MRAID/ANMRAIDUtil.m +++ b/sdk/sourcefiles/internal/MRAID/ANMRAIDUtil.m @@ -133,7 +133,7 @@ + (ANMRAIDOrientation)orientationFromForceOrientationString:(NSString *)orientat } + (CGSize)screenSize { - BOOL orientationIsPortrait = UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]); + BOOL orientationIsPortrait = UIInterfaceOrientationIsPortrait(ANStatusBarOrientation()); CGSize screenSize = ANPortraitScreenBounds().size; int orientedWidth = orientationIsPortrait ? screenSize.width : screenSize.height; int orientedHeight = orientationIsPortrait ? screenSize.height : screenSize.width; @@ -141,7 +141,7 @@ + (CGSize)screenSize { } + (CGSize)maxSizeSafeArea { - BOOL orientationIsPortrait = UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]); + BOOL orientationIsPortrait = UIInterfaceOrientationIsPortrait(ANStatusBarOrientation()); CGSize screenSize = ANPortraitScreenBoundsApplyingSafeAreaInsets().size; int orientedWidth = orientationIsPortrait ? screenSize.width : screenSize.height; int orientedHeight = orientationIsPortrait ? screenSize.height : screenSize.width; diff --git a/sdk/sourcefiles/internal/config/ANSDKSettings.m b/sdk/sourcefiles/internal/config/ANSDKSettings.m index df586c91a..9376d429e 100644 --- a/sdk/sourcefiles/internal/config/ANSDKSettings.m +++ b/sdk/sourcefiles/internal/config/ANSDKSettings.m @@ -100,6 +100,7 @@ + (id)sharedInstance { sdkSettings.locationEnabledForCreative = YES; sdkSettings.enableOpenMeasurement = YES; sdkSettings.enableTestMode = NO; + sdkSettings.disableIDFAUsage = NO; sdkSettings.auctionTimeout = 0; sdkSettings.nativeAdAboutToExpireInterval = kAppNexusNativeAdAboutToExpireInterval; }); @@ -107,6 +108,15 @@ + (id)sharedInstance { } - (NSString *)sdkVersion{ + NSDictionary *sdkPlist = [NSDictionary dictionaryWithContentsOfFile:ANPathForANResource(@"SDK-Info", @"plist")]; + //if Cocoapods + if([sdkPlist[@"CFBundleIdentifier"] isEqualToString:@"corp.appnexus.AppNexusSDK"]){ + return sdkPlist[@"CFBundleShortVersionString"]; + } + // If Source code or Dynamic Framework + else if([[[NSBundle bundleForClass: [self class]] bundleIdentifier] isEqualToString:@"corp.appnexus.AppNexusSDK"]){ + return [[[NSBundle bundleForClass: [self class]] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; + } return AN_SDK_VERSION; } @@ -128,6 +138,7 @@ - (void) optionalSDKInitialization { [[ANReachability sharedReachabilityForInternetConnection] start]; [ANCarrierObserver shared]; + [ANGlobal adServerRequestURL]; [ANWebView prepareWebView]; } diff --git a/sdk/sourcefiles/native/internal/ANNativeMediatedAdController.m b/sdk/sourcefiles/native/internal/ANNativeMediatedAdController.m index cecd877d6..9a9457514 100644 --- a/sdk/sourcefiles/native/internal/ANNativeMediatedAdController.m +++ b/sdk/sourcefiles/native/internal/ANNativeMediatedAdController.m @@ -173,7 +173,11 @@ - (ANTargetingParameters *)targetingParameters targetingParameters.gender = self.adRequestDelegate.gender; targetingParameters.externalUid = self.adRequestDelegate.externalUid; targetingParameters.location = self.adRequestDelegate.location; - targetingParameters.idforadvertising = ANAdvertisingIdentifier(); + NSString *idfa = ANAdvertisingIdentifier(); + if(idfa){ + targetingParameters.idforadvertising = idfa; + } + return targetingParameters; } diff --git a/tests/UnitTestApp/FunctionalTests/ANAdResponseTestCase.m b/tests/UnitTestApp/FunctionalTests/ANAdResponseTestCase.m index 628eb5337..0f06334d7 100644 --- a/tests/UnitTestApp/FunctionalTests/ANAdResponseTestCase.m +++ b/tests/UnitTestApp/FunctionalTests/ANAdResponseTestCase.m @@ -179,27 +179,6 @@ - (void)testAdResponseWithRTBBannerAdFailToLoadAd { } - -- (void)testAdResponseWithCSMBannerAd { - - [self setupBannerAd]; - [self stubRequestWithResponse:@"ANAdResponseCSM_Banner"]; - [self.banner loadAd]; - - self.loadAdResponseReceivedExpectation = [self expectationWithDescription:@"Waiting for adDidReceiveAd to be received"]; - [self waitForExpectationsWithTimeout:2 * kAppNexusRequestTimeoutInterval - handler:^(NSError *error) { - - }]; - XCTAssertEqualObjects(self.banner.adResponseInfo.creativeId, @"187027997"); - XCTAssertEqualObjects(self.banner.adResponseInfo.placementId, @"17432496"); - XCTAssertTrue(self.banner.adResponseInfo.memberId == 958); - XCTAssertTrue(self.banner.adResponseInfo.adType == ANAdTypeBanner); - XCTAssertEqualObjects(self.banner.adResponseInfo.contentSource, @"csm"); - XCTAssertEqualObjects(self.banner.adResponseInfo.networkName, @"ANAdAdapterBannerDFP"); - XCTAssertEqualObjects(self.banner.adResponseInfo.auctionId, @"8250270890488509817"); -} - - (void)testAdResponseWithCSMBannerAdFailToLoadAd { [self setupBannerAd]; diff --git a/tests/UnitTestApp/FunctionalTests/ANBannerNativeRenderingOMIDTrackingTestCase.m b/tests/UnitTestApp/FunctionalTests/ANBannerNativeRenderingOMIDTrackingTestCase.m index 0c2f2496f..ed27890dc 100644 --- a/tests/UnitTestApp/FunctionalTests/ANBannerNativeRenderingOMIDTrackingTestCase.m +++ b/tests/UnitTestApp/FunctionalTests/ANBannerNativeRenderingOMIDTrackingTestCase.m @@ -68,7 +68,7 @@ @implementation ANBannerNativeRenderingOMIDTrackingTestCase + (void)load { TESTTRACE(); - [ANGlobal getUserAgent]; + [ANGlobal userAgent]; [ANLogManager setANLogLevel:ANLogLevelAll]; } diff --git a/tests/UnitTestApp/FunctionalTests/ANJAMTestCase.m b/tests/UnitTestApp/FunctionalTests/ANJAMTestCase.m index 79cd35d23..36483ceb1 100644 --- a/tests/UnitTestApp/FunctionalTests/ANJAMTestCase.m +++ b/tests/UnitTestApp/FunctionalTests/ANJAMTestCase.m @@ -82,6 +82,7 @@ - (void)tearDown { for (UIView *additionalView in [[ANGlobal getKeyWindow].rootViewController.view subviews]){ [additionalView removeFromSuperview]; } + ANSDKSettings.sharedInstance.disableIDFAUsage = NO; } @@ -98,6 +99,27 @@ - (void)testANJAMDeviceIDResponse { } +- (void)testANJAMDeviceIDResponseDisableIDFAUsageToYes { + ANSDKSettings.sharedInstance.disableIDFAUsage = YES; + [self stubRequestWithResponse:@"ANJAMDeviceIdResponse"]; + self.deviceIdExpectation = [self expectationWithDescription:@"Waiting for app event to be received."]; + [self.adView loadAd]; + [self waitForExpectationsWithTimeout:3 * kAppNexusRequestTimeoutInterval handler:nil]; + self.deviceIdExpectation = nil; + [self tearDown]; +} + +- (void)testANJAMDeviceIDResponseDisableIDFAUsageToNo { + ANSDKSettings.sharedInstance.disableIDFAUsage = NO; + [self stubRequestWithResponse:@"ANJAMDeviceIdResponse"]; + self.deviceIdExpectation = [self expectationWithDescription:@"Waiting for app event to be received."]; + [self.adView loadAd]; + [self waitForExpectationsWithTimeout:3 * kAppNexusRequestTimeoutInterval handler:nil]; + self.deviceIdExpectation = nil; + [self tearDown]; +} + + - (void)testANJAMDispatchAppEvent { [self stubRequestWithResponse:@"ANJAMDispatchAppEventResponse"]; self.dispatchAppEventExpectation = [self expectationWithDescription:@"Waiting for app event to be received."]; @@ -183,7 +205,8 @@ - (void) ad: (id)ad TESTTRACE(); if ([name isEqualToString:@"idfa"]) { XCTAssertNotNil(data); - NSString *advertisingIdentifier = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]; + NSString *advertisingIdentifier = !ANSDKSettings.sharedInstance.disableIDFAUsage ? ([[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]) : @""; + XCTAssertEqualObjects(data, advertisingIdentifier); [self.deviceIdExpectation fulfill]; diff --git a/tests/UnitTestApp/FunctionalTests/ANMRAIDTests.m b/tests/UnitTestApp/FunctionalTests/ANMRAIDTests.m index 6540b3da6..a9ee86efa 100644 --- a/tests/UnitTestApp/FunctionalTests/ANMRAIDTests.m +++ b/tests/UnitTestApp/FunctionalTests/ANMRAIDTests.m @@ -130,12 +130,12 @@ - (void)testBasicViewability { // MS-453 #pragma mark - mraid.setOrientationProperties() - (void)testForceOrientationLandscapeFromPortrait { // MS-481 - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait, @"Expected portrait orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationPortrait, @"Expected portrait orientation"); [self addBasicMRAIDBannerWithSelectorName:NSStringFromSelector(_cmd)]; [self setOrientationPropertiesWithAllowOrientationChange:NO forceOrientation:@"landscape"]; [self expand]; - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft, @"Expected landscape left orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationLandscapeLeft, @"Expected landscape left orientation"); [self close]; [self clearTest]; @@ -143,12 +143,12 @@ - (void)testForceOrientationLandscapeFromPortrait { // MS-481 - (void)testForceOrientationPortraitFromLandscape { // MS-481 [self rotateDeviceToOrientation:UIInterfaceOrientationLandscapeRight]; - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight, @"Expected landscape right orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationLandscapeRight, @"Expected landscape right orientation"); [self addBasicMRAIDBannerWithSelectorName:NSStringFromSelector(_cmd)]; [self setOrientationPropertiesWithAllowOrientationChange:NO forceOrientation:@"portrait"]; [self expand]; - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait, @"Expected portrait orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationPortrait, @"Expected portrait orientation"); [self close]; [self clearTest]; @@ -159,10 +159,10 @@ - (void)testForceOrientationLandscapeFromLandscapeRight { // MS-481 [self addBasicMRAIDBannerWithSelectorName:NSStringFromSelector(_cmd)]; [self setOrientationPropertiesWithAllowOrientationChange:NO forceOrientation:@"landscape"]; [self expand]; - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight, @"Expected landscape right orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationLandscapeRight, @"Expected landscape right orientation"); [self close]; - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight, @"Expected landscape right orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationLandscapeRight, @"Expected landscape right orientation"); [self clearTest]; } @@ -197,11 +197,11 @@ - (void)testExpandFromPortraitUpsideDown { // MS-510 [self rotateDeviceToOrientation:UIInterfaceOrientationPortraitUpsideDown]; [self addBasicMRAIDBannerWithSelectorName:NSStringFromSelector(_cmd)]; [self expand]; - XCTAssertFalse([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait, @"Did not expect portrait right side up orientation"); - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown, @"Expected portrait upside down orientation"); + XCTAssertFalse(ANStatusBarOrientation() == UIInterfaceOrientationPortrait, @"Did not expect portrait right side up orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationPortraitUpsideDown, @"Expected portrait upside down orientation"); [self close]; - XCTAssertTrue([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown, @"Expected portrait upside down orientation"); + XCTAssertTrue(ANStatusBarOrientation() == UIInterfaceOrientationPortraitUpsideDown, @"Expected portrait upside down orientation"); } @@ -301,8 +301,8 @@ - (void)testMaxSizePortraitOnLoad { CGFloat expectedWidth = screenBounds.size.width; CGFloat expectedHeight = [self eliminatePortraitSafeAreaInsets:screenBounds.size.height]; - if (![UIApplication sharedApplication].statusBarHidden) { - expectedHeight -= [UIApplication sharedApplication].statusBarFrame.size.height; + if (!ANStatusBarHidden()) { + expectedHeight -= ANStatusBarFrame().size.height; } XCTAssertTrue(expectedWidth == width && expectedHeight == height, @"Expected portrait max size %f x %f, received %f x %f", expectedWidth, expectedHeight, width, height); @@ -320,8 +320,8 @@ - (void)testMaxSizeLandscapeOnLoad { CGFloat expectedWidth = [self eliminateLandscapeSafeAreaInsets:screenBounds.size.height]; CGFloat expectedHeight = [self eliminatePortraitSafeAreaInsets:screenBounds.size.width]; - if (![UIApplication sharedApplication].statusBarHidden) { - expectedHeight -= [UIApplication sharedApplication].statusBarFrame.size.width; + if (!ANStatusBarHidden()) { + expectedHeight -= ANStatusBarFrame().size.width; } XCTAssertTrue(expectedWidth == width && expectedHeight == height, @"Expected landscape max size %f x %f, received %f x %f", expectedWidth, expectedHeight, width, height); @@ -330,7 +330,7 @@ - (void)testMaxSizeLandscapeOnLoad { - (void)testMaxSizeLandscapeOnRotate { [self addBasicMRAIDBannerWithSelectorName:NSStringFromSelector(_cmd)]; - XCTAssertTrue(UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation), @"Expected to start in portrait orientation"); + XCTAssertTrue(UIInterfaceOrientationIsPortrait(ANStatusBarOrientation()), @"Expected to start in portrait orientation"); [self rotateDeviceToOrientation:UIInterfaceOrientationLandscapeRight]; CGPoint maxSize = [self getMaxSize]; @@ -340,8 +340,8 @@ - (void)testMaxSizeLandscapeOnRotate { CGFloat expectedWidth = [self eliminateLandscapeSafeAreaInsets:screenBounds.size.height]; CGFloat expectedHeight = [self eliminatePortraitSafeAreaInsets:screenBounds.size.width]; - if (![UIApplication sharedApplication].statusBarHidden) { - expectedHeight -= [UIApplication sharedApplication].statusBarFrame.size.width; + if (!ANStatusBarHidden()) { + expectedHeight -= ANStatusBarFrame().size.width; } XCTAssertTrue(expectedWidth == width && expectedHeight == height, @"Expected landscape max size %f x %f, received %f x %f", expectedWidth, expectedHeight, width, height); @@ -359,8 +359,8 @@ - (void)testMaxSizeLandscapeOnRotate { expectedWidth = [self eliminateLandscapeSafeAreaInsets:screenBounds.size.width]; expectedHeight = [self eliminatePortraitSafeAreaInsets:screenBounds.size.height]; - if (![UIApplication sharedApplication].statusBarHidden) { - expectedHeight -= [UIApplication sharedApplication].statusBarFrame.size.height; + if (!ANStatusBarHidden()) { + expectedHeight -= ANStatusBarFrame().size.height; } XCTAssertTrue(expectedWidth == width && expectedHeight == height, @"Expected portrait max size %f x %f, received %f x %f", expectedWidth, expectedHeight, width, height); @@ -1559,7 +1559,7 @@ - (void)clearTest [self removeBannerFromSuperview]; - if ([[UIApplication sharedApplication] statusBarOrientation] != UIInterfaceOrientationPortrait) { + if (ANStatusBarOrientation() != UIInterfaceOrientationPortrait) { [self rotateDeviceToOrientation:UIInterfaceOrientationPortrait]; } diff --git a/tests/UnitTestApp/FunctionalTests/ANNativeAdRequestTestCase.m b/tests/UnitTestApp/FunctionalTests/ANNativeAdRequestTestCase.m index 347baf06d..63438bd4e 100644 --- a/tests/UnitTestApp/FunctionalTests/ANNativeAdRequestTestCase.m +++ b/tests/UnitTestApp/FunctionalTests/ANNativeAdRequestTestCase.m @@ -64,6 +64,9 @@ - (void)setUp { [[ANHTTPStubbingManager sharedStubbingManager] enable]; [ANHTTPStubbingManager sharedStubbingManager].ignoreUnstubbedRequests = YES; [self setupRequestTracker]; + + self.adRequest = [[ANNativeAdRequest alloc] init]; + self.adRequest.delegate = self; } - (void)tearDown { @@ -108,11 +111,8 @@ - (void)requestLoaded:(NSNotification *)notification { - (void)testSetPlacementIdOnlyOnNative { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; - //self.requestExpectation = [self expectationWithDescription:@"request"]; [self.adRequest setPlacementId:@"1"]; [self.adRequest setExternalUid:@"AppNexus"]; @@ -138,8 +138,6 @@ - (void)testSetPlacementIdOnlyOnNative - (void)testSetForceCreativeIdOnlyOnNative { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; self.adRequest.forceCreativeId = 135482485; @@ -161,8 +159,6 @@ - (void)testSetForceCreativeIdOnlyOnNative - (void)testNativeRendererId { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"native_videoResponse"]; [self.adRequest setPlacementId:@"1"]; @@ -183,8 +179,6 @@ - (void)testNativeRendererId } - (void)testNativeVideoObject { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"native_videoResponse"]; [self.adRequest loadAd]; @@ -204,6 +198,7 @@ - (void)testNativeVideoObject { - (void)testTrafficSourceCodeAndExtInvCodeSet { + [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest setInventoryCode:@"test" memberId:2]; [self.adRequest setExtInvCode:@"Xandr-ext_inv_code"]; @@ -249,6 +244,7 @@ - (void)testExtInvCode { - (void)testTrafficSourceCode { + [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest setInventoryCode:@"test" memberId:2]; [self.adRequest setTrafficSourceCode:@"Xandr-traffic_source_code"]; @@ -274,6 +270,7 @@ - (void)testTrafficSourceCode { - (void)testTrafficSourceCodeAndExtInvCodeNotSet { + [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest setInventoryCode:@"test" memberId:2]; @@ -294,8 +291,7 @@ - (void)testTrafficSourceCodeAndExtInvCodeNotSet { - (void)testSetInventoryCodeAndMemberIdOnlyOnNative { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest setInventoryCode:@"test" memberId:2]; @@ -323,8 +319,7 @@ - (void)testSetInventoryCodeAndMemberIdOnlyOnNative { } - (void)testSetBothInventoryCodeAndPlacementIdOnNative { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest setInventoryCode:@"test" memberId:2]; @@ -357,8 +352,7 @@ - (void)testSetBothInventoryCodeAndPlacementIdOnNative { } - (void)testAppNexusWithMainImageLoad { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest loadAd]; @@ -377,8 +371,7 @@ - (void)testAppNexusWithMainImageLoad { } - (void)testAppNexusWithAdditionalDescription { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; [self.adRequest loadAd]; @@ -393,8 +386,7 @@ - (void)testAppNexusWithAdditionalDescription { } - (void)testFacebook { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"facebook_mediated_response"]; [self.adRequest loadAd]; @@ -413,8 +405,7 @@ - (void)testFacebook { } - (void)testFacebookWithIconImageLoad { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"facebook_mediated_response"]; [self.adRequest loadAd]; @@ -434,8 +425,7 @@ - (void)testFacebookWithIconImageLoad { } - (void)testInvalidMediationAdapter { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"custom_adapter_mediated_response"]; [self.adRequest loadAd]; @@ -447,8 +437,7 @@ - (void)testInvalidMediationAdapter { } - (void)testWaterfallMediationAdapterEndingInFacebook { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"custom_adapter_fb_mediated_response"]; [self.adRequest loadAd]; @@ -466,8 +455,7 @@ - (void)testWaterfallMediationAdapterEndingInFacebook { } - (void)testNoResponse { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"empty_response"]; [self.adRequest loadAd]; @@ -479,8 +467,7 @@ - (void)testNoResponse { } - (void)testCustomAdapterFailToStandardResponse { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"custom_adapter_to_standard_response"]; [self.adRequest loadAd]; @@ -497,8 +484,7 @@ - (void)testCustomAdapterFailToStandardResponse { } - (void)testMediatedResponseInvalidType { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"custom_adapter_invalid_type"]; [self.adRequest loadAd]; @@ -510,8 +496,7 @@ - (void)testMediatedResponseInvalidType { } - (void)testSuccessfulResponseWithNoAds { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"no_ads_ok_response"]; [self.adRequest loadAd]; @@ -523,8 +508,7 @@ - (void)testSuccessfulResponseWithNoAds { } - (void)testMediatedResponseEmptyMediatedAd { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; + [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"empty_mediated_ad_response"]; [self.adRequest loadAd]; @@ -537,8 +521,6 @@ - (void)testMediatedResponseEmptyMediatedAd { - (void)testBackgroundLoadVersusForegroundNotification { - self.adRequest = [[ANNativeAdRequest alloc] init]; - self.adRequest.delegate = self; [self.adRequest getIncrementCountEnabledOrIfSet:YES thenValue:NO]; [self stubRequestWithResponse:@"appnexus_standard_response"]; @@ -635,9 +617,7 @@ - (void)loadNativeAdRequest{ - (void)testNativeAdWillExpireWithSettingAboutToExpireTimeIntervalGreaterThanUpperValue{ [self stubRequestWithResponse:@"appnexus_standard_response"]; - self.adRequest= [[ANNativeAdRequest alloc] init]; [self.adRequest setPlacementId:@"1"]; - self.adRequest.delegate = self; [ANSDKSettings sharedInstance].nativeAdAboutToExpireInterval = 22000; [self.adRequest loadAd]; @@ -654,9 +634,7 @@ - (void)testNativeAdWillExpireWithoutSettingAboutToExpireTimeInterval { [self stubRequestWithResponse:@"appnexus_standard_response"]; [ANSDKSettings sharedInstance].nativeAdAboutToExpireInterval = 0; - self.adRequest= [[ANNativeAdRequest alloc] init]; [self.adRequest setPlacementId:@"1"]; - self.adRequest.delegate = self; [self.adRequest loadAd]; self.nativeAdWillExpireExpectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; [self waitForExpectationsWithTimeout:2 * kAppNexusRequestTimeoutInterval @@ -670,9 +648,7 @@ - (void)testNativeAdWillExpireWithoutSettingAboutToExpireTimeInterval { - (void)testNativeAdWillExpire { [self stubRequestWithResponse:@"appnexus_standard_response"]; - self.adRequest= [[ANNativeAdRequest alloc] init]; [self.adRequest setPlacementId:@"1"]; - self.adRequest.delegate = self; [ANSDKSettings sharedInstance].nativeAdAboutToExpireInterval = 30; [self.adRequest loadAd]; self.nativeAdWillExpireExpectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; diff --git a/tests/UnitTestApp/UnitTestApp.xcodeproj/project.pbxproj b/tests/UnitTestApp/UnitTestApp.xcodeproj/project.pbxproj index cea4c73a9..4cf0b11e0 100644 --- a/tests/UnitTestApp/UnitTestApp.xcodeproj/project.pbxproj +++ b/tests/UnitTestApp/UnitTestApp.xcodeproj/project.pbxproj @@ -106,14 +106,10 @@ 0E516FE9243E6F1500B5E744 /* ANNativeAdResponse+ANTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E516FE7243E6F1500B5E744 /* ANNativeAdResponse+ANTest.m */; }; 0E516FEF243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E516FED243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m */; }; 0E516FF0243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E516FED243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m */; }; - 0E516FF4243F9EDD00B5E744 /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E5529B92419228C00D50C51 /* FBAudienceNetwork.framework */; }; 0E516FF5243FA01200B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E516FED243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m */; }; 0E516FF6243FA05E00B5E744 /* TestANCSRUniversalFetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E9EBD6924336111001A30D8 /* TestANCSRUniversalFetcher.m */; }; 0E54523223336BC300C7EC93 /* ANReachability+ANTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E8C972B21FF32EB005D1F0E /* ANReachability+ANTest.m */; }; 0E5529AD2419201F00D50C51 /* ANCSRUniversalTagRequestBuilderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E5529AC2419201F00D50C51 /* ANCSRUniversalTagRequestBuilderTests.m */; }; - 0E5529BA2419228C00D50C51 /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E5529B92419228C00D50C51 /* FBAudienceNetwork.framework */; }; - 0E5529BD241925DB00D50C51 /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E5529B92419228C00D50C51 /* FBAudienceNetwork.framework */; }; - 0E5529BE241925DB00D50C51 /* FBAudienceNetwork.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0E5529B92419228C00D50C51 /* FBAudienceNetwork.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 0E56C6EF21F8AEF300ADE6E1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E56C6EE21F8AEF300ADE6E1 /* CoreGraphics.framework */; }; 0E56C6F121F8AEF800ADE6E1 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E56C6F021F8AEF800ADE6E1 /* AdSupport.framework */; }; 0E56C6F321F8AF0300ADE6E1 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E56C6F221F8AF0300ADE6E1 /* AudioToolbox.framework */; }; @@ -544,9 +540,12 @@ FC4E6F7224E9985F003F2381 /* SuccessfulSquareInstreamVideoAdResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 0E7BC1BB229E91E9002F41FF /* SuccessfulSquareInstreamVideoAdResponse.json */; }; FC4E6F7324E99939003F2381 /* OMID_VideoResponse.json in Resources */ = {isa = PBXBuildFile; fileRef = 9736FABA2354CF26008F6687 /* OMID_VideoResponse.json */; }; FC4E6F7424E99A9C003F2381 /* ANOMIDInstreamVideoTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 9736FAAB235492F7008F6687 /* ANOMIDInstreamVideoTestCase.m */; }; + FC871DA225BB038F003144BC /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FC871DA125BB038F003144BC /* FBAudienceNetwork.framework */; }; + FC871DA325BB038F003144BC /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FC871DA125BB038F003144BC /* FBAudienceNetwork.framework */; }; + FC871DA425BB038F003144BC /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FC871DA125BB038F003144BC /* FBAudienceNetwork.framework */; }; FCBF0CD624D1E3CC00EA4474 /* ANGlobal+ANTest.m in Sources */ = {isa = PBXBuildFile; fileRef = FCBF0CD524D1E3CC00EA4474 /* ANGlobal+ANTest.m */; }; - FCF5362024EEB3EA0058A3A2 /* ANPublicAPITrafficSourceCodeAndExtInvCode.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF5361E24EEB3EA0058A3A2 /* ANPublicAPITrafficSourceCodeAndExtInvCode.m */; }; FCE9649224EA5FBC002FA163 /* HTTPCookieTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EA5DE4B24BF1AE100614011 /* HTTPCookieTestCase.m */; }; + FCF5362024EEB3EA0058A3A2 /* ANPublicAPITrafficSourceCodeAndExtInvCode.m in Sources */ = {isa = PBXBuildFile; fileRef = FCF5361E24EEB3EA0058A3A2 /* ANPublicAPITrafficSourceCodeAndExtInvCode.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -616,7 +615,6 @@ dstSubfolderSpec = 10; files = ( 0E6B7E4922D8DE49005D069E /* AppNexusSDK.framework in Embed Frameworks */, - 0E5529BE241925DB00D50C51 /* FBAudienceNetwork.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -727,7 +725,6 @@ 0E516FEE243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANAdAdapterCSRNativeBannerFacebook.h; sourceTree = ""; }; 0E5529AC2419201F00D50C51 /* ANCSRUniversalTagRequestBuilderTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ANCSRUniversalTagRequestBuilderTests.m; sourceTree = ""; }; 0E5529B02419203400D50C51 /* ANCSRUniversalTagRequestBuilderTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ANCSRUniversalTagRequestBuilderTests.m; sourceTree = ""; }; - 0E5529B92419228C00D50C51 /* FBAudienceNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = FBAudienceNetwork.framework; sourceTree = ""; }; 0E56C6EE21F8AEF300ADE6E1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 0E56C6F021F8AEF800ADE6E1 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; 0E56C6F221F8AF0300ADE6E1 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; @@ -943,7 +940,6 @@ 0ED159F82236B82800D56022 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; 0ED15A192236BEA200D56022 /* CoreAudioKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudioKit.framework; path = System/Library/Frameworks/CoreAudioKit.framework; sourceTree = SDKROOT; }; 0ED15A1B2236BFC000D56022 /* BaseMediationSingleNetworkResponse.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BaseMediationSingleNetworkResponse.json; sourceTree = ""; }; - 0ED15A662236C5D300D56022 /* FBAudienceNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBAudienceNetwork.framework; path = ../../mediation/mediatedviews/Facebook/FacebookSDK/FBAudienceNetwork.framework; sourceTree = ""; }; 0ED15A702236C60B00D56022 /* MMAdSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MMAdSDK.framework; path = ../../mediation/mediatedviews/MillennialMedia/MillennialMediaSDK/MMAdSDK.framework; sourceTree = ""; }; 0ED15A742236C62200D56022 /* SCSCoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SCSCoreKit.framework; path = ../../mediation/mediatedviews/SmartAd/SmartAdSDK/SCSCoreKit.framework; sourceTree = ""; }; 0ED15A752236C62200D56022 /* SASDisplayKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SASDisplayKit.framework; path = ../../mediation/mediatedviews/SmartAd/SmartAdSDK/SASDisplayKit.framework; sourceTree = ""; }; @@ -1113,6 +1109,7 @@ FC4E6F2624E9779E003F2381 /* AppReleaseTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppReleaseTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; FC4E6F2824E9779E003F2381 /* ReleaseTestAppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReleaseTestAppTests.m; sourceTree = ""; }; FC4E6F2A24E9779E003F2381 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + FC871DA125BB038F003144BC /* FBAudienceNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBAudienceNetwork.framework; path = mediationsdk/FacebookSDK/FBAudienceNetwork.framework; sourceTree = SOURCE_ROOT; }; FCBF0CD524D1E3CC00EA4474 /* ANGlobal+ANTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "ANGlobal+ANTest.m"; sourceTree = ""; }; FCF5361E24EEB3EA0058A3A2 /* ANPublicAPITrafficSourceCodeAndExtInvCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ANPublicAPITrafficSourceCodeAndExtInvCode.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1149,12 +1146,12 @@ 0ED159F72236B82200D56022 /* CoreBluetooth.framework in Frameworks */, 0E56C6EF21F8AEF300ADE6E1 /* CoreGraphics.framework in Frameworks */, 0E56C6FB21F8AF1900ADE6E1 /* CoreLocation.framework in Frameworks */, + FC871DA225BB038F003144BC /* FBAudienceNetwork.framework in Frameworks */, 0ED159E12236B53B00D56022 /* CoreMedia.framework in Frameworks */, 0ED159E32236B54100D56022 /* CoreMotion.framework in Frameworks */, 0E56C6FD21F8AF1E00ADE6E1 /* CoreTelephony.framework in Frameworks */, 0ED159DB2236B52800D56022 /* EventKit.framework in Frameworks */, 0ED159DD2236B52C00D56022 /* EventKitUI.framework in Frameworks */, - 0E5529BD241925DB00D50C51 /* FBAudienceNetwork.framework in Frameworks */, 0E56C6FF21F8AF2200ADE6E1 /* Foundation.framework in Frameworks */, 0E56C70321F8AF2D00ADE6E1 /* GameKit.framework in Frameworks */, 0ED159F92236B82900D56022 /* GLKit.framework in Frameworks */, @@ -1183,8 +1180,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FC871DA325BB038F003144BC /* FBAudienceNetwork.framework in Frameworks */, 0E6B7E4722D8DE0B005D069E /* AppNexusSDK.framework in Frameworks */, - 0E516FF4243F9EDD00B5E744 /* FBAudienceNetwork.framework in Frameworks */, 0E8C97D121FF3342005D1F0E /* XCTest.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1193,8 +1190,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + FC871DA425BB038F003144BC /* FBAudienceNetwork.framework in Frameworks */, 0E6B7E4522D8DE01005D069E /* AppNexusSDK.framework in Frameworks */, - 0E5529BA2419228C00D50C51 /* FBAudienceNetwork.framework in Frameworks */, 0E56C83521F8B2A900ADE6E1 /* XCTest.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1332,7 +1329,6 @@ isa = PBXGroup; children = ( 0ED6434C243233F9006B2A2E /* csr */, - 0E5529B92419228C00D50C51 /* FBAudienceNetwork.framework */, ); name = FacebookSDK; path = mediationsdk/FacebookSDK; @@ -1358,7 +1354,6 @@ 0E56C6FC21F8AF1E00ADE6E1 /* CoreTelephony.framework */, 0ED159DA2236B52800D56022 /* EventKit.framework */, 0ED159DC2236B52C00D56022 /* EventKitUI.framework */, - 0ED15A662236C5D300D56022 /* FBAudienceNetwork.framework */, 0E56C6FE21F8AF2200ADE6E1 /* Foundation.framework */, 0E56C70221F8AF2D00ADE6E1 /* GameKit.framework */, 0ED159F82236B82800D56022 /* GLKit.framework */, @@ -1824,6 +1819,7 @@ 0ED6434D243233F9006B2A2E /* Facebook */ = { isa = PBXGroup; children = ( + FC871DA125BB038F003144BC /* FBAudienceNetwork.framework */, 0E516FEE243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.h */, 0E516FED243F9DCA00B5E744 /* ANAdAdapterCSRNativeBannerFacebook.m */, 0ED64351243233F9006B2A2E /* ANFBSettings.h */, @@ -3043,6 +3039,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = HR94J6TSB3; + EXCLUDED_ARCHS = arm64; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../sdk/sourcefiles/Viewability\""; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -3065,6 +3062,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NativeSDKTestApp.app/NativeSDKTestApp"; + VALIDATE_WORKSPACE = YES; }; name = Debug; }; @@ -3074,6 +3072,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = HR94J6TSB3; + EXCLUDED_ARCHS = arm64; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../sdk/sourcefiles/Viewability\""; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -3096,6 +3095,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NativeSDKTestApp.app/NativeSDKTestApp"; + VALIDATE_WORKSPACE = YES; }; name = Release; }; @@ -3384,6 +3384,7 @@ "\"$(SRCROOT)/../../sdk/sourcefiles/Viewability\"", "\"$(SRCROOT)/mediationsdk/FacebookSDK\"", "$(PROJECT_DIR)/mediationsdk/GoogleAdMobSDK", + "$(PROJECT_DIR)/mediationsdk/FacebookSDK", ); HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -3416,6 +3417,7 @@ "\"$(SRCROOT)/../../sdk/sourcefiles/Viewability\"", "\"$(SRCROOT)/mediationsdk/FacebookSDK\"", "$(PROJECT_DIR)/mediationsdk/GoogleAdMobSDK", + "$(PROJECT_DIR)/mediationsdk/FacebookSDK", ); HEADER_SEARCH_PATHS = ( "$(inherited)", diff --git a/tests/UnitTestApp/UnitTestApp/AppDelegate.m b/tests/UnitTestApp/UnitTestApp/AppDelegate.m index 7f93f5329..132461d38 100644 --- a/tests/UnitTestApp/UnitTestApp/AppDelegate.m +++ b/tests/UnitTestApp/UnitTestApp/AppDelegate.m @@ -27,7 +27,7 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [ANGlobal getUserAgent]; + [ANGlobal userAgent]; [ANLogManager setANLogLevel:ANLogLevelAll]; [[ANHTTPStubbingManager sharedStubbingManager] enable]; diff --git a/tests/UnitTestApp/UnitTests/ANUniversalAdFetcherTests.m b/tests/UnitTestApp/UnitTests/ANUniversalAdFetcherTests.m index 7ab909ae8..0947a9b78 100644 --- a/tests/UnitTestApp/UnitTests/ANUniversalAdFetcherTests.m +++ b/tests/UnitTestApp/UnitTests/ANUniversalAdFetcherTests.m @@ -53,6 +53,8 @@ @implementation ANUniversalAdFetcherTests @synthesize customKeywords; @synthesize externalUid; @synthesize publisherId; +@synthesize extInvCode; +@synthesize trafficSourceCode; diff --git a/tests/UnitTestApp/UnitTests/ANUniversalTagRequestBuilderTests.m b/tests/UnitTestApp/UnitTests/ANUniversalTagRequestBuilderTests.m index 14179bc05..5a1bae27d 100644 --- a/tests/UnitTestApp/UnitTests/ANUniversalTagRequestBuilderTests.m +++ b/tests/UnitTestApp/UnitTests/ANUniversalTagRequestBuilderTests.m @@ -49,6 +49,7 @@ - (void)setUp { - (void)tearDown { [super tearDown]; [ANGDPRSettings reset]; + [ANSDKSettings sharedInstance].disableIDFAUsage = NO; } @@ -645,4 +646,130 @@ - (void)testUTRequestWithContentURLCustomKeywordsValue [self waitForExpectationsWithTimeout:UTMODULETESTS_TIMEOUT handler:nil]; } +/** + API To verify : disableIDFAUsage + If disableIDFAUsage is set to default value(No) then the device_id should not be nil + */ +- (void)testUTRequestDisableIDFAUsageDefault +{ + + TestANUniversalFetcher *adFetcher = [[TestANUniversalFetcher alloc] initWithPlacementId:videoPlacementID]; + dispatch_queue_t backgroundQueue = dispatch_queue_create("QUEUE FOR testUTRequest.", DISPATCH_QUEUE_SERIAL); + + XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__]]; + + [ANGDPRSettings setPurposeConsents:@"1010"]; + + // + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), backgroundQueue, + ^{ + NSURLRequest *request = [ANUniversalTagRequestBuilder buildRequestWithAdFetcherDelegate:adFetcher.delegate]; + + NSError *error; + id jsonObject = [NSJSONSerialization JSONObjectWithData: request.HTTPBody + options: kNilOptions + error: &error]; + TESTTRACEM(@"jsonObject=%@", jsonObject); + + // JSON foundation. + XCTAssertNil(error); + XCTAssertNotNil(jsonObject); + XCTAssertTrue([jsonObject isKindOfClass:[NSDictionary class]]); + NSDictionary *jsonDict = (NSDictionary *)jsonObject; + NSDictionary *device = jsonDict[@"device"]; + XCTAssertNotNil(device); + // Device Id Start + NSDictionary *deviceId = device[@"device_id"]; + XCTAssertNotNil(deviceId); + + [expectation fulfill]; + }); + + // + [self waitForExpectationsWithTimeout:UTMODULETESTS_TIMEOUT handler:nil]; +} +/** + API To verify : disableIDFAUsage + If disableIDFAUsage is set to true then device_id should be nil + */ +- (void)testUTRequestDisableIDFAUsageSetToTrue +{ + [ANSDKSettings sharedInstance].disableIDFAUsage = YES; + + TestANUniversalFetcher *adFetcher = [[TestANUniversalFetcher alloc] initWithPlacementId:videoPlacementID]; + dispatch_queue_t backgroundQueue = dispatch_queue_create("QUEUE FOR testUTRequest.", DISPATCH_QUEUE_SERIAL); + + XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__]]; + + [ANGDPRSettings setPurposeConsents:@"1010"]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), backgroundQueue, + ^{ + NSURLRequest *request = [ANUniversalTagRequestBuilder buildRequestWithAdFetcherDelegate:adFetcher.delegate]; + + NSError *error; + id jsonObject = [NSJSONSerialization JSONObjectWithData: request.HTTPBody + options: kNilOptions + error: &error]; + TESTTRACEM(@"jsonObject=%@", jsonObject); + + // JSON foundation. + XCTAssertNil(error); + XCTAssertNotNil(jsonObject); + XCTAssertTrue([jsonObject isKindOfClass:[NSDictionary class]]); + NSDictionary *jsonDict = (NSDictionary *)jsonObject; + NSDictionary *device = jsonDict[@"device"]; + XCTAssertNotNil(device); + // Device Id Start + NSDictionary *deviceId = device[@"device_id"]; + XCTAssertNil(deviceId); + + [expectation fulfill]; + }); + + // + [self waitForExpectationsWithTimeout:UTMODULETESTS_TIMEOUT handler:nil]; +} + +/** + API To verify : disableIDFAUsage + If disableIDFAUsage is set to false then device_id should not be nil + */ +- (void)testUTRequestDisableIDFAUsageSetToFalse +{ + [ANSDKSettings sharedInstance].disableIDFAUsage = YES; + [ANSDKSettings sharedInstance].disableIDFAUsage = NO; + TestANUniversalFetcher *adFetcher = [[TestANUniversalFetcher alloc] initWithPlacementId:videoPlacementID]; + dispatch_queue_t backgroundQueue = dispatch_queue_create("QUEUE FOR testUTRequest.", DISPATCH_QUEUE_SERIAL); + + XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__]]; + + [ANGDPRSettings setPurposeConsents:@"1010"]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), backgroundQueue, + ^{ + NSURLRequest *request = [ANUniversalTagRequestBuilder buildRequestWithAdFetcherDelegate:adFetcher.delegate]; + + NSError *error; + id jsonObject = [NSJSONSerialization JSONObjectWithData: request.HTTPBody + options: kNilOptions + error: &error]; + TESTTRACEM(@"jsonObject=%@", jsonObject); + + // JSON foundation. + XCTAssertNil(error); + XCTAssertNotNil(jsonObject); + XCTAssertTrue([jsonObject isKindOfClass:[NSDictionary class]]); + NSDictionary *jsonDict = (NSDictionary *)jsonObject; + NSDictionary *device = jsonDict[@"device"]; + XCTAssertNotNil(device); + NSDictionary *deviceId = device[@"device_id"]; + XCTAssertNotNil(deviceId); + [expectation fulfill]; + }); + + [self waitForExpectationsWithTimeout:UTMODULETESTS_TIMEOUT handler:nil]; +} + + @end diff --git a/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork b/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork index 98728eb1d..c2afebad1 100755 Binary files a/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork and b/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/FBAudienceNetwork differ diff --git a/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/Headers/FBAudienceNetwork.h b/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/Headers/FBAudienceNetwork.h index 3d017cf24..17adc5d5f 100644 --- a/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/Headers/FBAudienceNetwork.h +++ b/tests/UnitTestApp/mediationsdk/FacebookSDK/FBAudienceNetwork.framework/Headers/FBAudienceNetwork.h @@ -58,4 +58,4 @@ // NOTE: Any changes should also be made to the module.modulemap // to ensure comptability with Swift apps using Cocoapods -#define FB_AD_SDK_VERSION @"6.2.0" +#define FB_AD_SDK_VERSION @"6.2.1"