Skip to content

Commit

Permalink
5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kdun committed May 11, 2018
1 parent 033f583 commit 35b74a5
Show file tree
Hide file tree
Showing 254 changed files with 8,003 additions and 4,281 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## Version 5.0.0 (May 14, 2018)
- **Features**
- General Data Protection Regulation (GDPR) update to support a way for publishers to determine GDPR applicability and to obtain and manage consent from users in European Economic Area, the United Kingdom, or Switzerland to serve personalize ads.
- New SDK initialization method to initialize consent management and rewarded video ad networks. Required for receiving personalized ads. In future versions of the SDK, initialization will be required to receive ads.
- Updated the networking stack to use `NSURLSession` in place of the deprecated `NSURLConnection`.
- Updated ad requests to use POST instead of GET.

- **Bug Fixes**
- Renamed the `/MoPubSDK/Native Ads/` folder to `/MoPubSDK/NativeAds/`.
- Removed the usage of deprecated `shouldAutorotateToInterfaceOrientation`.

## Version 4.20.1 (March 12, 2018)
- **Bug Fixes**
- Fixes compatibility issues with some fullscreen ads on iPhone X
Expand Down
10 changes: 5 additions & 5 deletions MoPubResources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleIdentifier</key>
<string>com.MoPub.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand All @@ -16,10 +16,10 @@
<string>4.0.0+kit</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>4.0.0+kit</string>
<key>NSHumanReadableCopyright</key>
Expand Down
501 changes: 324 additions & 177 deletions MoPubSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions MoPubSDK/Internal/Banners/MPBannerAdManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (id)initWithDelegate:(id<MPBannerAdManagerDelegate>)delegate
if (self) {
self.delegate = delegate;

self.communicator = [[MPCoreInstanceProvider sharedProvider] buildMPAdServerCommunicatorWithDelegate:self];
self.communicator = [[MPAdServerCommunicator alloc] initWithDelegate:self];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground)
Expand Down Expand Up @@ -159,8 +159,8 @@ - (void)loadAdWithURL:(NSURL *)URL

URL = (URL) ? URL : [MPAdServerURLBuilder URLWithAdUnitID:[self.delegate adUnitId]
keywords:[self.delegate keywords]
location:[self.delegate location]
testing:[self.delegate isTesting]];
userDataKeywords:[self.delegate userDataKeywords]
location:[self.delegate location]];

MPLogInfo(@"Banner view (%@) loading ad with MoPub server URL: %@", [self.delegate adUnitId], URL);

Expand Down Expand Up @@ -200,43 +200,43 @@ - (void)refreshTimerDidFire

#pragma mark - <MPAdServerCommunicatorDelegate>

