Skip to content

Commit

Permalink
4.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-lee committed Mar 12, 2018
1 parent cd95f66 commit 033f583
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 157 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 4.20.1 (March 12, 2018)
- **Bug Fixes**
- Fixes compatibility issues with some fullscreen ads on iPhone X

## Version 4.20.0 (February 20, 2018)
- **Bug Fixes**
- Fixed ad expiration check for rewarded ad formats
Expand Down
1 change: 1 addition & 0 deletions MoPubSDK/Internal/HTML/MPAdWebViewAgent.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ - (void)loadConfiguration:(MPAdConfiguration *)configuration
self.view = nil;
}
self.view = [[MPWebView alloc] initWithFrame:self.frame];
self.view.shouldConformToSafeArea = [self isInterstitialAd];
self.view.delegate = self;
[self.view addGestureRecognizer:self.userInteractionRecognizer];

Expand Down
10 changes: 10 additions & 0 deletions MoPubSDK/Internal/HTML/MPWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ typedef void (^MPWebViewJavascriptEvaluationCompletionHandler)(id result, NSErro

@property (weak, nonatomic) id<MPWebViewDelegate> delegate;

// When set to `YES`, `shouldConformToSafeArea` sets constraints on the WKWebView to always stay within the safe area
// using the MPWebView's safeAreaLayoutGuide. Otherwise, the WKWebView will be constrained directly to MPWebView's
// anchors to fill the whole container. Default is `NO`.
//
// This property has no effect on versions of iOS less than 11 or phones other than iPhone X.
//
// This property has no effect on UIWebView-based MPWebViews, as UIWebView only supports springs and struts, however
// this should not be an issue because UIWebView doesn't seem to be glitchy with the safe area.
@property (nonatomic, assign) BOOL shouldConformToSafeArea;

@property (nonatomic, readonly, getter=isLoading) BOOL loading;

// These methods and properties are non-functional below iOS 9. If you call or try to set them, they'll do nothing.
Expand Down
42 changes: 42 additions & 0 deletions MoPubSDK/Internal/HTML/MPWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ @interface MPWebView () <UIWebViewDelegate, WKNavigationDelegate, WKUIDelegate,
@property (weak, nonatomic) WKWebView *wkWebView;
@property (weak, nonatomic) UIWebView *uiWebView;

@property (strong, nonatomic) NSArray<NSLayoutConstraint *> *wkWebViewLayoutConstraints;

@property (nonatomic, assign) BOOL hasMovedToWindow;

@end
Expand Down Expand Up @@ -113,6 +115,9 @@ - (void)setUpStepsForceUIWebView:(BOOL)forceUIWebView {
// set default scalesPageToFit
self.scalesPageToFit = NO;

// set default `shouldConformToSafeArea`
self.shouldConformToSafeArea = NO;

// configure like the old MPAdWebView
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
Expand Down Expand Up @@ -167,6 +172,7 @@ - (void)didMoveToWindow {
&& [self.wkWebView.superview isEqual:gOffscreenView]) {
self.wkWebView.frame = self.bounds;
[self addSubview:self.wkWebView];
[self constrainWebViewShouldUseSafeArea:self.shouldConformToSafeArea];
self.hasMovedToWindow = YES;

// Don't keep OffscreenView if we don't need it; it can always be re-allocated again later
Expand Down Expand Up @@ -218,6 +224,42 @@ - (void)dealloc {
[self cleanUpOffscreenView];
}

- (void)setShouldConformToSafeArea:(BOOL)shouldConformToSafeArea {
_shouldConformToSafeArea = shouldConformToSafeArea;

if (self.hasMovedToWindow) {
[self constrainWebViewShouldUseSafeArea:shouldConformToSafeArea];
}
}

- (void)constrainWebViewShouldUseSafeArea:(BOOL)shouldUseSafeArea {
if (@available(iOS 11.0, *)) {
self.wkWebView.translatesAutoresizingMaskIntoConstraints = NO;

if (self.wkWebViewLayoutConstraints) {
[NSLayoutConstraint deactivateConstraints:self.wkWebViewLayoutConstraints];
}

if (shouldUseSafeArea) {
self.wkWebViewLayoutConstraints = @[
[self.wkWebView.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor],
[self.wkWebView.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor],
[self.wkWebView.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor],
[self.wkWebView.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor],
];
} else {
self.wkWebViewLayoutConstraints = @[
[self.wkWebView.topAnchor constraintEqualToAnchor:self.topAnchor],
[self.wkWebView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
[self.wkWebView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor],
[self.wkWebView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
];
}

[NSLayoutConstraint activateConstraints:self.wkWebViewLayoutConstraints];
}
}

- (BOOL)isLoading {
return self.uiWebView ? self.uiWebView.isLoading : self.wkWebView.isLoading;
}
Expand Down
1 change: 1 addition & 0 deletions MoPubSDK/Internal/MRAID/MRController.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ - (void)loadAdWithConfiguration:(MPAdConfiguration *)configuration

self.mraidWebView = [self buildMRAIDWebViewWithFrame:self.mraidDefaultAdFrame
forceUIWebView:self.shouldUseUIWebView];
self.mraidWebView.shouldConformToSafeArea = [self isInterstitialAd];

self.mraidBridge = [[MPInstanceProvider sharedProvider] buildMRBridgeWithWebView:self.mraidWebView delegate:self];
self.mraidAdView = [[MPInstanceProvider sharedProvider] buildMRAIDMPClosableViewWithFrame:self.mraidDefaultAdFrame
Expand Down
2 changes: 1 addition & 1 deletion MoPubSDK/MPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define DEFAULT_PUB_ID @"agltb3B1Yi1pbmNyDAsSBFNpdGUYkaoMDA"
#define MP_SERVER_VERSION @"8"
#define MP_BUNDLE_IDENTIFIER @"com.mopub.mopub"
#define MP_SDK_VERSION @"4.20.0"
#define MP_SDK_VERSION @"4.20.1"

// Sizing constants.
extern CGSize const MOPUB_BANNER_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion MoPubSDKFramework/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>4.20.0</string>
<string>4.20.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The MoPub SDK is distributed as source code that you can include in your applica

Includes everything you need to serve HTML and MRAID advertisements. Third party ad networks and Native MoPub advertisements are not included.

The current version of the SDK is 4.20.0
The current version of the SDK is 4.20.1

## Integrate

Expand All @@ -46,15 +46,12 @@ More detailed class documentation is available in the repo under the `ClassDocum
Please view the [changelog](https://github.com/mopub/mopub-ios-sdk/blob/master/CHANGELOG.md) for details.

- **Bug Fixes**
- Fixed ad expiration check for rewarded ad formats

- **Ad Network Mediation Updates**
- Network mediation adapters are now in a separate repository to enable an independent release cadence and faster updates to the adapters. Please find the new location [here](https://github.com/mopub/mopub-ios-mediation).
- Fixes compatibility issues with some fullscreen ads on iPhone X

See the [Getting Started Guide](https://github.com/mopub/mopub-ios-sdk/wiki/Getting-Started#app-transport-security-settings) for instructions on setting up ATS in your app.

### <a name="disableViewability"></a>Disabling Viewability Measurement
There are a few options for opting out of viewability measurement:
There are a few options for opting out of viewability measurement:
##### Opting Out in a Manual Integration
Before dragging the MoPubSDK folder into your Xcode project, simply delete the “Moat” folder to opt out of Moat or the “Avid” folder to opt out of IAS in MoPubSDK/Viewability/. If you would like to opt out of both, delete both folders.
##### Opting Out in a CocoaPods Integration
Expand Down
Loading

0 comments on commit 033f583

Please sign in to comment.