Skip to content

Commit

Permalink
Pull request #896: SDK v8.7.0
Browse files Browse the repository at this point in the history
Merge in MOBILE-SDK/app_mobile-sdk-ios from SDKv8.7.0 to master

* commit '251c124917bf655417289d3916727f3e94fdf0db':
  updated release notes
  Updated version 8.7.0
  Pull request #893: MS-5346 Fixed issue when Multiple Banner native rendering ad loading - loads only the last ad
  Pull request #894: MS-5206 Changes for video orientation - iOS
  MS-5344 Outlook reports crashes in prod environment with the SDK updated to 8.2
  MS-5340 module map build fixes
  • Loading branch information
asharmaa committed Jul 6, 2023
2 parents 95b08e5 + 251c124 commit 17a4cd8
Show file tree
Hide file tree
Showing 22 changed files with 207 additions and 55 deletions.
2 changes: 1 addition & 1 deletion AppNexusSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "AppNexusSDK"
s.version = "8.6.0"
s.version = "8.7.0"
s.platform = :ios, "10.0"

s.summary = "AppNexus iOS Mobile Advertising SDK"
Expand Down
8 changes: 8 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 8.7.0

### Improvement/Bug Fixes
+ MS-5346 Fixed issue where only last ad is rendered in a multi ad request for Banner Native Rendering
+ MS-5206 Added support for setting player size and getting video creative width and height for BannerVideo. New API introduced in ANBannerAdView landscapeBannerVideoPlayerSize, portraitBannerVideoPlayerSize, squareBannerVideoPlayerSize , getVideoWidth, getVideoHeight and In ANVideoAdPlayer getVideoWidth and getVideoHeight
+ MS-5344 Gracefully handle error to avoid crash during fetch User agent String
+ MS-5340 Fixed ModuleMap XCFramework Warning

## 8.6.0

### Improvement/Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion sdk/AppNexusNativeSDK/SDK-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<string>8.7.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
40 changes: 20 additions & 20 deletions sdk/AppNexusSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sdk/AppNexusSDK/SDK-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<string>8.7.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
18 changes: 9 additions & 9 deletions sdk/sourcefiles/Resources/MobileVastPlayer.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions sdk/sourcefiles/internal/ANAdFetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
// setVideoAdOrientation is sufficient to BannerAd entry point.
-(void)setVideoAdOrientation:(ANVideoOrientation)videoOrientation;

-(void)setVideoAdWidth:(NSInteger)videoAdWidth;

-(void)setVideoAdHeight:(NSInteger)videoAdHeight;

@end


12 changes: 12 additions & 0 deletions sdk/sourcefiles/internal/ANAdFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,18 @@ - (void) didCompleteFirstLoadFromWebViewController:(ANAdWebViewController *)cont
[self.delegate setVideoAdOrientation:controller.videoAdOrientation];
}
}

if (controller.videoAdWidth) {
if ([self.delegate respondsToSelector:@selector(setVideoAdWidth:)]) {
[self.delegate setVideoAdWidth:controller.videoAdWidth];
}
}

if (controller.videoAdHeight) {
if ([self.delegate respondsToSelector:@selector(setVideoAdHeight:)]) {
[self.delegate setVideoAdHeight:controller.videoAdHeight];
}
}

fetcherResponse = [ANAdFetcherResponse responseWithAdObject: self.adView
andAdObjectHandler: self.adObjectHandler ];
Expand Down
3 changes: 3 additions & 0 deletions sdk/sourcefiles/internal/ANAdViewInternalDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
@protocol ANBannerAdViewInternalDelegate <ANAdViewInternalDelegate>

- (NSNumber *)transitionInProgress;
- (CGSize) landscapeBannerVideoPlayerSize;
- (CGSize) portraitBannerVideoPlayerSize;
- (CGSize) squareBannerVideoPlayerSize;

@end

Expand Down
3 changes: 3 additions & 0 deletions sdk/sourcefiles/internal/ANAdWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@

@property (nonatomic, readwrite, assign) NSTimeInterval checkViewableTimeInterval;
@property (nonatomic, readonly, assign) ANVideoOrientation videoAdOrientation;
@property (nonatomic, readonly, assign) NSInteger videoAdWidth;
@property (nonatomic, readonly, assign) NSInteger videoAdHeight;
@property (nonatomic, readwrite, assign) CGSize videoPlayerSize;


