From d175d220b8561d780db001bceedd92bc29bcc475 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Tue, 25 Oct 2022 19:02:41 +0000 Subject: [PATCH 1/6] MacOS SDK registerviewforTracking API Squashed commit of the following: commit 3998844f5b1691646fc4fd8f9b7c2227cb24aaeb Author: asharma Date: Wed Oct 12 01:55:03 2022 +0530 Added registerViewForTracking as NSView --- .../ViewController.swift | 3 ++- .../native/internal/ANNativeAdResponse.m | 19 +++++++++++++++++++ .../public-headers/ANNativeAdResponse.h | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/examples/Swift/SimpleIntegration/MacOSSimpleIntegrationSwift/ViewController.swift b/examples/Swift/SimpleIntegration/MacOSSimpleIntegrationSwift/ViewController.swift index 041dfd9c..15ddd3bc 100644 --- a/examples/Swift/SimpleIntegration/MacOSSimpleIntegrationSwift/ViewController.swift +++ b/examples/Swift/SimpleIntegration/MacOSSimpleIntegrationSwift/ViewController.swift @@ -145,7 +145,8 @@ extension ViewController: NSTableViewDelegate { do{ let rowView : NSTableRowView = tableView.rowView(atRow: row, makeIfNecessary: true)! - try self.nativeAdResponse?.registerView(forTracking: rowView, withRootViewController: self, clickableXandrNativeAdView: clickableViews) + try self.nativeAdResponse?.registerViewTracking(rowView, withRootViewController: self, clickableXandrNativeAdView: clickableViews) + } catch { print("Failed to registerView for Tracking") } diff --git a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m index 052ff034..0f54244b 100644 --- a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m +++ b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m @@ -203,6 +203,25 @@ - (BOOL)registerViewForTracking:(nonnull NSTableRowView *)view } return true; } + +- (BOOL)registerViewTracking:(nonnull NSView *)view + withRootViewController:(nonnull NSViewController *)rvc + clickableXandrNativeAdView:(nullable NSArray *)views + error:(NSError *__nullable*__nullable)error{ + + BOOL successfulResponseRegistration = [self registerViewForTracking:(XandrView *)view withRootViewController:(XandrViewController *)rvc clickableViews:nil error:error]; + + for(XandrNativeAdView *clickableView in views){ + [self registerClickView:clickableView]; + } + + if(!successfulResponseRegistration){ + ANLogError(@"Unable to register view for tracking"); + return false; + } + return true; +} + #endif diff --git a/sdk/sourcefiles/public-headers/ANNativeAdResponse.h b/sdk/sourcefiles/public-headers/ANNativeAdResponse.h index 33970adc..09ac27c2 100644 --- a/sdk/sourcefiles/public-headers/ANNativeAdResponse.h +++ b/sdk/sourcefiles/public-headers/ANNativeAdResponse.h @@ -240,6 +240,23 @@ extern NSString * __nonnull const kANNativeCSRObject; clickableXandrNativeAdView:(nullable NSArray *)views error:(NSError *__nullable*__nullable)error; + +/*! + * Should be called when the native view has been populated with the ad elements and will be displayed. + * it will be automatically detached from that response before being attached to this response. + * + * @param view The view which is populated with the native ad elements. Must not be nil and type NSView. + * @param rvc The root view controller which contains the view. Must not be nil. + * @param views Specifies XandrNativeAdView subviews which should be clickable, instead of the whole view (the default). May be nil. + * @note The response holds a strong reference to the registered view. + * @see ANNativeAdRegisterErrorCode in ANAdConstants.h for possible error code values. + */ +- (BOOL)registerViewTracking:(nonnull NSView *)view + withRootViewController:(nonnull NSViewController *)rvc + clickableXandrNativeAdView:(nullable NSArray *)views + error:(NSError *__nullable*__nullable)error; + + #endif From 8c2ca117b61a0b4165f2822a9e8907b88434dd89 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Tue, 25 Oct 2022 19:15:50 +0000 Subject: [PATCH 2/6] MS-5128 Refactor MacOS SDK code Squashed commit of the following: commit b8d659523ccdfb01da9c76ccb9c2bc13f6b20363 Merge: 666ba86fd d175d220b Author: asharma Date: Wed Oct 26 00:32:56 2022 +0530 Merge remote-tracking branch 'origin/develop' into macOSRefector commit 666ba86fd7dac9dde214b4bf0c10010ff3e2a1ce Author: asharma Date: Wed Oct 26 00:30:53 2022 +0530 IDFV comment commit 8ae568d0d982eb05893b0a8fcada79765bd257ea Author: asharma Date: Wed Oct 26 00:30:30 2022 +0530 Refector gestureRecognizer and iab_support commit 568e3a8401864c76a6cb01d665213281001afc94 Author: asharma Date: Tue Oct 25 22:54:44 2022 +0530 Fixed setupViewabilityTracker condition commit 3c87500d66c787e183c20e5746b5f45efd1fa116 Author: asharma Date: Tue Oct 25 22:17:23 2022 +0530 Added comments commit a9f7383b90b100b812953a3fe0746ff2924eb56f Author: asharma Date: Tue Oct 25 19:18:54 2022 +0530 Fixed detachAllGestureRecognizers for macOS commit 000939d74c22833f08cefd92fc3209f0a7f4096d Author: asharma Date: Tue Oct 25 16:47:00 2022 +0530 identifierForVendor comment added commit ecdc00282b63f879b05e0759be72c8ca48a26bc2 Author: asharma Date: Tue Oct 25 16:34:55 2022 +0530 Added fix for send 'euid' for MacOS commit 90e22bde8b484140a5fdcfa5acaea748b8f6fbed Author: asharma Date: Tue Oct 25 16:19:37 2022 +0530 Removed unused function commit a80eef3bda1abc1386ad1680587ea4a9b29734b9 Author: asharma Date: Fri Oct 21 01:03:26 2022 +0530 Removed unused files commit 4e50ca645268de258efc9edb4fb907589142856f Author: asharma Date: Tue Oct 18 14:48:43 2022 +0530 Fixed error with Unit testcase commit ee5cdb769872b46e4c09b954be7adac49722d35a Author: asharma Date: Sat Oct 15 02:41:31 2022 +0530 Reverted sample commit 286fec69a894137916d1aab95db1c4effb177a1e Author: asharma Date: Sat Oct 15 02:40:03 2022 +0530 macOSRefector --- sdk/AppNexusSDK.xcodeproj/project.pbxproj | 32 -- sdk/sourcefiles/Categories/XandrButton.h | 36 -- sdk/sourcefiles/Categories/XandrButton.m | 21 -- sdk/sourcefiles/Categories/XandrImage.m | 2 - sdk/sourcefiles/Categories/XandrView.h | 6 - .../Categories/XandrViewController.h | 8 - sdk/sourcefiles/internal/ANCarrierObserver.h | 2 + sdk/sourcefiles/internal/ANGlobal.h | 4 +- sdk/sourcefiles/internal/ANGlobal.m | 327 +++++++++--------- sdk/sourcefiles/internal/ANRealTimer.m | 1 - .../internal/ANUniversalTagRequestBuilder.m | 67 ++-- .../internal/config/ANSDKSettings.m | 1 + sdk/sourcefiles/macOS/NSView+ANCategory.h | 3 + sdk/sourcefiles/macOS/NSView+ANCategory.m | 10 +- .../macOS/NSView+ANNativeAdCategory.h | 30 -- .../macOS/NSView+ANNativeAdCategory.m | 36 -- .../macOS/NSView-UserInteraction.h | 31 -- .../macOS/NSView-UserInteraction.m | 54 --- .../ANNativeAdResponse+PrivateMethods.h | 2 +- .../native/internal/ANNativeAdResponse.m | 91 ++--- .../internal/ANNativeStandardAdResponse.m | 43 +-- .../public-headers/ANAdConstants.h | 1 + sdk/sourcefiles/public-headers/ANAdProtocol.h | 2 + 23 files changed, 282 insertions(+), 528 deletions(-) delete mode 100644 sdk/sourcefiles/Categories/XandrButton.h delete mode 100644 sdk/sourcefiles/Categories/XandrButton.m delete mode 100644 sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.h delete mode 100644 sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.m delete mode 100644 sdk/sourcefiles/macOS/NSView-UserInteraction.h delete mode 100644 sdk/sourcefiles/macOS/NSView-UserInteraction.m diff --git a/sdk/AppNexusSDK.xcodeproj/project.pbxproj b/sdk/AppNexusSDK.xcodeproj/project.pbxproj index 82febcad..4a10edf0 100644 --- a/sdk/AppNexusSDK.xcodeproj/project.pbxproj +++ b/sdk/AppNexusSDK.xcodeproj/project.pbxproj @@ -232,24 +232,14 @@ 8805092228AEA1C10099C6C6 /* NSTimer+ANCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = ECE4EA98194B768A0069D934 /* NSTimer+ANCategory.h */; settings = {ATTRIBUTES = (Private, ); }; }; 8805092628AEA2400099C6C6 /* ANBaseUrlConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A02D6F91D6CE946006831A3 /* ANBaseUrlConfig.h */; }; 8805092928AEA28D0099C6C6 /* ANMultiAdRequest+PrivateMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F8EBCD3235E2F6200256BFB /* ANMultiAdRequest+PrivateMethods.h */; }; - 88375F7828B93EBE00690416 /* NSView+ANNativeAdCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F7628B93EBE00690416 /* NSView+ANNativeAdCategory.h */; }; - 88375F7928B93EBE00690416 /* NSView+ANNativeAdCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F7728B93EBE00690416 /* NSView+ANNativeAdCategory.m */; }; 88375F7A28B95C6700690416 /* ANRealTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 60C4CB0025DD76B300A744CC /* ANRealTimer.h */; }; 88375F7B28B95C6B00690416 /* ANRealTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 60C4CB0125DD76B300A744CC /* ANRealTimer.m */; }; - 88375F7E28B960C600690416 /* NSView-UserInteraction.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F7C28B960C600690416 /* NSView-UserInteraction.h */; }; - 88375F7F28B960C600690416 /* NSView-UserInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F7D28B960C600690416 /* NSView-UserInteraction.m */; }; 88375F8428B96B2D00690416 /* XandrView.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F8028B96B2D00690416 /* XandrView.h */; }; - 88375F8528B96B2D00690416 /* XandrButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F8128B96B2D00690416 /* XandrButton.h */; }; - 88375F8628B96B2D00690416 /* XandrButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F8228B96B2D00690416 /* XandrButton.m */; }; 88375F8728B96B2D00690416 /* XandrView.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F8328B96B2D00690416 /* XandrView.m */; }; 88375F8C28B96B3800690416 /* XandrView.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F8028B96B2D00690416 /* XandrView.h */; }; 88375F8D28B96B3800690416 /* XandrView.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F8328B96B2D00690416 /* XandrView.m */; }; - 88375F8E28B96B3800690416 /* XandrButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F8128B96B2D00690416 /* XandrButton.h */; }; - 88375F8F28B96B3800690416 /* XandrButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F8228B96B2D00690416 /* XandrButton.m */; }; 88375F9028B96B3900690416 /* XandrView.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F8028B96B2D00690416 /* XandrView.h */; }; 88375F9128B96B3900690416 /* XandrView.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F8328B96B2D00690416 /* XandrView.m */; }; - 88375F9228B96B3900690416 /* XandrButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F8128B96B2D00690416 /* XandrButton.h */; }; - 88375F9328B96B3900690416 /* XandrButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F8228B96B2D00690416 /* XandrButton.m */; }; 88375F9A28B96C9800690416 /* XandrViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 88375F9828B96C9800690416 /* XandrViewController.m */; }; 88375F9B28B96C9800690416 /* XandrViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F9928B96C9800690416 /* XandrViewController.h */; }; 88375FA028B96CA000690416 /* XandrViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 88375F9928B96C9800690416 /* XandrViewController.h */; }; @@ -577,13 +567,7 @@ 880508B128AC14A80099C6C6 /* AppNexusNativeMacOSSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AppNexusNativeMacOSSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 880508B328AC14A80099C6C6 /* AppNexusNativeMacOSSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppNexusNativeMacOSSDK.h; sourceTree = ""; }; 880508B428AC14A80099C6C6 /* AppNexusNativeMacOSSDK.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = AppNexusNativeMacOSSDK.docc; sourceTree = ""; }; - 88375F7628B93EBE00690416 /* NSView+ANNativeAdCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+ANNativeAdCategory.h"; sourceTree = ""; }; - 88375F7728B93EBE00690416 /* NSView+ANNativeAdCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+ANNativeAdCategory.m"; sourceTree = ""; }; - 88375F7C28B960C600690416 /* NSView-UserInteraction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSView-UserInteraction.h"; sourceTree = ""; }; - 88375F7D28B960C600690416 /* NSView-UserInteraction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSView-UserInteraction.m"; sourceTree = ""; }; 88375F8028B96B2D00690416 /* XandrView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XandrView.h; sourceTree = ""; }; - 88375F8128B96B2D00690416 /* XandrButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XandrButton.h; sourceTree = ""; }; - 88375F8228B96B2D00690416 /* XandrButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XandrButton.m; sourceTree = ""; }; 88375F8328B96B2D00690416 /* XandrView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XandrView.m; sourceTree = ""; }; 88375F9828B96C9800690416 /* XandrViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XandrViewController.m; sourceTree = ""; }; 88375F9928B96C9800690416 /* XandrViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XandrViewController.h; sourceTree = ""; }; @@ -911,10 +895,6 @@ children = ( 88459B2428D25C7500A59352 /* NSView+ANCategory.h */, 88459B2328D25C7500A59352 /* NSView+ANCategory.m */, - 88375F7628B93EBE00690416 /* NSView+ANNativeAdCategory.h */, - 88375F7728B93EBE00690416 /* NSView+ANNativeAdCategory.m */, - 88375F7C28B960C600690416 /* NSView-UserInteraction.h */, - 88375F7D28B960C600690416 /* NSView-UserInteraction.m */, 8803BF0628E4B72200877A74 /* XandrNativeAdView.h */, 8803BF0728E4B72200877A74 /* XandrNativeAdView.m */, ); @@ -1125,8 +1105,6 @@ ECE4EA9B194B768A0069D934 /* UIView+ANCategory.m */, 602E0E221FE46571002C0F1C /* WKWebView+ANCategory.h */, 602E0E231FE46571002C0F1C /* WKWebView+ANCategory.m */, - 88375F8128B96B2D00690416 /* XandrButton.h */, - 88375F8228B96B2D00690416 /* XandrButton.m */, 88375F8028B96B2D00690416 /* XandrView.h */, 88375F8328B96B2D00690416 /* XandrView.m */, 88375FA528B96FB800690416 /* XandrImage.h */, @@ -1230,7 +1208,6 @@ files = ( 8805092628AEA2400099C6C6 /* ANBaseUrlConfig.h in Headers */, 8803BF0828E4B72200877A74 /* XandrNativeAdView.h in Headers */, - 88375F7E28B960C600690416 /* NSView-UserInteraction.h in Headers */, 88375F9B28B96C9800690416 /* XandrViewController.h in Headers */, 880508DC28AE62E70099C6C6 /* ANSDKSettings+PrivateMethods.h in Headers */, 880508F128AE74680099C6C6 /* ANUniversalTagAdServerResponse.h in Headers */, @@ -1251,7 +1228,6 @@ 8805090E28AE80940099C6C6 /* ANTargetingParameters.h in Headers */, 880508CB28AC15E00099C6C6 /* ANAdProtocol.h in Headers */, 880508D728AE56130099C6C6 /* ANLogManager.h in Headers */, - 88375F8528B96B2D00690416 /* XandrButton.h in Headers */, 8860676028B0436F00139573 /* ANNativeAdImageCache.h in Headers */, 8805091128AE80CA0099C6C6 /* ANStandardAd.h in Headers */, 880508FE28AE7A3B0099C6C6 /* ANNativeStandardAdResponse.h in Headers */, @@ -1279,7 +1255,6 @@ 880508DA28AE602A0099C6C6 /* ANSDKSettings.h in Headers */, 880508F628AE79A90099C6C6 /* ANCSMVideoAd.h in Headers */, 880508EF28AE74640099C6C6 /* ANUniversalTagRequestBuilder.h in Headers */, - 88375F7828B93EBE00690416 /* NSView+ANNativeAdCategory.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1297,7 +1272,6 @@ 8AE5E11E1A2FDC7700FDE858 /* ANAdView+PrivateMethods.h in Headers */, 8A9AEDB31A1BE8C200C58BDA /* ANAdView.h in Headers */, 8A9AEDCE1A1BF88200C58BDA /* ANAdViewInternalDelegate.h in Headers */, - 88375F9228B96B3900690416 /* XandrButton.h in Headers */, 8A9AEDD01A1BF88200C58BDA /* ANANJAMImplementation.h in Headers */, 381A0183245B17850093EBB2 /* ANAudioVolumeChangeListener.h in Headers */, 8A9AEDC61A1BF88200C58BDA /* ANBannerAdView+ANContentViewTransitions.h in Headers */, @@ -1421,7 +1395,6 @@ F5731B4F228C8D1A0012B134 /* ANNativeAdDelegate.h in Headers */, F5731BCD228DD90B0012B134 /* ANNativeAdFetcher.h in Headers */, F5731B3F228C8CA80012B134 /* ANNativeAdImageCache.h in Headers */, - 88375F8E28B96B3800690416 /* XandrButton.h in Headers */, F5731B50228C8D230012B134 /* ANNativeAdRequest.h in Headers */, F5731B42228C8CC30012B134 /* ANNativeAdResponse+PrivateMethods.h in Headers */, F5731B51228C8D290012B134 /* ANNativeAdResponse.h in Headers */, @@ -1646,7 +1619,6 @@ 002D905928B82F2200CBF78A /* ANMultiAdRequest.m in Sources */, 880508DB28AE62E10099C6C6 /* ANSDKSettings.m in Sources */, 8803BF0928E4B72200877A74 /* XandrNativeAdView.m in Sources */, - 88375F7F28B960C600690416 /* NSView-UserInteraction.m in Sources */, 880508D328AE56070099C6C6 /* ANLogging.m in Sources */, 880508FB28AE79D10099C6C6 /* ANMediatedAd.m in Sources */, 8805090B28AE805F0099C6C6 /* ANTrackerManager.m in Sources */, @@ -1662,7 +1634,6 @@ 8860675A28B031E500139573 /* ANNativeAdStarRating.m in Sources */, 880508F728AE79AE0099C6C6 /* ANCSMVideoAd.m in Sources */, 880508E828AE6B530099C6C6 /* ANNativeAdResponse.m in Sources */, - 88375F8628B96B2D00690416 /* XandrButton.m in Sources */, 880508F528AE799C0099C6C6 /* ANBaseAdObject.m in Sources */, 88375F7B28B95C6B00690416 /* ANRealTimer.m in Sources */, 8805092028AEA1AB0099C6C6 /* NSString+ANCategory.m in Sources */, @@ -1685,7 +1656,6 @@ 880508E528AE6B3F0099C6C6 /* ANNativeAdRequest.m in Sources */, 8805090F28AE80A80099C6C6 /* ANTargetingParameters.m in Sources */, 880508B528AC14A80099C6C6 /* AppNexusNativeMacOSSDK.docc in Sources */, - 88375F7928B93EBE00690416 /* NSView+ANNativeAdCategory.m in Sources */, 8805092128AEA1BE0099C6C6 /* NSTimer+ANCategory.m in Sources */, 88375FA628B96FB900690416 /* XandrImage.m in Sources */, 8860675828AEF9B000139573 /* ANLocation.m in Sources */, @@ -1752,7 +1722,6 @@ 0E7BC1CC229FC727002F41FF /* ANNativeRenderingViewController.m in Sources */, 8A598F8D1A1EA061009BA879 /* ANNativeStandardAdResponse.m in Sources */, 00D6B04B20D1BCAF007A3439 /* ANOMIDImplementation.m in Sources */, - 88375F9328B96B3900690416 /* XandrButton.m in Sources */, 8A2F48261A2E255600B0EA05 /* ANOpenInExternalBrowserActivity.m in Sources */, 602ADF6720178BAF00BEF101 /* ANProxyViewController.m in Sources */, 8A9AEE021A1BF99D00C58BDA /* ANReachability.m in Sources */, @@ -1792,7 +1761,6 @@ buildActionMask = 2147483647; files = ( 88375F8D28B96B3800690416 /* XandrView.m in Sources */, - 88375F8F28B96B3800690416 /* XandrButton.m in Sources */, 4F06400823A2E7D700E7920A /* ANAdFetcherBase.m in Sources */, F5731B79228C94700012B134 /* ANAdFetcherResponse.m in Sources */, 3850566E24DAD12F00D4B54D /* ANAdResponseCode.m in Sources */, diff --git a/sdk/sourcefiles/Categories/XandrButton.h b/sdk/sourcefiles/Categories/XandrButton.h deleted file mode 100644 index 4c72fa27..00000000 --- a/sdk/sourcefiles/Categories/XandrButton.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 Xandr INC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - -#import -#import "ANAdConstants.h" - -#if !APPNEXUS_NATIVE_MACOS_SDK - -#import - -@interface XandrButton : UIButton - -@end - - -#else -#import - -@interface XandrButton : NSButton - -@end -#endif - diff --git a/sdk/sourcefiles/Categories/XandrButton.m b/sdk/sourcefiles/Categories/XandrButton.m deleted file mode 100644 index 94dc05c4..00000000 --- a/sdk/sourcefiles/Categories/XandrButton.m +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 Xandr INC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - -#import "XandrButton.h" - -@implementation XandrButton - -@end diff --git a/sdk/sourcefiles/Categories/XandrImage.m b/sdk/sourcefiles/Categories/XandrImage.m index 18560a99..8596ce39 100644 --- a/sdk/sourcefiles/Categories/XandrImage.m +++ b/sdk/sourcefiles/Categories/XandrImage.m @@ -19,8 +19,6 @@ @implementation XandrImage #if !APPNEXUS_NATIVE_MACOS_SDK + (nullable XandrImage *)getImageWithData:(NSData *_Nonnull)data{ - - return [XandrImage imageWithData:data]; } #else diff --git a/sdk/sourcefiles/Categories/XandrView.h b/sdk/sourcefiles/Categories/XandrView.h index f05e8f59..fb9b1910 100644 --- a/sdk/sourcefiles/Categories/XandrView.h +++ b/sdk/sourcefiles/Categories/XandrView.h @@ -19,16 +19,10 @@ #if !APPNEXUS_NATIVE_MACOS_SDK #import - @interface XandrView : UIView - @end - - #else #import - @interface XandrView : NSView - @end #endif diff --git a/sdk/sourcefiles/Categories/XandrViewController.h b/sdk/sourcefiles/Categories/XandrViewController.h index 4580832f..f24241ff 100644 --- a/sdk/sourcefiles/Categories/XandrViewController.h +++ b/sdk/sourcefiles/Categories/XandrViewController.h @@ -18,19 +18,11 @@ #import "ANAdConstants.h" #if !APPNEXUS_NATIVE_MACOS_SDK - - #import - @interface XandrViewController : UIViewController - @end - - #else #import - @interface XandrViewController : NSViewController - @end #endif diff --git a/sdk/sourcefiles/internal/ANCarrierObserver.h b/sdk/sourcefiles/internal/ANCarrierObserver.h index e7637fca..48fe3811 100644 --- a/sdk/sourcefiles/internal/ANCarrierObserver.h +++ b/sdk/sourcefiles/internal/ANCarrierObserver.h @@ -2,6 +2,8 @@ NS_ASSUME_NONNULL_BEGIN +// App should be able to handle changes to the user’s cellular service provider. For example, the user could swap the device’s SIM card with one from another provider while app is running. Not applicable for macOS to know more click link https://developer.apple.com/documentation/coretelephony/cttelephonynetworkinfo + @interface ANCarrierMeta: NSObject @property (nonatomic, copy, readonly) NSString *name; @property (nonatomic, copy, readonly) NSString *countryCode; diff --git a/sdk/sourcefiles/internal/ANGlobal.h b/sdk/sourcefiles/internal/ANGlobal.h index 598d9319..d8ee5a11 100644 --- a/sdk/sourcefiles/internal/ANGlobal.h +++ b/sdk/sourcefiles/internal/ANGlobal.h @@ -114,7 +114,6 @@ static NSString * __nonnull const kANAdResponseInfo = @"adResponseInfo"; #pragma mark - Global functions. NSString *__nonnull ANDeviceModel(void); -BOOL ANAdvertisingTrackingEnabled(void); BOOL ANIsFirstLaunch(void); NSString * __nonnull ANUUID(void); @@ -138,6 +137,7 @@ NSNumber * __nullable ANiTunesIDForURL(NSURL * __nonnull URL); BOOL ANStatusBarHidden(void); CGRect ANStatusBarFrame(void); #if !APPNEXUS_NATIVE_MACOS_SDK +BOOL ANAdvertisingTrackingEnabled(void); UIInterfaceOrientation ANStatusBarOrientation(void); BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController); #endif @@ -146,7 +146,6 @@ BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController @interface ANGlobal : NSObject -+ (void) openURL: (nonnull NSString *)urlString; + (NSMutableDictionary * __nonnull)convertCustomKeywordsAsMapToStrings: (NSDictionary *> * __nonnull)keywordsMap withSeparatorString: (nonnull NSString *)separatorString; @@ -158,6 +157,7 @@ BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController + (nonnull NSString *) userAgent; #if !APPNEXUS_NATIVE_MACOS_SDK ++ (void) openURL: (nonnull NSString *)urlString; + (nonnull UIWindow *) getKeyWindow; #endif diff --git a/sdk/sourcefiles/internal/ANGlobal.m b/sdk/sourcefiles/internal/ANGlobal.m index 673cac58..cf8d79e3 100644 --- a/sdk/sourcefiles/internal/ANGlobal.m +++ b/sdk/sourcefiles/internal/ANGlobal.m @@ -59,30 +59,6 @@ } -/* -True : Advertising Tracking Enabled -False : Advertising Tracking Disabled, Restricted or NotDetermined - */ -BOOL ANAdvertisingTrackingEnabled() { - // If a user does turn this off, use the unique identifier *only* for the following: - // - Frequency capping - // - Conversion events - // - Estimating number of unique users - // - Security and fraud detection - // - Debugging - - if (@available(iOS 14, *)) { -#if __has_include() - if ([ATTrackingManager trackingAuthorizationStatus] == ATTrackingManagerAuthorizationStatusAuthorized ){ - return YES; - }else { - return NO; - } -#endif - } - return [ASIdentifierManager sharedManager].isAdvertisingTrackingEnabled; -} - NSString * __nonnull const kANFirstLaunchKey = @"kANFirstLaunchKey"; @@ -115,11 +91,11 @@ BOOL ANIsFirstLaunch() return advertisingIdentifier; } - +#if !APPNEXUS_NATIVE_MACOS_SDK +// a UUID that may be used to uniquely identify the device, same across apps from a single vendor. API is under UIKit which is not supported by macOS, https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor NSString *__nullable ANIdentifierForVendor() { if (ANSDKSettings.sharedInstance.disableIDFVUsage) { return nil; } -#if !APPNEXUS_NATIVE_MACOS_SDK - + NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; if (idfv) { ANLogInfo(@"idfv = %@", idfv); @@ -127,69 +103,36 @@ BOOL ANIsFirstLaunch() ANLogWarn(@"No IDFV retrieved."); } return idfv; -#endif return nil; } -NSString *__nonnull ANErrorString( NSString * __nonnull key) { - return NSLocalizedStringFromTableInBundle(key, AN_ERROR_TABLE, ANResourcesBundle(), @""); -} - -NSError *__nonnull ANError(NSString *__nonnull key, NSInteger code, ...) { - NSDictionary *errorInfo = nil; - va_list args; - va_start(args, code); - NSString *localizedDescription = ANErrorString(key); - if (localizedDescription) { - localizedDescription = [[NSString alloc] initWithFormat:localizedDescription - arguments:args]; - } else { - ANLogWarn(@"Could not find localized error string for key %@", key); - localizedDescription = @""; - } - va_end(args); - errorInfo = @{NSLocalizedDescriptionKey: localizedDescription}; - return [NSError errorWithDomain:AN_ERROR_DOMAIN - code:code - userInfo:errorInfo]; -} - -NSBundle *__nonnull ANResourcesBundle() { -#ifdef SWIFT_PACKAGE - return SWIFTPM_MODULE_BUNDLE; -#else - static dispatch_once_t resBundleToken; - static NSBundle *resBundle; - static ANGlobal *globalInstance; - dispatch_once(&resBundleToken, ^{ - globalInstance = [[ANGlobal alloc] init]; - resBundle = [NSBundle bundleForClass:[globalInstance class]]; - }); - return resBundle; +/* +True : Advertising Tracking Enabled +False : Advertising Tracking Disabled, Restricted or NotDetermined + */ +BOOL ANAdvertisingTrackingEnabled() { + // If a user does turn this off, use the unique identifier *only* for the following: + // - Frequency capping + // - Conversion events + // - Estimating number of unique users + // - Security and fraud detection + // - Debugging + + if (@available(iOS 14, *)) { +#if __has_include() + if ([ATTrackingManager trackingAuthorizationStatus] == ATTrackingManagerAuthorizationStatusAuthorized ){ + return YES; + }else { + return NO; + } #endif -} - -NSString *__nullable ANPathForANResource(NSString *__nullable name, NSString *__nullable type) { - NSString *path = [ANResourcesBundle() pathForResource:name ofType:type]; - if (!path) { - ANLogError(@"Could not find resource %@.%@. Please make sure that all the resources in sdk/resources are included in your app target's \"Copy Bundle Resources\".", name, type); } - return path; + return [ASIdentifierManager sharedManager].isAdvertisingTrackingEnabled; } -NSString *__nullable ANConvertToNSString(id __nullable value) { - if ([value isKindOfClass:[NSString class]]) return value; - if ([value respondsToSelector:@selector(stringValue)]) { - return [value stringValue]; - } - ANLogWarn(@"Failed to convert to NSString"); - return nil; -} CGRect ANAdjustAbsoluteRectInWindowCoordinatesForOrientationGivenRect(CGRect rect) { -#if !APPNEXUS_NATIVE_MACOS_SDK - // If portrait, no adjustment is necessary. if (ANStatusBarOrientation() == UIInterfaceOrientationPortrait) { return rect; @@ -220,35 +163,10 @@ CGRect ANAdjustAbsoluteRectInWindowCoordinatesForOrientationGivenRect(CGRect rec adjustedRect = rect; break; } - + return adjustedRect; -#endif - - return rect; - -} - -NSString *__nullable ANMRAIDBundlePath() { - NSString *mraidPath = ANPathForANResource(@"ANMRAID", @"bundle"); - if (!mraidPath) { - ANLogError(@"Could not find ANMRAID.bundle. Please make sure that ANMRAID.bundle resource in sdk/resources is included in your app target's \"Copy Bundle Resources\"."); - return nil; - } - return mraidPath; } -BOOL ANHasHttpPrefix(NSString * __nonnull url) { - return ([url hasPrefix:@"http"] || [url hasPrefix:@"https"]); -} - -void ANPostNotifications(NSString * __nonnull name, id __nullable object, NSDictionary * __nullable userInfo) { - if ([ANLogManager isNotificationsEnabled]) { - [[NSNotificationCenter defaultCenter] postNotificationName:name - object:object - userInfo:userInfo]; - } -} -#if !APPNEXUS_NATIVE_MACOS_SDK CGRect ANPortraitScreenBounds() { CGRect screenBounds = [UIScreen mainScreen].bounds; @@ -303,33 +221,6 @@ CGRect ANPortraitScreenBoundsApplyingSafeAreaInsets() { } return screenBounds; } -#endif - -NSMutableURLRequest * __nonnull ANBasicRequestWithURL(NSURL * __nonnull URL) { - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL - cachePolicy:NSURLRequestReloadIgnoringLocalCacheData - timeoutInterval:kAppNexusRequestTimeoutInterval]; - - [request setValue:[ANGlobal userAgent] forHTTPHeaderField:@"User-Agent"]; - return [request copy]; -} - -NSNumber * __nullable ANiTunesIDForURL(NSURL * __nonnull URL) { - if ([URL.host isEqualToString:@"itunes.apple.com"]) { - NSRegularExpression *idPattern = [[NSRegularExpression alloc] initWithPattern:@"id(\\d+)" - options:0 - error:nil]; - NSRange idRange = [idPattern rangeOfFirstMatchInString:URL.absoluteString - options:0 - range:NSMakeRange(0, URL.absoluteString.length)]; - if (idRange.length != 0) { - NSString *idString = [[URL.absoluteString substringWithRange:idRange] substringFromIndex:2]; - return @([idString longLongValue]); - } - } - return nil; -} -#if !APPNEXUS_NATIVE_MACOS_SDK BOOL ANCanPresentFromViewController(UIViewController * __nullable viewController) { return viewController.view.window != nil ? YES : NO; } @@ -360,7 +251,7 @@ UIInterfaceOrientation ANStatusBarOrientation() if (@available(iOS 13.0, *)) { // On application launch, the value of [UIApplication sharedApplication].windows is nil, in this case, the [ANGlobal getKeyWindow] returns the nil, then it picks device Orientation based screen size. - + if([ANGlobal getKeyWindow] != nil){ statusBarOrientation = [[[ANGlobal getKeyWindow] windowScene] interfaceOrientation]; }else{ @@ -378,8 +269,142 @@ UIInterfaceOrientation ANStatusBarOrientation() } #endif +NSString *__nonnull ANErrorString( NSString * __nonnull key) { + return NSLocalizedStringFromTableInBundle(key, AN_ERROR_TABLE, ANResourcesBundle(), @""); +} + +NSError *__nonnull ANError(NSString *__nonnull key, NSInteger code, ...) { + NSDictionary *errorInfo = nil; + va_list args; + va_start(args, code); + NSString *localizedDescription = ANErrorString(key); + if (localizedDescription) { + localizedDescription = [[NSString alloc] initWithFormat:localizedDescription + arguments:args]; + } else { + ANLogWarn(@"Could not find localized error string for key %@", key); + localizedDescription = @""; + } + va_end(args); + errorInfo = @{NSLocalizedDescriptionKey: localizedDescription}; + return [NSError errorWithDomain:AN_ERROR_DOMAIN + code:code + userInfo:errorInfo]; +} + +NSBundle *__nonnull ANResourcesBundle() { +#ifdef SWIFT_PACKAGE + return SWIFTPM_MODULE_BUNDLE; +#else + static dispatch_once_t resBundleToken; + static NSBundle *resBundle; + static ANGlobal *globalInstance; + dispatch_once(&resBundleToken, ^{ + globalInstance = [[ANGlobal alloc] init]; + resBundle = [NSBundle bundleForClass:[globalInstance class]]; + }); + return resBundle; +#endif +} + +NSString *__nullable ANPathForANResource(NSString *__nullable name, NSString *__nullable type) { + NSString *path = [ANResourcesBundle() pathForResource:name ofType:type]; + if (!path) { + ANLogError(@"Could not find resource %@.%@. Please make sure that all the resources in sdk/resources are included in your app target's \"Copy Bundle Resources\".", name, type); + } + return path; +} + +NSString *__nullable ANConvertToNSString(id __nullable value) { + if ([value isKindOfClass:[NSString class]]) return value; + if ([value respondsToSelector:@selector(stringValue)]) { + return [value stringValue]; + } + ANLogWarn(@"Failed to convert to NSString"); + return nil; +} + +NSString *__nullable ANMRAIDBundlePath() { + NSString *mraidPath = ANPathForANResource(@"ANMRAID", @"bundle"); + if (!mraidPath) { + ANLogError(@"Could not find ANMRAID.bundle. Please make sure that ANMRAID.bundle resource in sdk/resources is included in your app target's \"Copy Bundle Resources\"."); + return nil; + } + return mraidPath; +} + +BOOL ANHasHttpPrefix(NSString * __nonnull url) { + return ([url hasPrefix:@"http"] || [url hasPrefix:@"https"]); +} + +void ANPostNotifications(NSString * __nonnull name, id __nullable object, NSDictionary * __nullable userInfo) { + if ([ANLogManager isNotificationsEnabled]) { + [[NSNotificationCenter defaultCenter] postNotificationName:name + object:object + userInfo:userInfo]; + } +} + + +NSMutableURLRequest * __nonnull ANBasicRequestWithURL(NSURL * __nonnull URL) { + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData + timeoutInterval:kAppNexusRequestTimeoutInterval]; + + [request setValue:[ANGlobal userAgent] forHTTPHeaderField:@"User-Agent"]; + return [request copy]; +} + +NSNumber * __nullable ANiTunesIDForURL(NSURL * __nonnull URL) { + if ([URL.host isEqualToString:@"itunes.apple.com"]) { + NSRegularExpression *idPattern = [[NSRegularExpression alloc] initWithPattern:@"id(\\d+)" + options:0 + error:nil]; + NSRange idRange = [idPattern rangeOfFirstMatchInString:URL.absoluteString + options:0 + range:NSMakeRange(0, URL.absoluteString.length)]; + if (idRange.length != 0) { + NSString *idString = [[URL.absoluteString substringWithRange:idRange] substringFromIndex:2]; + return @([idString longLongValue]); + } + } + return nil; +} + @implementation ANGlobal +#if !APPNEXUS_NATIVE_MACOS_SDK + + + ++ (void) openURL: (nonnull NSString *)urlString +{ + + if (@available(iOS 10.0, *)) { + if([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]){ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString] options:@{} completionHandler:nil]; + return; + } + } + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; +} + + +#pragma mark - Get KeyWindow + ++ (nonnull UIWindow *) getKeyWindow +{ + UIWindow *keyWindow = nil; + for (UIWindow *window in [UIApplication sharedApplication].windows) { + if (window.isKeyWindow) { + keyWindow = window; + break; + } + } + return keyWindow; +} +#endif + +(nullable NSMutableURLRequest *) adServerRequestURL { if([ANGDPRSettings canAccessDeviceData] && !ANSDKSettings.sharedInstance.doNotTrack){ @@ -427,21 +452,6 @@ + (void)handleUserAgentDidChangeNotification:(NSNotification *)notification { } -+ (void) openURL: (nonnull NSString *)urlString -{ -#if !APPNEXUS_NATIVE_MACOS_SDK - - if (@available(iOS 10.0, *)) { - if([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]){ - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString] options:@{} completionHandler:nil]; - return; - } - } - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; -#endif - -} - #pragma mark - Custom keywords. // See also [AdSettings -setCustomKeywordsAsMapInEntryPoint:]. @@ -550,25 +560,6 @@ + (void) getUserAgent } } - -#if !APPNEXUS_NATIVE_MACOS_SDK - -#pragma mark - Get KeyWindow - -+ (nonnull UIWindow *) getKeyWindow -{ - UIWindow *keyWindow = nil; - for (UIWindow *window in [UIApplication sharedApplication].windows) { - if (window.isKeyWindow) { - keyWindow = window; - break; - } - } - return keyWindow; -} -#endif - - + (NSString *) userAgent { if(anUserAgent == nil){ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUserAgentDidChangeNotification:) name:@"kUserAgentDidChangeNotification" object:nil]; diff --git a/sdk/sourcefiles/internal/ANRealTimer.m b/sdk/sourcefiles/internal/ANRealTimer.m index 9733629d..57e0bfd8 100644 --- a/sdk/sourcefiles/internal/ANRealTimer.m +++ b/sdk/sourcefiles/internal/ANRealTimer.m @@ -107,7 +107,6 @@ -(void) notifyListenerObjects { id delegate = [self.timerDelegates objectAtIndex:i]; if([delegate respondsToSelector:@selector(handle1SecTimerSentNotification)]){ ANLogInfo(@"Notifications pushed from time"); - [delegate handle1SecTimerSentNotification]; } } diff --git a/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m b/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m index 6ea56fab..c4a92bca 100644 --- a/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m +++ b/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m @@ -245,13 +245,7 @@ - (NSDictionary *)requestBody requestDict[@"user"] = user; } - // Set EUID node, EUID - Third party id solutions - // - NSArray *> *externalUserIds = [self externalUserIds]; - if (externalUserIds && ANAdvertisingTrackingEnabled()) { - requestDict[@"eids"] = externalUserIds; - } - + NSDictionary *device = [self device]; if (device) { requestDict[@"device"] = device; @@ -280,10 +274,27 @@ - (NSDictionary *)requestBody requestDict[@"supply_type"] = @"mobile_app"; + // Condition will be fixed with MS-5112 -[mobile-sdk][ios]Update logic to pass PPID to impbus + NSArray *> *externalUserIds = [self externalUserIds]; + #if !APPNEXUS_NATIVE_MACOS_SDK + // Set EUID node, EUID - Third party id solutions + // + if (externalUserIds && ANAdvertisingTrackingEnabled()) { + requestDict[@"eids"] = externalUserIds; + } + #else + if (externalUserIds) { + requestDict[@"eids"] = externalUserIds; + } + #endif + - if(ANSDKSettings.sharedInstance.enableOpenMeasurement){ - requestDict[@"iab_support"] = [self getIABSupport]; - } + #if !APPNEXUS_NATIVE_MACOS_SDK + if(ANSDKSettings.sharedInstance.enableOpenMeasurement){ + requestDict[@"iab_support"] = [self getIABSupport]; + } + #endif + // add GDPR Consent @@ -636,14 +647,17 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ // Use publisherFirstPartyID if it is present. External Id in ANAdProtocol is deprecated. if (publisherUserId) { userDict[@"external_uid"] = publisherUserId; - }else if (!ANAdvertisingTrackingEnabled()){ - // Pass IDFV as external_uid when there is no Publisher First Party Id and IDFA + } + #if !APPNEXUS_NATIVE_MACOS_SDK + else if (!ANAdvertisingTrackingEnabled()){ + // Pass IDFV as external_uid when there is no Publisher First Party Id and IDFA, IDFV is not support by macOS. NSString *idfv = ANIdentifierForVendor(); if (idfv) { userDict[@"external_uid"] = idfv; } } - + #endif + if ([[ANSDKSettings sharedInstance] doNotTrack]) { userDict[@"dnt"] = [NSNumber numberWithBool:YES]; } @@ -678,7 +692,8 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ } #if !APPNEXUS_NATIVE_MACOS_SDK - // +// App should be able to handle changes to the user’s cellular service provider. For example, the user could swap the device’s SIM card with one from another provider while app is running. Not applicable for macOS to know more click link https://developer.apple.com/documentation/coretelephony/cttelephonynetworkinfo + ANCarrierObserver *carrierObserver = ANCarrierObserver.shared; ANCarrierMeta *carrierMeta = carrierObserver.carrierMeta; @@ -693,6 +708,13 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ if (carrierMeta.networkCode.length > 0) { deviceDict[@"mnc"] = @([carrierMeta.networkCode integerValue]); } + if(ANAdvertisingTrackingEnabled()){ + deviceDict[@"limit_ad_tracking"] = [NSNumber numberWithBool:NO]; + } + NSDictionary *deviceId = [self deviceId]; + if (deviceId) { + deviceDict[@"device_id"] = deviceId; + } #endif @@ -715,14 +737,8 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ deviceDict[@"connectiontype"] = @(connectionType); - if(ANAdvertisingTrackingEnabled()){ - deviceDict[@"limit_ad_tracking"] = [NSNumber numberWithBool:NO]; - } - NSDictionary *deviceId = [self deviceId]; - if (deviceId) { - deviceDict[@"device_id"] = deviceId; - } + // NSInteger timeInMiliseconds = (NSInteger)[[NSDate date] timeIntervalSince1970]; @@ -776,7 +792,7 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ // return [geoDict copy]; } - +#if !APPNEXUS_NATIVE_MACOS_SDK - (NSDictionary *)deviceId { if([ANGDPRSettings canAccessDeviceData] && ANAdvertisingTrackingEnabled() && !ANSDKSettings.sharedInstance.doNotTrack){ @@ -785,7 +801,6 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ return nil; } - -(NSDictionary *) fetchAdvertisingIdentifier { NSString *idfa = ANAdvertisingIdentifier(); @@ -795,6 +810,7 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ return nil; } } +#endif - (NSDictionary *)app @@ -914,18 +930,17 @@ - (NSDictionary *)getGDPRConsentObject return nil; } } +#if !APPNEXUS_NATIVE_MACOS_SDK - (NSDictionary *)getIABSupport { -#if !APPNEXUS_NATIVE_MACOS_SDK - return @{ @"omidpn" : AN_OMIDSDK_PARTNER_NAME, @"omidpv" : AN_SDK_VERSION }; -#endif return @{}; } +#endif - (NSDictionary *)geoOverrideCountryZipCode { diff --git a/sdk/sourcefiles/internal/config/ANSDKSettings.m b/sdk/sourcefiles/internal/config/ANSDKSettings.m index 12e59651..96736348 100644 --- a/sdk/sourcefiles/internal/config/ANSDKSettings.m +++ b/sdk/sourcefiles/internal/config/ANSDKSettings.m @@ -141,6 +141,7 @@ - (void) optionalSDKInitialization:(sdkInitCompletion _Nullable)success [[ANReachability sharedReachabilityForInternetConnection] start]; [ANGlobal adServerRequestURL]; +// App should be able to handle changes to the user’s cellular service provider. For example, the user could swap the device’s SIM card with one from another provider while app is running. Not applicable for macOS to know more click link https://developer.apple.com/documentation/coretelephony/cttelephonynetworkinfo #if !APPNEXUS_NATIVE_MACOS_SDK [ANCarrierObserver shared]; [ANWebView prepareWebView]; diff --git a/sdk/sourcefiles/macOS/NSView+ANCategory.h b/sdk/sourcefiles/macOS/NSView+ANCategory.h index 90c688a4..b85df0c7 100644 --- a/sdk/sourcefiles/macOS/NSView+ANCategory.h +++ b/sdk/sourcefiles/macOS/NSView+ANCategory.h @@ -14,11 +14,14 @@ */ #import +#import +#import "ANNativeAdResponse.h" @interface NSView (NSCategory) - (BOOL)an_isViewable; - (CGRect)an_visibleInViewRectangle; +@property (nonatomic, readwrite, weak) ANNativeAdResponse *anNativeAdResponse; @end diff --git a/sdk/sourcefiles/macOS/NSView+ANCategory.m b/sdk/sourcefiles/macOS/NSView+ANCategory.m index ffbbfbfe..ed045622 100644 --- a/sdk/sourcefiles/macOS/NSView+ANCategory.m +++ b/sdk/sourcefiles/macOS/NSView+ANCategory.m @@ -27,7 +27,7 @@ - (CGRect)an_visibleInViewRectangle{ if(self.an_isViewable){ NSWindow *parentWindow = self.window; visibleRectangle = [parentWindow convertRectToScreen:self.frame]; - + } return visibleRectangle; @@ -59,4 +59,12 @@ - (BOOL)an_isViewable { } + +- (void)setAnNativeAdResponse:(ANNativeAdResponse *)anNativeAdResponse { + objc_setAssociatedObject(self, @selector(anNativeAdResponse), anNativeAdResponse, OBJC_ASSOCIATION_RETAIN); +} + +- (ANNativeAdResponse *)anNativeAdResponse { + return objc_getAssociatedObject(self, @selector(anNativeAdResponse)); +} @end diff --git a/sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.h b/sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.h deleted file mode 100644 index 25a9df1d..00000000 --- a/sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2014 APPNEXUS INC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import -#import "ANAdConstants.h" - -#if APPNEXUS_NATIVE_MACOS_SDK - - -#import -#import "ANNativeAdResponse.h" - -@interface NSView (ANNativeAdCategory) - -@property (nonatomic, readwrite, weak) ANNativeAdResponse *anNativeAdResponse; - -@end -#endif diff --git a/sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.m b/sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.m deleted file mode 100644 index b8616a54..00000000 --- a/sdk/sourcefiles/macOS/NSView+ANNativeAdCategory.m +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2014 APPNEXUS INC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -#import -#import "ANAdConstants.h" - -#if APPNEXUS_NATIVE_MACOS_SDK - -#import "NSView+ANNativeAdCategory.h" -#import - -@implementation NSView (ANNativeAdCategory) - -@dynamic anNativeAdResponse; - -- (void)setAnNativeAdResponse:(ANNativeAdResponse *)anNativeAdResponse { - objc_setAssociatedObject(self, @selector(anNativeAdResponse), anNativeAdResponse, OBJC_ASSOCIATION_RETAIN); -} - -- (ANNativeAdResponse *)anNativeAdResponse { - return objc_getAssociatedObject(self, @selector(anNativeAdResponse)); -} - -@end -#endif diff --git a/sdk/sourcefiles/macOS/NSView-UserInteraction.h b/sdk/sourcefiles/macOS/NSView-UserInteraction.h deleted file mode 100644 index 8c83b666..00000000 --- a/sdk/sourcefiles/macOS/NSView-UserInteraction.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 Xandr INC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#import -#import "ANAdConstants.h" - -#if APPNEXUS_NATIVE_MACOS_SDK -#import - -NS_ASSUME_NONNULL_BEGIN -@interface NSView (UserInteraction) - -- (void)disableSubViews; -- (void)enableSubViews; - -@end - -NS_ASSUME_NONNULL_END -#endif diff --git a/sdk/sourcefiles/macOS/NSView-UserInteraction.m b/sdk/sourcefiles/macOS/NSView-UserInteraction.m deleted file mode 100644 index 0742eba9..00000000 --- a/sdk/sourcefiles/macOS/NSView-UserInteraction.m +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2022 APPNEXUS INC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - -#import -#import "ANAdConstants.h" - -#if APPNEXUS_NATIVE_MACOS_SDK - -#import "NSView-UserInteraction.h" - -@implementation NSView(UserInteraction) - -- (void)disableSubViews -{ - [self setSubViewsEnabled:NO]; -} - -- (void)enableSubViews -{ - [self setSubViewsEnabled:YES]; -} - -- (void)setSubViewsEnabled:(BOOL)enabled -{ - NSView* currentView = NULL; - NSEnumerator* viewEnumerator = [[self subviews] objectEnumerator]; - - while( currentView = [viewEnumerator nextObject] ) - { - if( [currentView respondsToSelector:@selector(setEnabled:)] ) - { - [(NSControl*)currentView setEnabled:enabled]; - } - [currentView setSubViewsEnabled:enabled]; - - [currentView display]; - } -} - -@end -#endif diff --git a/sdk/sourcefiles/native/internal/ANNativeAdResponse+PrivateMethods.h b/sdk/sourcefiles/native/internal/ANNativeAdResponse+PrivateMethods.h index 949737d1..889863d5 100644 --- a/sdk/sourcefiles/native/internal/ANNativeAdResponse+PrivateMethods.h +++ b/sdk/sourcefiles/native/internal/ANNativeAdResponse+PrivateMethods.h @@ -49,7 +49,7 @@ clickableViews:(NSArray *)clickableViews error:(NSError *__autoreleasing*)error; #if APPNEXUS_NATIVE_MACOS_SDK --(void)registerClickView:(XandrNativeAdView *)view; +-(void)attachClickGestureRecognizerToView:(XandrNativeAdView *)view; #endif #pragma mark - Unregistration diff --git a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m index 0f54244b..f3e38ed6 100644 --- a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m +++ b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m @@ -27,12 +27,10 @@ #import "ANOMIDImplementation.h" #import "ANVerificationScriptResource.h" #else -#import "NSView+ANNativeAdCategory.h" -#import "NSView-UserInteraction.h" +#import "NSView+ANCategory.h" #import "XandrNativeAdView.h" #endif -#import "XandrButton.h" #import "XandrView.h" #import "XandrViewController.h" #import "ANSDKSettings.h" @@ -50,12 +48,13 @@ #pragma mark - ANNativeAdResponseGestureRecognizerRecord @interface ANNativeAdResponseGestureRecognizerRecord : NSObject -@property (nonatomic, weak) XandrView *viewWithTracking; #if !APPNEXUS_NATIVE_MACOS_SDK +@property (nonatomic, weak) XandrView *viewWithTracking; @property (nonatomic, weak) UIGestureRecognizer *gestureRecognizer; #else -@property (nonatomic, weak) NSPressGestureRecognizer *gestureRecognizer; +@property (nonatomic, weak) XandrNativeAdView *viewWithTracking; +@property (nonatomic, weak) NSClickGestureRecognizer *gestureRecognizer; #endif @end @@ -80,7 +79,6 @@ @interface ANNativeAdResponse() #else @property (nonatomic, readwrite, weak) NSView *viewForTracking; @property (nonatomic, readwrite, weak) NSViewController *rootViewController; -@property (nonatomic, readwrite, strong, nullable) NSMutableArray *obstructionViews; #endif @property (nonatomic, readwrite, strong) NSMutableArray *gestureRecognizerRecords; @property (nonatomic, readwrite, assign, getter=hasExpired) BOOL expired; @@ -167,6 +165,7 @@ - (BOOL)registerViewForTracking:(nonnull XandrView *)view self.viewForTracking = view; [view setAnNativeAdResponse:self]; self.rootViewController = controller; +// OMID is not supported by macOS #if !APPNEXUS_NATIVE_MACOS_SDK [self registerOMID]; #endif @@ -194,7 +193,7 @@ - (BOOL)registerViewForTracking:(nonnull NSTableRowView *)view BOOL successfulResponseRegistration = [self registerViewForTracking:(XandrView *)view withRootViewController:(XandrViewController *)rvc clickableViews:nil error:error]; for(XandrNativeAdView *clickableView in views){ - [self registerClickView:clickableView]; + [self attachClickGestureRecognizerToView:clickableView]; } if(!successfulResponseRegistration){ @@ -227,7 +226,7 @@ - (BOOL)registerViewTracking:(nonnull NSView *)view #pragma mark - Click handling - +#if !APPNEXUS_NATIVE_MACOS_SDK - (void)attachGestureRecognizersToNativeView:(XandrView *)nativeView withClickableViews:(NSArray *)clickableViews { @@ -236,19 +235,11 @@ - (void)attachGestureRecognizersToNativeView:(XandrView *)nativeView if (clickableViews.count) { [clickableViews enumerateObjectsUsingBlock:^(id clickableView, NSUInteger idx, BOOL *stop) { -#if !APPNEXUS_NATIVE_MACOS_SDK if ([clickableView isKindOfClass:[UIView class]]) { [self attachGestureRecognizerToView:clickableView]; } else { ANLogWarn(@"native_invalid_clickable_views"); } -#else - if ([clickableView isKindOfClass:[NSView class]]) { - [self attachGestureRecognizerToView:clickableView]; - } else { - ANLogWarn(@"native_invalid_clickable_views"); - } -#endif }]; @@ -260,7 +251,6 @@ - (void)attachGestureRecognizersToNativeView:(XandrView *)nativeView - (void)attachGestureRecognizerToView:(XandrView *)view { -#if !APPNEXUS_NATIVE_MACOS_SDK view.userInteractionEnabled = YES; ANNativeAdResponseGestureRecognizerRecord *record = [[ANNativeAdResponseGestureRecognizerRecord alloc] init]; record.viewWithTracking = view; @@ -276,45 +266,60 @@ - (void)attachGestureRecognizerToView:(XandrView *)view record.gestureRecognizer = clickRecognizer; } [self.gestureRecognizerRecords addObject:record]; -#endif } + +- (void)detachAllGestureRecognizers { + [self.gestureRecognizerRecords enumerateObjectsUsingBlock:^(ANNativeAdResponseGestureRecognizerRecord *record, NSUInteger idx, BOOL *stop) { + + XandrView *view = record.viewWithTracking; + if (view) { + if ([view isKindOfClass:[UIButton class]]) { + [(UIButton *)view removeTarget:self + action:@selector(handleClick) + forControlEvents:UIControlEventTouchUpInside]; + } else if (record.gestureRecognizer) { + [view removeGestureRecognizer:record.gestureRecognizer]; + } + } + }]; + + [self.gestureRecognizerRecords removeAllObjects]; +} + +#else + +-(void)attachClickGestureRecognizerToView:(XandrNativeAdView *)registerView { + ANNativeAdResponseGestureRecognizerRecord *record = [[ANNativeAdResponseGestureRecognizerRecord alloc] init]; + record.viewWithTracking = registerView; -#if APPNEXUS_NATIVE_MACOS_SDK --(void)registerClickView:(XandrNativeAdView *)registerView { [registerView attachClickableView]; NSClickGestureRecognizer *clickRecognizer = [[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(handleClick)]; [registerView addGestureRecognizer:clickRecognizer]; -} -#endif + record.gestureRecognizer = clickRecognizer; + [self.gestureRecognizerRecords addObject:record]; +} + - (void)detachAllGestureRecognizers { [self.gestureRecognizerRecords enumerateObjectsUsingBlock:^(ANNativeAdResponseGestureRecognizerRecord *record, NSUInteger idx, BOOL *stop) { - XandrView *view = record.viewWithTracking; - if (view) { -#if !APPNEXUS_NATIVE_MACOS_SDK - if ([view isKindOfClass:[UIButton class]]) { - [(UIButton *)view removeTarget:self - action:@selector(handleClick) - forControlEvents:UIControlEventTouchUpInside]; - } else if (record.gestureRecognizer) { - [view removeGestureRecognizer:record.gestureRecognizer]; - } -#else - if ([view isKindOfClass:[NSButton class]]) { - NSButton *button = (NSButton *)view; - [button setTarget:nil]; - [button setAction:nil]; - } else if (record.gestureRecognizer) { - [view removeGestureRecognizer:record.gestureRecognizer]; + + XandrNativeAdView *view = record.viewWithTracking; + if (view) { + if (record.gestureRecognizer) { + [view removeGestureRecognizer:record.gestureRecognizer]; + } } -#endif - } + }]; - + [self.gestureRecognizerRecords removeAllObjects]; } +#endif + + + #if !APPNEXUS_NATIVE_MACOS_SDK - (BOOL)registerViewForTracking:(nonnull UIView *)view @@ -369,6 +374,8 @@ - (void)unregisterViewFromTracking { [self detachAllGestureRecognizers]; [self.viewForTracking setAnNativeAdResponse:nil]; self.viewForTracking = nil; + +// OMID is not supported by macOS #if !APPNEXUS_NATIVE_MACOS_SDK if(self.omidAdSession != nil){ [[ANOMIDImplementation sharedInstance] stopOMIDAdSession:self.omidAdSession]; diff --git a/sdk/sourcefiles/native/internal/ANNativeStandardAdResponse.m b/sdk/sourcefiles/native/internal/ANNativeStandardAdResponse.m index 45963ea3..f07c12d0 100644 --- a/sdk/sourcefiles/native/internal/ANNativeStandardAdResponse.m +++ b/sdk/sourcefiles/native/internal/ANNativeStandardAdResponse.m @@ -106,9 +106,11 @@ - (BOOL)registerResponseInstanceWithNativeView:(XandrView *)view clickableViews:(NSArray *)clickableViews error:(NSError *__autoreleasing *)error { [self setupViewabilityTracker]; +#if !APPNEXUS_NATIVE_MACOS_SDK [self attachGestureRecognizersToNativeView:view withClickableViews:clickableViews]; - +#endif + return YES; } @@ -124,12 +126,8 @@ - (void)unregisterViewFromTracking { - (void)setupViewabilityTracker { - -#if !APPNEXUS_NATIVE_MACOS_SDK + if ((self.impressionType == ANViewableImpression || [ANSDKSettings sharedInstance].enableOMIDOptimization)) { -#else - if (self.impressionType == ANViewableImpression) { -#endif [ANRealTimer addDelegate:self]; } @@ -153,6 +151,7 @@ - (void) checkIfViewIs1pxOnScreen { [self trackImpression]; } } +// OMID is not supported by macOS #if !APPNEXUS_NATIVE_MACOS_SDK if([ANSDKSettings sharedInstance].enableOMIDOptimization){ if(updatedVisibleInViewRectangle.size.width == self.viewForTracking.frame.size.width && updatedVisibleInViewRectangle.size.height == self.viewForTracking.frame.size.height && !self.isAdVisible100Percent){ @@ -170,35 +169,16 @@ - (void) checkIfViewIs1pxOnScreen { } -- (void)checkIfIABViewable { - -#if !APPNEXUS_NATIVE_MACOS_SDK - -if (self.viewForTracking.window) { - [self trackImpression]; - } - -#endif - -} - - (void)trackImpression { if (!self.impressionHasBeenTracked) { ANLogDebug(@"Firing impression trackers"); [self fireImpTrackers]; [self.viewabilityTimer invalidate]; - self.impressionHasBeenTracked = YES; - -#if !APPNEXUS_NATIVE_MACOS_SDK - if(![ANSDKSettings sharedInstance].enableOMIDOptimization){ - [ANRealTimer removeDelegate:self]; - } -#else - if (self.impressionType == ANViewableImpression) { + self.impressionHasBeenTracked = YES; + if(self.impressionType == ANViewableImpression || ![ANSDKSettings sharedInstance].enableOMIDOptimization){ [ANRealTimer removeDelegate:self]; } -#endif } } @@ -211,6 +191,7 @@ - (void)fireImpTrackers { } }]; } +// OMID is not supported by macOS #if !APPNEXUS_NATIVE_MACOS_SDK if(self.omidAdSession != nil){ [[ANOMIDImplementation sharedInstance] fireOMIDImpressionOccuredEvent:self.omidAdSession]; @@ -254,6 +235,7 @@ - (BOOL)openIntendedBrowserWithURL:(NSURL *)URL { switch (self.clickThroughAction) { +// Open URL in SDK Browser is not supported by macOS, macOS supports ClickThrough as return URL only #if !APPNEXUS_NATIVE_MACOS_SDK case ANClickThroughActionOpenSDKBrowser: // Try to use device browser even if SDK browser was requested in cases @@ -290,14 +272,12 @@ - (BOOL)openIntendedBrowserWithURL:(NSURL *)URL - (BOOL) openURLWithExternalBrowser:(NSURL *)url { - +// Open URL in ExternalBrowser is not supported by macOS, macOS supports ClickThrough as return URL only #if !APPNEXUS_NATIVE_MACOS_SDK if (![[UIApplication sharedApplication] canOpenURL:url]) { return NO; } - -#endif - [self willLeaveApplication]; [ANGlobal openURL:[url absoluteString]]; +#endif return YES; } @@ -312,6 +292,7 @@ - (void)fireClickTrackers #pragma mark - ANBrowserViewControllerDelegate +// BrowserViewController is not supported by macOS, macOS supports ClickThrough as return URL only #if !APPNEXUS_NATIVE_MACOS_SDK - (UIViewController *)rootViewControllerForDisplayingBrowserViewController:(ANBrowserViewController *)controller { diff --git a/sdk/sourcefiles/public-headers/ANAdConstants.h b/sdk/sourcefiles/public-headers/ANAdConstants.h index 66d70655..8b3a0d10 100644 --- a/sdk/sourcefiles/public-headers/ANAdConstants.h +++ b/sdk/sourcefiles/public-headers/ANAdConstants.h @@ -46,6 +46,7 @@ typedef NS_ENUM(NSUInteger, ANAdType) { }; typedef NS_ENUM(NSUInteger, ANClickThroughAction) { +// ClickThrough as return URL is supported by macOS #if !APPNEXUS_NATIVE_MACOS_SDK ANClickThroughActionReturnURL, ANClickThroughActionOpenDeviceBrowser, diff --git a/sdk/sourcefiles/public-headers/ANAdProtocol.h b/sdk/sourcefiles/public-headers/ANAdProtocol.h index be47da67..a92c582d 100644 --- a/sdk/sourcefiles/public-headers/ANAdProtocol.h +++ b/sdk/sourcefiles/public-headers/ANAdProtocol.h @@ -242,7 +242,9 @@ Set the trafficSourceCode, Specifies the third-party source of the impression. * It is placed into ANAdProtocol instead of ANAdProtocolFoundation to avoid adResponseInfo being accessed through ANNativeAdRequest. */ @property (nonatomic, readwrite, strong, nullable) ANAdResponseInfo *adResponseInfo; +// OpenMeasurement is not supported by macOS #if !APPNEXUS_NATIVE_MACOS_SDK + /*! * UI View which would consider to be part of the ad can be added as friendly obstruction * (all sub-views of the adView will be automatically treated as part of the ad) From dbc71b7ee3a0c7d75621a67a94b4776076b44f51 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Tue, 25 Oct 2022 20:40:40 +0000 Subject: [PATCH 3/6] Merge pull request #859 in MOBILE-SDK/app_mobile-sdk-ios from clickRenameIssue to develop Squashed commit of the following: commit c3c7f6629145d5253c4c3a4769c1c854d9af86df Author: asharma Date: Wed Oct 26 01:22:46 2022 +0530 Fixed name for attachClickGestureRecognizerToView --- sdk/sourcefiles/native/internal/ANNativeAdResponse.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m index f3e38ed6..7a5f0b82 100644 --- a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m +++ b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m @@ -211,7 +211,7 @@ - (BOOL)registerViewTracking:(nonnull NSView *)view BOOL successfulResponseRegistration = [self registerViewForTracking:(XandrView *)view withRootViewController:(XandrViewController *)rvc clickableViews:nil error:error]; for(XandrNativeAdView *clickableView in views){ - [self registerClickView:clickableView]; + [self attachClickGestureRecognizerToView:clickableView]; } if(!successfulResponseRegistration){ From 6238f03e73a6b4eabf6914d327fdf581bddba893 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Thu, 27 Oct 2022 16:52:32 +0000 Subject: [PATCH 4/6] Tracker is not getting fired on multiple screens Squashed commit of the following: commit 9aabde8df43cab0579615e10f1f0cb28683b0144 Author: asharma Date: Thu Oct 27 21:47:36 2022 +0530 Removed duplicate code commit d55b65953b6db4619b1f3eaf6f9f2c6f71ccbb1e Author: asharma Date: Thu Oct 27 20:33:09 2022 +0530 Added -mac in version commit 204d22b66042b74f6e2605c48c200948233c3252 Author: asharma Date: Wed Oct 26 23:43:07 2022 +0530 Added multiscreen check --- sdk/sourcefiles/internal/ANGlobal.h | 10 +++++++++- .../internal/ANUniversalTagRequestBuilder.m | 16 ++++------------ sdk/sourcefiles/macOS/NSView+ANCategory.m | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/sdk/sourcefiles/internal/ANGlobal.h b/sdk/sourcefiles/internal/ANGlobal.h index d8ee5a11..dd7e53bb 100644 --- a/sdk/sourcefiles/internal/ANGlobal.h +++ b/sdk/sourcefiles/internal/ANGlobal.h @@ -26,7 +26,15 @@ #define AN_ERROR_TABLE @"errors" #define AN_DEFAULT_PLACEMENT_ID @"default_placement_id" -#define AN_SDK_VERSION @"8.1.0" + + +#if !APPNEXUS_NATIVE_MACOS_SDK + #define AN_SDK_VERSION @"8.1.0" +#else + #define AN_SDK_VERSION @"8.1.0-mac" +#endif + + #define APPNEXUS_BANNER_SIZE CGSizeMake(320, 50) diff --git a/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m b/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m index c4a92bca..90990318 100644 --- a/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m +++ b/sdk/sourcefiles/internal/ANUniversalTagRequestBuilder.m @@ -898,19 +898,11 @@ -(void)getAdFramework:(NSMutableDictionary *)tag{ - (NSDictionary *)sdk { -#if !APPNEXUS_NATIVE_MACOS_SDK - - return @{ - @"source" : @"ansdk", - @"version" : AN_SDK_VERSION - }; -#else return @{ - @"source" : @"ansdk-macos", - @"version" : AN_SDK_VERSION - }; -#endif - + @"source" : @"ansdk", + @"version" : AN_SDK_VERSION + }; + } - (NSDictionary *)getGDPRConsentObject diff --git a/sdk/sourcefiles/macOS/NSView+ANCategory.m b/sdk/sourcefiles/macOS/NSView+ANCategory.m index ed045622..4f3367a8 100644 --- a/sdk/sourcefiles/macOS/NSView+ANCategory.m +++ b/sdk/sourcefiles/macOS/NSView+ANCategory.m @@ -53,9 +53,19 @@ - (BOOL)an_isViewable { } if (isInHiddenSuperview) return NO; - CGRect screenRect = [NSScreen mainScreen].visibleFrame; CGRect normalizedSelfRect = [self convertRect:self.bounds toView:nil]; - return CGRectIntersectsRect(normalizedSelfRect, screenRect); + NSArray *screenList = [NSScreen screens]; + for (NSScreen *screen in screenList) + { + CGRect screenRect = screen.visibleFrame; + BOOL isViewable = CGRectIntersectsRect(normalizedSelfRect, screenRect); + if(isViewable){ + return YES; + } + } + + + return NO; } From 2667391b2d67ef31fe66f590f0cf3f24f64aed1c Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Thu, 27 Oct 2022 17:30:41 +0000 Subject: [PATCH 5/6] added detachClickableView Squashed commit of the following: commit 393b4e99617c377b462286ceb4b0d0190ff2378e Author: asharma Date: Thu Oct 27 22:56:26 2022 +0530 Updated detachClickableView block commit c000f27d995dc6ed1cb7cf68d405650fa734574e Author: asharma Date: Thu Oct 27 22:41:38 2022 +0530 Reverted Screen change commit 23f196ddb03e31f4cc18ed8d59d390f7279c1bdd Author: asharma Date: Thu Oct 27 22:38:10 2022 +0530 Added detachClickableView commit 9aabde8df43cab0579615e10f1f0cb28683b0144 Author: asharma Date: Thu Oct 27 21:47:36 2022 +0530 Removed duplicate code commit d55b65953b6db4619b1f3eaf6f9f2c6f71ccbb1e Author: asharma Date: Thu Oct 27 20:33:09 2022 +0530 Added -mac in version commit 204d22b66042b74f6e2605c48c200948233c3252 Author: asharma Date: Wed Oct 26 23:43:07 2022 +0530 Added multiscreen check --- sdk/sourcefiles/macOS/XandrNativeAdView.h | 1 + sdk/sourcefiles/macOS/XandrNativeAdView.m | 4 ++++ sdk/sourcefiles/native/internal/ANNativeAdResponse.m | 1 + 3 files changed, 6 insertions(+) diff --git a/sdk/sourcefiles/macOS/XandrNativeAdView.h b/sdk/sourcefiles/macOS/XandrNativeAdView.h index e4a5696b..62c0e5f0 100644 --- a/sdk/sourcefiles/macOS/XandrNativeAdView.h +++ b/sdk/sourcefiles/macOS/XandrNativeAdView.h @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @interface XandrNativeAdView : NSView @property (nonatomic, readwrite, strong) NSView *viewForTracking; -(void)attachClickableView; +-(void)detachClickableView; @end NS_ASSUME_NONNULL_END diff --git a/sdk/sourcefiles/macOS/XandrNativeAdView.m b/sdk/sourcefiles/macOS/XandrNativeAdView.m index 231fd3e2..e9526e11 100644 --- a/sdk/sourcefiles/macOS/XandrNativeAdView.m +++ b/sdk/sourcefiles/macOS/XandrNativeAdView.m @@ -30,4 +30,8 @@ -(void)attachClickableView{ self.viewForTracking.layer.backgroundColor = [[NSColor clearColor] CGColor]; [self addSubview:self.viewForTracking positioned:NSWindowAbove relativeTo:nil]; } + +-(void)detachClickableView{ + [self.viewForTracking removeFromSuperview]; +} @end diff --git a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m index 7a5f0b82..67ac1ded 100644 --- a/sdk/sourcefiles/native/internal/ANNativeAdResponse.m +++ b/sdk/sourcefiles/native/internal/ANNativeAdResponse.m @@ -309,6 +309,7 @@ - (void)detachAllGestureRecognizers { if (record.gestureRecognizer) { [view removeGestureRecognizer:record.gestureRecognizer]; } + [view detachClickableView]; } }]; From 8c8144423019e0110bffd2f0f62dfb01332fa44f Mon Sep 17 00:00:00 2001 From: asharma Date: Fri, 28 Oct 2022 19:03:57 +0530 Subject: [PATCH 6/6] SDK v8.1.1 --- AppNexusSDK.podspec | 2 +- RELEASE-NOTES.md | 7 +++++++ sdk/AppNexusSDK.xcodeproj/project.pbxproj | 12 ++++++------ sdk/sourcefiles/internal/ANGlobal.h | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/AppNexusSDK.podspec b/AppNexusSDK.podspec index 122d35d2..a85ce818 100644 --- a/AppNexusSDK.podspec +++ b/AppNexusSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "AppNexusSDK" - s.version = "8.1.0" + s.version = "8.1.1" s.platform = :ios, "10.0" s.summary = "AppNexus iOS Mobile Advertising SDK" diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 3a61c6ab..1355495e 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,3 +1,10 @@ +## 8.1.1 + +### Improvement/Bug Fixes for macOS SDK ++ MS-5127 Added Impression tracking API for NSView registerViewTracking ++ MS-5128 Code optimizations ++ MS-5149 Fixed Impression tracking issue when app is on secondary displays + ## 8.1.0 ### New Feature diff --git a/sdk/AppNexusSDK.xcodeproj/project.pbxproj b/sdk/AppNexusSDK.xcodeproj/project.pbxproj index 4a10edf0..4af543af 100644 --- a/sdk/AppNexusSDK.xcodeproj/project.pbxproj +++ b/sdk/AppNexusSDK.xcodeproj/project.pbxproj @@ -1854,7 +1854,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 8.1.0; + MARKETING_VERSION = 8.1.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = Xandr.AppNexusNativeMacOSSDK; @@ -1899,7 +1899,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - MARKETING_VERSION = 8.1.0; + MARKETING_VERSION = 8.1.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = Xandr.AppNexusNativeMacOSSDK; @@ -1945,7 +1945,7 @@ "@loader_path/Frameworks", ); LIBRARY_SEARCH_PATHS = ""; - MARKETING_VERSION = 8.1.0; + MARKETING_VERSION = 8.1.1; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "corp.appnexus.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1987,7 +1987,7 @@ "@loader_path/Frameworks", ); LIBRARY_SEARCH_PATHS = ""; - MARKETING_VERSION = 8.1.0; + MARKETING_VERSION = 8.1.1; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "corp.appnexus.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2151,7 +2151,7 @@ "@loader_path/Frameworks", ); LIBRARY_SEARCH_PATHS = ""; - MARKETING_VERSION = 8.1.0; + MARKETING_VERSION = 8.1.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = corp.appnexus.AppNexusSDK; @@ -2202,7 +2202,7 @@ "@loader_path/Frameworks", ); LIBRARY_SEARCH_PATHS = ""; - MARKETING_VERSION = 8.1.0; + MARKETING_VERSION = 8.1.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = corp.appnexus.AppNexusSDK; diff --git a/sdk/sourcefiles/internal/ANGlobal.h b/sdk/sourcefiles/internal/ANGlobal.h index dd7e53bb..6e1fba60 100644 --- a/sdk/sourcefiles/internal/ANGlobal.h +++ b/sdk/sourcefiles/internal/ANGlobal.h @@ -29,9 +29,9 @@ #if !APPNEXUS_NATIVE_MACOS_SDK - #define AN_SDK_VERSION @"8.1.0" + #define AN_SDK_VERSION @"8.1.1" #else - #define AN_SDK_VERSION @"8.1.0-mac" + #define AN_SDK_VERSION @"8.1.1-mac" #endif