- (void)communicatorDidReceiveAdConfiguration:(MPAdConfiguration *)configuration
- (void)communicatorDidReceiveAdConfigurations:(NSArray<MPAdConfiguration *> *)configurations
{
self.requestingConfiguration = configuration;
self.requestingConfiguration = configurations.firstObject;

MPLogInfo(@"Banner ad view is fetching ad network type: %@", self.requestingConfiguration.networkType);

if (configuration.adType == MPAdTypeUnknown) {
if (self.requestingConfiguration.adType == MPAdTypeUnknown) {
[self didFailToLoadAdapterWithError:[MOPUBError errorWithCode:MOPUBErrorServerError]];
return;
}

if (configuration.adType == MPAdTypeInterstitial) {
if (self.requestingConfiguration.adType == MPAdTypeInterstitial) {
MPLogWarn(@"Could not load ad: banner object received an interstitial ad unit ID.");
[self didFailToLoadAdapterWithError:[MOPUBError errorWithCode:MOPUBErrorAdapterInvalid]];
return;
}

if (configuration.adUnitWarmingUp) {
if (self.requestingConfiguration.adUnitWarmingUp) {
MPLogInfo(kMPWarmingUpErrorLogFormatWithAdUnitID, self.delegate.adUnitId);
[self didFailToLoadAdapterWithError:[MOPUBError errorWithCode:MOPUBErrorAdUnitWarmingUp]];
return;
}

if ([configuration.networkType isEqualToString:kAdTypeClear]) {
if ([self.requestingConfiguration.networkType isEqualToString:kAdTypeClear]) {
MPLogInfo(kMPClearErrorLogFormatWithAdUnitID, self.delegate.adUnitId);
[self didFailToLoadAdapterWithError:[MOPUBError errorWithCode:MOPUBErrorNoInventory]];
return;
}

self.requestingAdapter = [[MPBannerCustomEventAdapter alloc] initWithConfiguration:configuration
self.requestingAdapter = [[MPBannerCustomEventAdapter alloc] initWithConfiguration:self.requestingConfiguration
delegate:self];
if (!self.requestingAdapter) {
[self loadAdWithURL:self.requestingConfiguration.failoverURL];
return;
}

[self.requestingAdapter _getAdWithConfiguration:configuration containerSize:self.delegate.containerSize];
[self.requestingAdapter _getAdWithConfiguration:self.requestingConfiguration containerSize:self.delegate.containerSize];
}

- (void)communicatorDidFailWithError:(NSError *)error
Expand Down
2 changes: 1 addition & 1 deletion MoPubSDK/Internal/Banners/MPBannerAdManagerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
- (id<MPAdViewDelegate>)bannerDelegate;
- (CGSize)containerSize;
- (NSString *)keywords;
- (NSString *)userDataKeywords;
- (CLLocation *)location;
- (BOOL)isTesting;
- (UIViewController *)viewControllerForPresentingModalView;

- (void)invalidateContentView;
Expand Down
3 changes: 2 additions & 1 deletion MoPubSDK/Internal/Banners/MPBannerCustomEventAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ - (void)getAdWithConfiguration:(MPAdConfiguration *)configuration containerSize:
return;
}


self.bannerCustomEvent = customEvent;
self.bannerCustomEvent.delegate = self;
[self.bannerCustomEvent requestAdWithSize:size customEventInfo:configuration.customEventClassData];
[self.bannerCustomEvent requestAdWithSize:size customEventInfo:configuration.customEventClassData adMarkup:configuration.advancedBidPayload];
}

- (void)rotateToOrientation:(UIInterfaceOrientation)newOrientation
Expand Down
8 changes: 4 additions & 4 deletions MoPubSDK/Internal/Common/MPAPIEndpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
#import <Foundation/Foundation.h>

#define MOPUB_BASE_HOSTNAME @"ads.mopub.com"
#define MOPUB_BASE_HOSTNAME_FOR_TESTING @"testing.ads.mopub.com"

#define MOPUB_API_PATH_AD_REQUEST @"/m/ad"
#define MOPUB_API_PATH_CONVERSION @"/m/open"
#define MOPUB_API_PATH_NATIVE_POSITIONING @"/m/pos"
#define MOPUB_API_PATH_SESSION @"/m/open"
#define MOPUB_API_PATH_OPEN @"/m/open"
#define MOPUB_API_PATH_CONSENT_DIALOG @"/m/gdpr_consent_dialog"
#define MOPUB_API_PATH_CONSENT_SYNC @"/m/gdpr_sync"

@interface MPAPIEndpoints : NSObject

+ (void)setUsesHTTPS:(BOOL)usesHTTPS;
+ (NSString *)baseURL;
+ (NSString *)baseURLStringWithPath:(NSString *)path testing:(BOOL)testing;
+ (NSString *)baseURLStringWithPath:(NSString *)path;

@end
4 changes: 2 additions & 2 deletions MoPubSDK/Internal/Common/MPAPIEndpoints.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ + (NSString *)baseURLScheme
return sUsesHTTPS ? @"https://" : @"http://";
}

+ (NSString *)baseURLStringWithPath:(NSString *)path testing:(BOOL)testing
+ (NSString *)baseURLStringWithPath:(NSString *)path
{
return [NSString stringWithFormat:@"%@%@%@",
[[self class] baseURLScheme],
testing ? MOPUB_BASE_HOSTNAME_FOR_TESTING : MOPUB_BASE_HOSTNAME,
MOPUB_BASE_HOSTNAME,
path];
}

Expand Down
3 changes: 1 addition & 2 deletions MoPubSDK/Internal/Common/MPActivityViewControllerHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ - (BOOL)presentActivityViewControllerWithSubject:(NSString *)subject body:(NSStr
[self.delegate activityViewControllerWillPresent];
}

UIUserInterfaceIdiom userInterfaceIdiom = [[[MPCoreInstanceProvider sharedProvider]
sharedCurrentDevice] userInterfaceIdiom];
UIUserInterfaceIdiom userInterfaceIdiom = UIDevice.currentDevice.userInterfaceIdiom;
// iPad must present as popover on iOS >= 8
if (userInterfaceIdiom == UIUserInterfaceIdiomPad) {
if ([activityViewController respondsToSelector:@selector(popoverPresentationController)]) {
Expand Down
36 changes: 2 additions & 34 deletions MoPubSDK/Internal/Common/MPAdBrowserController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

#import "MPAdBrowserController.h"
#import "MPLogging.h"
#import "MPLogEvent.h"
#import "MPLogEventRecorder.h"
#import "MPAdConfiguration.h"
#import "MPAPIEndpoints.h"
#import "NSBundle+MPAdditions.h"
#import "MPURLRequest.h"

static NSString * const kAdBrowserControllerNibName = @"MPAdBrowserController";

Expand All @@ -31,8 +30,6 @@ @interface MPAdBrowserController ()
@property (nonatomic, strong) UIActionSheet *actionSheet;
@property (nonatomic, strong) NSString *HTMLString;
@property (nonatomic, assign) int webViewLoadCount;
@property (nonatomic) MPLogEvent *dwellEvent;
@property (nonatomic) BOOL hasAppeared;

- (void)dismissActionSheet;

Expand All @@ -58,8 +55,6 @@ - (instancetype)initWithURL:(NSURL *)URL HTMLString:(NSString *)HTMLString deleg
self.spinner.hidesWhenStopped = YES;

self.webViewLoadCount = 0;

_hasAppeared = NO;
}
return self;
}
Expand Down Expand Up @@ -140,20 +135,12 @@ - (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];

// Track when this view first appears so we can log the time the user stays in the view controller. Creating the event will mark the start of the dwell time.
// Make sure we don't create the event twice.
if (!self.hasAppeared) {
self.dwellEvent = [[MPLogEvent alloc] initWithEventCategory:MPLogEventCategoryAdInteractions eventName:MPLogEventNameClickthroughDwellTime];
}

self.hasAppeared = YES;

NSURL *baseURL = (self.URL != nil) ? self.URL : [NSURL URLWithString:[MPAPIEndpoints baseURL]];

if (self.HTMLString) {
[self.webView loadHTMLString:self.HTMLString baseURL:baseURL];
} else {
[self.webView loadRequest:[NSURLRequest requestWithURL:self.URL]];
[self.webView loadRequest:[MPURLRequest requestWithURL:self.URL]];
}
}

Expand Down Expand Up @@ -187,18 +174,6 @@ - (IBAction)done
} else {
[self dismissViewControllerAnimated:MP_ANIMATED completion:nil];
}