- (instancetype)initWithSize:(CGSize)size
Expand Down
6 changes: 5 additions & 1 deletion sdk/sourcefiles/internal/ANAdWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ @interface ANAdWebViewController () <WKNavigationDelegate, WKUIDelegate, WKScrip
@property (nonatomic, readwrite, strong) NSString *videoXML;
@property (nonatomic, readwrite) BOOL appIsInBackground;
@property (nonatomic, readwrite, assign) ANVideoOrientation videoAdOrientation;

@property (nonatomic, readwrite, assign) NSInteger videoAdWidth;
@property (nonatomic, readwrite, assign) NSInteger videoAdHeight;
@property (nonatomic, readwrite, strong) ANAudioVolumeChangeListener* audioVolumeChange;

@end
Expand Down Expand Up @@ -192,6 +193,7 @@ - (instancetype) initWithSize: (CGSize)size

_webView = [[ANWebView alloc] initWithSize:size URL:[[[ANSDKSettings sharedInstance] baseUrlConfig] videoWebViewUrl] isVASTVideoAd:true];
self.firstNavigation = _webView.navigation;
self.videoPlayerSize = size;
[self loadWebViewWithUserScripts];

UIWindow *currentWindow = [ANGlobal getKeyWindow];
Expand Down Expand Up @@ -449,6 +451,8 @@ - (void) userContentController: (WKUserContentController *)userContentController
if(paramsDictionary.count > 0){
self.videoAdOrientation = [ANGlobal parseVideoOrientation:[paramsDictionary objectForKey:kANAspectRatio]];
}
self.videoAdWidth = [[paramsDictionary objectForKey:@"width"] integerValue];
self.videoAdHeight = [[paramsDictionary objectForKey:@"height"] integerValue];
// For VideoAds's wait unitll adReady to create AdSession if not the adsession will run in limited access mode.
self.omidAdSession = [[ANOMIDImplementation sharedInstance] createOMIDAdSessionforWebView:self.webView isVideoAd:true];
if ([self.videoDelegate respondsToSelector:@selector(videoAdReady)]) {
Expand Down
39 changes: 38 additions & 1 deletion sdk/sourcefiles/internal/ANBannerAdView.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ @interface ANBannerAdView() <ANBannerAdViewInternalDelegate, ANRealTimerDelegate

@property (nonatomic, readwrite, assign) ANVideoOrientation videoAdOrientation;

@property (nonatomic, readwrite, assign) NSInteger videoAdWidth;

@property (nonatomic, readwrite, assign) NSInteger videoAdHeight;

@property (nonatomic, readwrite, assign) ANImpressionType impressionType;

/**
Expand Down Expand Up @@ -113,8 +117,10 @@ @implementation ANBannerAdView
@synthesize adResponseInfo = _adResponseInfo;
@synthesize minDuration = __minDuration;
@synthesize maxDuration = __maxDuration;

@synthesize enableLazyLoad = _enableLazyLoad;
@synthesize landscapeBannerVideoPlayerSize = _landscapeBannerVideoPlayerSize;
@synthesize portraitBannerVideoPlayerSize = _portraitBannerVideoPlayerSize;
@synthesize squareBannerVideoPlayerSize = _squareBannerVideoPlayerSize;


#pragma mark - Lifecycle.
Expand All @@ -139,6 +145,11 @@ - (void)initialize {

_nativeAdRendererId = 0;
_videoAdOrientation = ANUnknown;
_videoAdWidth = 0;
_videoAdHeight = 0;
_landscapeBannerVideoPlayerSize = CGSizeMake(1, 1);
_portraitBannerVideoPlayerSize = CGSizeMake(1, 1);
_squareBannerVideoPlayerSize = CGSizeMake(1, 1);

self.allowSmallerSizes = NO;
self.loadAdHasBeenInvoked = NO;
Expand Down Expand Up @@ -271,6 +282,22 @@ - (ANVideoOrientation) getVideoOrientation {
return _videoAdOrientation;
}

-(void)setVideoAdWidth:(NSInteger)videoWidth{
_videoAdWidth = videoWidth;
}

- (NSInteger) getVideoWidth {
return _videoAdWidth;
}

-(void)setVideoAdHeight:(NSInteger)videoHeight{
_videoAdHeight = videoHeight;
}

- (NSInteger) getVideoHeight {
return _videoAdHeight;
}

- (CGSize)adSize {
ANLogDebug(@"adSize returned %@", NSStringFromCGSize(_adSize));
return _adSize;
Expand Down Expand Up @@ -660,6 +687,16 @@ - (void)adFetcher:(ANAdFetcher *)fetcher didFinishRequestWithResponse:(ANAdFetch
if(self.contentView == nil){
self.contentView = adObject;
}

// Once the contentView is set Video will resize based on user set size(landscape/portrait/squareBannerVideoPlayerSize),
// we need to update the loaded Ad Size
if ((_adResponseInfo.adType == ANAdTypeVideo))
{
if([self.contentView isKindOfClass:[ANMRAIDContainerView class]]){
ANMRAIDContainerView *adView = (ANMRAIDContainerView *)self.contentView;
_loadedAdSize = adView.webViewController.videoPlayerSize;
}
}

// Only Fire OMID Impression here for Begin to Render Cases. If it is Begin To Render then impression would have already fired from [ANAdFetcher fireImpressionTrackersEarly]
if(self.impressionType == ANBeginToRender){
Expand Down
4 changes: 2 additions & 2 deletions sdk/sourcefiles/internal/ANGlobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


#if !APPNEXUS_NATIVE_MACOS_SDK
#define AN_SDK_VERSION @"8.6.0"
#define AN_SDK_VERSION @"8.7.0"
#else
#define AN_SDK_VERSION @"8.6.0-mac"
#define AN_SDK_VERSION @"8.7.0-mac"
#endif


Expand Down
38 changes: 22 additions & 16 deletions sdk/sourcefiles/internal/ANGlobal.m
Original file line number Diff line number Diff line change
Expand Up @@ -537,23 +537,29 @@ + (void) getUserAgent

dispatch_async(dispatch_get_main_queue(),
^{
webViewForUserAgent = [WKWebView new];
[webViewForUserAgent evaluateJavaScript: @"navigator.userAgent"
completionHandler: ^(id __nullable userAgentString, NSError * __nullable error)
{
if (error != nil) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"kUserAgentFailedToChangeNotification" object:nil userInfo: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;
@try {
webViewForUserAgent = [[WKWebView alloc] initWithFrame:CGRectZero];;
[webViewForUserAgent evaluateJavaScript: @"navigator.userAgent"
completionHandler: ^(id __nullable userAgentString, NSError * __nullable error)
{
if (error != nil) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"kUserAgentFailedToChangeNotification" object:nil userInfo: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;
}];
webViewForUserAgent = nil;
}];
}
@catch (NSException *exception) {
ANLogError(@"Failed to fetch UserAgent with exception (%@)", exception);
}

});
}
ANLogDebug(@"userAgent=%@", anUserAgent);
Expand Down
5 changes: 5 additions & 0 deletions sdk/sourcefiles/internal/ANWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

-(instancetype) initWithSize:(CGSize)size URL:(NSURL *)URL;
-(instancetype) initWithSize:(CGSize)size URL:(NSURL *)URL isVASTVideoAd:(BOOL)videoAd;
-(instancetype) initWithSize:(CGSize)size
content:(NSString *)htmlContent
baseURL:(NSURL *)baseURL
isNativeRenderingAd:(BOOL)nativeRenderingAd;


-(void) loadWithSize:(CGSize)size content:(NSString *) contentString baseURL:(NSURL *)baseURL;

Expand Down
10 changes: 9 additions & 1 deletion sdk/sourcefiles/internal/ANWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

@interface ANWebView ()
@property (nonatomic, readwrite, assign) BOOL isVASTVideoAd;
@property (nonatomic, readwrite, assign) BOOL isNativeRenderingAd;
@end


Expand All @@ -42,7 +43,7 @@ -(instancetype) initWithSize:(CGSize)size
{
[[self class] loadWebViewConfigurations];
WKWebViewConfiguration *configuration;
if(self.isVASTVideoAd){
if(self.isVASTVideoAd || self.isNativeRenderingAd){
configuration = [[self class] prepareWebConfiguration];
}else{
configuration = [[self class] webConfiguration];
Expand Down Expand Up @@ -100,6 +101,13 @@ -(instancetype) initWithSize:(CGSize)size content:(NSString *)htmlContent baseUR
[self loadHTMLString:htmlContent baseURL:baseURL];
return self;
}

-(instancetype) initWithSize:(CGSize)size content:(NSString *)htmlContent baseURL:(NSURL *)baseURL isNativeRenderingAd:(BOOL)nativeRenderingAd
{
self.isNativeRenderingAd = nativeRenderingAd;
return [self initWithSize:size content:htmlContent baseURL:baseURL];

}

-(instancetype) initWithSize:(CGSize)size URL:(NSURL *)URL isVASTVideoAd:(BOOL)videoAd {
self.isVASTVideoAd = videoAd;
Expand Down
32 changes: 32 additions & 0 deletions sdk/sourcefiles/internal/MRAID/ANMRAIDContainerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,38 @@ - (void)setAdViewDelegate:(id<ANAdViewInternalDelegate>)adViewDelegate
[self addSupplementaryCustomCloseRegion];
}
}


if ([_adViewDelegate conformsToProtocol:@protocol(ANBannerAdViewInternalDelegate)])
{
id<ANBannerAdViewInternalDelegate> bannerDelegate = (id<ANBannerAdViewInternalDelegate>)_adViewDelegate;

UIView *contentView = self.webViewController.contentView;
CGSize newPlayerSize = kANAdSize1x1;
switch (self.webViewController.videoAdOrientation){
case ANPortrait:
newPlayerSize = bannerDelegate.portraitBannerVideoPlayerSize;
break;
case ANSquare:
newPlayerSize = bannerDelegate.squareBannerVideoPlayerSize;
break;
case ANLandscape:
case ANUnknown:
newPlayerSize = bannerDelegate.landscapeBannerVideoPlayerSize;
break;
}

if (!CGSizeEqualToSize(newPlayerSize, CGSizeMake(1, 1))) {
self.webViewController.videoPlayerSize = newPlayerSize;
CGRect updatedRect = CGRectMake(0, 0, newPlayerSize.width, newPlayerSize.height);
[self setFrame:updatedRect];

contentView.translatesAutoresizingMaskIntoConstraints = NO;
[contentView an_constrainToSizeOfSuperview];
[contentView an_alignToSuperviewWithXAttribute:NSLayoutAttributeLeft
yAttribute:NSLayoutAttributeTop];
}
}
}

- (void)setAdInteractionInProgress:(BOOL)adInteractionInProgress {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ - (void)initANWebViewWithSize:(CGSize)size
base = [NSURL URLWithString:[[[ANSDKSettings sharedInstance] baseUrlConfig] webViewBaseUrl]];
}

_webView = [ANWebView fetchWebView];
_webView = [[ANWebView alloc] initWithSize:size content:html baseURL:base isNativeRenderingAd:YES];

[_webView loadWithSize:size content:html baseURL:base];
// [_webView loadWithSize:size content:html baseURL:base];

[self configureWebView];
}
Expand Down
6 changes: 6 additions & 0 deletions sdk/sourcefiles/public-headers/ANAdProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ Set the trafficSourceCode, Specifies the third-party source of the impression.
* @return Default VideoOrientation value ANUnknown, which indicates that aspectRatio can't be retrieved for the video.
*/
- (ANVideoOrientation) getVideoOrientation;

- (NSInteger) getVideoWidth;

- (NSInteger) getVideoHeight;


@end


Expand Down
6 changes: 6 additions & 0 deletions sdk/sourcefiles/public-headers/ANBannerAdView.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ typedef NS_ENUM(NSUInteger, ANBannerViewAdAlignment) {
*/
@property (nonatomic, readwrite) BOOL shouldAllowVideoDemand;

@property (nonatomic, readwrite, assign) CGSize landscapeBannerVideoPlayerSize;

@property (nonatomic, readwrite, assign) CGSize portraitBannerVideoPlayerSize;

@property (nonatomic, readwrite, assign) CGSize squareBannerVideoPlayerSize;

/**
* Sets whether or not Native Ads(AppNexus Media Type:12) can serve on this Ad object.
*
Expand Down
4 changes: 4 additions & 0 deletions sdk/sourcefiles/video/ANVideoAdPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,9 @@ typedef NS_ENUM(NSUInteger, ANVideoAdPlayerEvent) {
*/
- (ANVideoOrientation) getVideoOrientation;

- (NSInteger) getVideoWidth;

- (NSInteger) getVideoHeight;

@end

Loading

0 comments on commit 17a4cd8

Please sign in to comment.