if ([self.delegate respondsToSelector:@selector(adConfiguration)]) {
MPAdConfiguration *configuration = [self.delegate adConfiguration];

if (configuration) {
MPAdConfigurationLogEventProperties *logProperties = [[MPAdConfigurationLogEventProperties alloc] initWithConfiguration:configuration];
[self.dwellEvent setLogEventProperties:logProperties];
[self.dwellEvent recordEndTime];

MPAddLogEvent(self.dwellEvent);
}
}
}

- (IBAction)back
Expand Down Expand Up @@ -367,11 +342,4 @@ - (UIImage *)forwardArrowImage
return image;
}

#pragma mark -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

@end
3 changes: 1 addition & 2 deletions MoPubSDK/Internal/Common/MPAdConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extern NSString * const kCustomEventClassDataHeaderKey;
extern NSString * const kFailUrlHeaderKey;
extern NSString * const kHeightHeaderKey;
extern NSString * const kImpressionTrackerHeaderKey;
extern NSString * const kInterceptLinksHeaderKey;
extern NSString * const kLaunchpageHeaderKey;
extern NSString * const kNativeSDKParametersHeaderKey;
extern NSString * const kNetworkTypeHeaderKey;
Expand Down Expand Up @@ -72,7 +71,6 @@ extern NSString * const kBannerImpressionMinPixelHeaderKey;
@property (nonatomic, strong) NSURL *impressionTrackingURL;
@property (nonatomic, strong) NSURL *failoverURL;
@property (nonatomic, strong) NSURL *interceptURLPrefix;
@property (nonatomic, assign) BOOL shouldInterceptLinks;
@property (nonatomic, assign) BOOL scrollable;
@property (nonatomic, assign) NSTimeInterval refreshInterval;
@property (nonatomic, assign) NSTimeInterval adTimeoutInterval;
Expand Down Expand Up @@ -100,6 +98,7 @@ extern NSString * const kBannerImpressionMinPixelHeaderKey;
@property (nonatomic, copy) NSString *rewardedVideoCompletionUrl;
@property (nonatomic, assign) NSTimeInterval rewardedPlayableDuration;
@property (nonatomic, assign) BOOL rewardedPlayableShouldRewardOnClick;
@property (nonatomic, copy) NSString *advancedBidPayload;


// viewable impression tracking experiment
Expand Down
17 changes: 11 additions & 6 deletions MoPubSDK/Internal/Common/MPAdConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

#import "MPAdConfiguration.h"

#import "MOPUBExperimentProvider.h"
#import "MPConsentAdServerKeys.h"
#import "MPConsentManager.h"
#import "MPConstants.h"
#import "MPLogging.h"
#import "math.h"
#import "NSJSONSerialization+MPAdditions.h"
#import "MPRewardedVideoReward.h"
#import "MOPUBExperimentProvider.h"
#import "MPViewabilityTracker.h"
#import "NSJSONSerialization+MPAdditions.h"
#import "NSString+MPAdditions.h"

#if MP_HAS_NATIVE_PACKAGE
Expand All @@ -30,7 +31,6 @@
NSString * const kFailUrlHeaderKey = @"X-Failurl";
NSString * const kHeightHeaderKey = @"X-Height";
NSString * const kImpressionTrackerHeaderKey = @"X-Imptracker";
NSString * const kInterceptLinksHeaderKey = @"X-Interceptlinks";
NSString * const kLaunchpageHeaderKey = @"X-Launchpage";
NSString * const kNativeSDKParametersHeaderKey = @"X-Nativeparams";
NSString * const kNetworkTypeHeaderKey = @"X-Networktype";
Expand Down Expand Up @@ -132,8 +132,6 @@ - (id)initWithHeaders:(NSDictionary *)headers data:(NSData *)data
self.interceptURLPrefix = [self URLFromHeaders:headers
forKey:kLaunchpageHeaderKey];

NSNumber *shouldInterceptLinks = [headers objectForKey:kInterceptLinksHeaderKey];
self.shouldInterceptLinks = shouldInterceptLinks ? [shouldInterceptLinks boolValue] : YES;
self.scrollable = [[headers objectForKey:kScrollableHeaderKey] boolValue];
self.refreshInterval = [self refreshIntervalFromHeaders:headers];
self.adTimeoutInterval = [self timeIntervalFromHeaders:headers forKey:kAdTimeoutHeaderKey];
Expand Down Expand Up @@ -232,6 +230,13 @@ - (id)initWithHeaders:(NSDictionary *)headers data:(NSData *)data
MPViewabilityOption vendorsToDisable = (MPViewabilityOption)([disabledViewabilityVendors integerValue]);
[MPViewabilityTracker disableViewability:vendorsToDisable];
}

// consent
[[MPConsentManager sharedManager] forceStatusShouldForceExplicitNo:[headers[kForceExplicitNoKey] boolValue]
shouldInvalidateConsent:[headers[kInvalidateConsentKey] boolValue]
shouldReacquireConsent:[headers[kReacquireConsentKey] boolValue]
consentChangeReason:headers[kConsentChangedReasonKey]
shouldBroadcast:YES];
}
return self;
}
Expand Down
35 changes: 16 additions & 19 deletions MoPubSDK/Internal/Common/MPAdDestinationDisplayAgent.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,12 @@ - (void)displayDestinationForURL:(NSURL *)URL
[self.enhancedDeeplinkFallbackResolver cancel];

__weak __typeof__(self) weakSelf = self;
self.resolver = [[MPCoreInstanceProvider sharedProvider] buildMPURLResolverWithURL:URL completion:^(MPURLActionInfo *suggestedAction, NSError *error) {
self.resolver = [MPURLResolver resolverWithURL:URL completion:^(MPURLActionInfo *suggestedAction, NSError *error) {
__typeof__(self) strongSelf = weakSelf;
if (strongSelf) {
if (error) {
[strongSelf failedToResolveURLWithError:error];
} else {
[strongSelf handleSuggestedURLAction:suggestedAction isResolvingEnhancedDeeplink:NO];
}
if (error) {
[strongSelf failedToResolveURLWithError:error];
} else {
[strongSelf handleSuggestedURLAction:suggestedAction isResolvingEnhancedDeeplink:NO];
}
}];

Expand Down Expand Up @@ -182,19 +180,18 @@ - (void)handleEnhancedDeeplinkFallbackForRequest:(MPEnhancedDeeplinkRequest *)re
{
__weak __typeof__(self) weakSelf = self;
[self.enhancedDeeplinkFallbackResolver cancel];
self.enhancedDeeplinkFallbackResolver = [[MPCoreInstanceProvider sharedProvider] buildMPURLResolverWithURL:request.fallbackURL completion:^(MPURLActionInfo *actionInfo, NSError *error) {
self.enhancedDeeplinkFallbackResolver = [MPURLResolver resolverWithURL:request.fallbackURL completion:^(MPURLActionInfo *actionInfo, NSError *error) {
__typeof__(self) strongSelf = weakSelf;
if (strongSelf) {
if (error) {
// If the resolver fails, just treat the entire original URL as a regular deeplink.
[strongSelf openURLInApplication:request.originalURL];
} else {
// Otherwise, the resolver will return us a URL action. We process that action
// normally with one exception: we don't follow any nested enhanced deeplinks.
BOOL success = [strongSelf handleSuggestedURLAction:actionInfo isResolvingEnhancedDeeplink:YES];
if (success) {
[[[MPCoreInstanceProvider sharedProvider] sharedMPAnalyticsTracker] sendTrackingRequestForURLs:request.fallbackTrackingURLs];
}
if (error) {
// If the resolver fails, just treat the entire original URL as a regular deeplink.
[strongSelf openURLInApplication:request.originalURL];
}
else {
// Otherwise, the resolver will return us a URL action. We process that action
// normally with one exception: we don't follow any nested enhanced deeplinks.
BOOL success = [strongSelf handleSuggestedURLAction:actionInfo isResolvingEnhancedDeeplink:YES];
if (success) {
[[[MPCoreInstanceProvider sharedProvider] sharedMPAnalyticsTracker] sendTrackingRequestForURLs:request.fallbackTrackingURLs];
}
}
}];
Expand Down
Loading

0 comments on commit 35b74a5

Please sign in to comment.