Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/max mrec support #21

Merged
merged 16 commits into from
May 15, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
1D992FE6231FA1C400C472F8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1D992FE4231FA1C400C472F8 /* Main.storyboard */; };
1D992FE8231FA1C500C472F8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1D992FE7231FA1C500C472F8 /* Assets.xcassets */; };
1D992FEB231FA1C500C472F8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1D992FE9231FA1C500C472F8 /* LaunchScreen.storyboard */; };
37B6CED5246E04FC0068A6A4 /* ALMAXAutoLayoutMRecAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 37B6CED4246E04FC0068A6A4 /* ALMAXAutoLayoutMRecAdViewController.m */; };
37B6CED8246E05770068A6A4 /* ALMAXFrameLayoutMRecAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 37B6CED7246E05770068A6A4 /* ALMAXFrameLayoutMRecAdViewController.m */; };
37B6CEDB246E05D00068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 37B6CEDA246E05D00068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.m */; };
37C7E1EB2328904E002165B5 /* ALMAXAutoLayoutBannerAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D0CB33523204D120076AAAA /* ALMAXAutoLayoutBannerAdViewController.m */; };
37C7E1EC2328904E002165B5 /* ALMAXFrameLayoutBannerAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 37C7E1E823285E94002165B5 /* ALMAXFrameLayoutBannerAdViewController.m */; };
37C7E1ED2328904E002165B5 /* ALMAXInterstitialAdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D0CB32F23204CE70076AAAA /* ALMAXInterstitialAdViewController.m */; };
Expand Down Expand Up @@ -85,6 +88,12 @@
1D992FEA231FA1C500C472F8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
1D992FEC231FA1C500C472F8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1D992FED231FA1C500C472F8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
37B6CED4246E04FC0068A6A4 /* ALMAXAutoLayoutMRecAdViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALMAXAutoLayoutMRecAdViewController.m; sourceTree = "<group>"; };
37B6CED6246E05330068A6A4 /* ALMAXAutoLayoutMRecAdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALMAXAutoLayoutMRecAdViewController.h; sourceTree = "<group>"; };
37B6CED7246E05770068A6A4 /* ALMAXFrameLayoutMRecAdViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALMAXFrameLayoutMRecAdViewController.m; sourceTree = "<group>"; };
37B6CED9246E05870068A6A4 /* ALMAXFrameLayoutMRecAdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALMAXFrameLayoutMRecAdViewController.h; sourceTree = "<group>"; };
37B6CEDA246E05D00068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALMAXInterfaceBuilderMRecAdViewController.m; sourceTree = "<group>"; };
37B6CEDC246E062F0068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALMAXInterfaceBuilderMRecAdViewController.h; sourceTree = "<group>"; };
37C7E1E523285B4E002165B5 /* ALMAXInterfaceBuilderBannerAdViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALMAXInterfaceBuilderBannerAdViewController.m; sourceTree = "<group>"; };
37C7E1E723285B6A002165B5 /* ALMAXInterfaceBuilderBannerAdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALMAXInterfaceBuilderBannerAdViewController.h; sourceTree = "<group>"; };
37C7E1E823285E94002165B5 /* ALMAXFrameLayoutBannerAdViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALMAXFrameLayoutBannerAdViewController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -183,6 +192,7 @@
1D0CB33823204EBD0076AAAA /* MAX */ = {
isa = PBXGroup;
children = (
37B6CED3246E04D30068A6A4 /* MRECs */,
1D629D5D240F4E6600FE6F5F /* Banners */,
1D629D5E240F4E7200FE6F5F /* Interstitials */,
1D629D5F240F4E7500FE6F5F /* Rewarded */,
Expand Down Expand Up @@ -278,6 +288,19 @@
path = "Supporting Files";
sourceTree = "<group>";
};
37B6CED3246E04D30068A6A4 /* MRECs */ = {
isa = PBXGroup;
children = (
37B6CED4246E04FC0068A6A4 /* ALMAXAutoLayoutMRecAdViewController.m */,
37B6CED6246E05330068A6A4 /* ALMAXAutoLayoutMRecAdViewController.h */,
37B6CED7246E05770068A6A4 /* ALMAXFrameLayoutMRecAdViewController.m */,
37B6CED9246E05870068A6A4 /* ALMAXFrameLayoutMRecAdViewController.h */,
37B6CEDA246E05D00068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.m */,
37B6CEDC246E062F0068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.h */,
);
path = MRECs;
sourceTree = "<group>";
};
E567854723F22E1E00ACA6C1 /* Rewarded */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -673,18 +696,21 @@
E56785E823F3555A00ACA6C1 /* ALDemoProgrammaticBannerViewController.m in Sources */,
E567854623F22E1300ACA6C1 /* ALDemoRewardedVideosZoneViewController.m in Sources */,
E56786D223F48C1A00ACA6C1 /* ALDemoRSSFeedRetriever.m in Sources */,
37B6CEDB246E05D00068A6A4 /* ALMAXInterfaceBuilderMRecAdViewController.m in Sources */,
E56785EB23F3557100ACA6C1 /* ALDemoInterfaceBuilderBannerViewController.m in Sources */,
37C7E1F3232892CF002165B5 /* ALAppDelegate.m in Sources */,
E56786D123F48C1A00ACA6C1 /* ALDemoArticle.m in Sources */,
E56786FA23F4CAE100ACA6C1 /* ALEventTrackingViewController.m in Sources */,
E56786B923F48B2000ACA6C1 /* ALCarouselReplayOverlayView.m in Sources */,
E573083823EB972C00D972F4 /* ALDemoInterstitalZoneViewController.m in Sources */,
E56786BB23F48B2000ACA6C1 /* ALCarouselView.m in Sources */,
37B6CED5246E04FC0068A6A4 /* ALMAXAutoLayoutMRecAdViewController.m in Sources */,
E56786CB23F48B8A00ACA6C1 /* ALNativeAdVideoPlayer.m in Sources */,
37C7E1EB2328904E002165B5 /* ALMAXAutoLayoutBannerAdViewController.m in Sources */,
E567860623F4899600ACA6C1 /* ALDemoNativeAdProgrammaticViewController.m in Sources */,
E5C8F4C724119F0F00592BF8 /* ALDemoInterfaceBuilderMRECViewController.m in Sources */,
E56785FA23F35BC200ACA6C1 /* ALDemoProgrammaticLeaderViewController.m in Sources */,
37B6CED8246E05770068A6A4 /* ALMAXFrameLayoutMRecAdViewController.m in Sources */,
37C7E1EC2328904E002165B5 /* ALMAXFrameLayoutBannerAdViewController.m in Sources */,
E56786BC23F48B2000ACA6C1 /* ALNativeAdVideoView.m in Sources */,
E56786C223F48B7500ACA6C1 /* UIView+ALActivityIndicator.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALAutoLayoutBannerAdViewController.h
// ALMAXAutoLayoutBannerAdViewController.h
// DemoApp-ObjC
//
// Created by Thomas So on 9/4/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALAutoLayoutBannerAdViewController.m
// ALMAXAutoLayoutBannerAdViewController.m
// DemoApp-ObjC
//
// Created by Thomas So on 9/4/19.
Expand Down Expand Up @@ -30,34 +30,18 @@ - (void)viewDidLoad

[self.view addSubview: self.adView];

// Center the banner and anchor it to the top of the screen.
CGFloat height = (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) ? 90 : 50; // Banner height on iPhone and iPad is 50 and 90, respectively
[self.view addConstraints: @[[self constraintWithAdView: self.adView andAttribute: NSLayoutAttributeLeading],
[self constraintWithAdView: self.adView andAttribute: NSLayoutAttributeTrailing],
[self constraintWithAdView: self.adView andAttribute: NSLayoutAttributeTop],
[NSLayoutConstraint constraintWithItem: self.adView
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 1.0
constant: height]]];

// Anchor the banner to the left, right, and top of the screen.
[[self.adView.leadingAnchor constraintEqualToAnchor: self.view.leadingAnchor] setActive: YES];
[[self.adView.trailingAnchor constraintEqualToAnchor: self.view.trailingAnchor] setActive: YES];
[[self.adView.topAnchor constraintEqualToAnchor: self.view.topAnchor] setActive: YES];

[[self.adView.widthAnchor constraintEqualToAnchor: self.view.widthAnchor] setActive: YES];
[[self.adView.heightAnchor constraintEqualToConstant: UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad ? 90 : 50 ] setActive: YES];

// Load the first ad
[self.adView loadAd];
}

- (NSLayoutConstraint *)constraintWithAdView:(MAAdView *)adView andAttribute:(NSLayoutAttribute)attribute
{
return [NSLayoutConstraint constraintWithItem: adView
attribute: attribute
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: attribute
multiplier: 1.0
constant: 0.0];
}

#pragma mark - MAAdDelegate Protocol

- (void)didLoadAd:(MAAd *)ad
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALFrameLayoutBannerAdViewController.h
// ALMAXFrameLayoutBannerAdViewController.h
// DemoApp-ObjC
//
// Created by Andrew Tian on 9/10/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALFrameLayoutBannerAdViewController.m
// ALMAXFrameLayoutBannerAdViewController.m
// DemoApp-ObjC
//
// Created by Andrew Tian on 9/10/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALInterfaceBuilderBannerAdViewController.h
// ALMAXInterfaceBuilderBannerAdViewController.h
// DemoApp-ObjC
//
// Created by Andrew Tian on 9/10/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALInterfaceBuilderBannerAdViewController.m
// ALMAXInterfaceBuilderBannerAdViewController.m
// DemoApp-ObjC
//
// Created by Andrew Tian on 9/10/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALInterstitialAdViewController.h
// ALMAXInterstitialAdViewController.h
// DemoApp-ObjC
//
// Created by Thomas So on 9/4/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ALInterstitialAdViewController.m
// ALMAXInterstitialAdViewController.m
// DemoApp-ObjC
//
// Created by Thomas So on 9/4/19.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ALMAXAutoLayoutMRecAdViewController.h
// DemoApp-ObjC
//
// Created by Andrew Tian on 1/14/20.
// Copyright © 2020 AppLovin Corporation. All rights reserved.
//

#import "ALBaseAdViewController.h"

NS_ASSUME_NONNULL_BEGIN

@interface ALMAXAutoLayoutMRecAdViewController : ALBaseAdViewController

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// ALMAXAutoLayoutMRecAdViewController.m
// DemoApp-ObjC
//
// Created by Andrew Tian on 1/14/20.
// Copyright © 2020 AppLovin Corporation. All rights reserved.
//

#import "ALMAXAutoLayoutMRecAdViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>

@interface ALMAXAutoLayoutMRecAdViewController()<MAAdViewAdDelegate>
@property (nonatomic, strong) MAAdView *adView;
@end

@implementation ALMAXAutoLayoutMRecAdViewController

#pragma mark - View Lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];

self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"YOUR_AD_UNIT_ID" adFormat: MAAdFormat.mrec];
self.adView.delegate = self;
self.adView.translatesAutoresizingMaskIntoConstraints = NO;

// Set background or background color for MRECs to be fully functional
self.adView.backgroundColor = UIColor.blackColor;

[self.view addSubview: self.adView];

// Center the MREC and anchor it to the top of the screen.
[[self.adView.centerXAnchor constraintEqualToAnchor: self.view.centerXAnchor] setActive: YES];
[[self.adView.topAnchor constraintEqualToAnchor: self.view.topAnchor] setActive: YES];

[[self.adView.widthAnchor constraintEqualToConstant: 300] setActive: YES];
[[self.adView.heightAnchor constraintEqualToConstant: 250] setActive: YES];

// Load the first ad
[self.adView loadAd];
}

#pragma mark - MAAdDelegate Protocol

- (void)didLoadAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withErrorCode:(NSInteger)errorCode
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didDisplayAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didHideAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didClickAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didFailToDisplayAd:(MAAd *)ad withErrorCode:(NSInteger)errorCode
{
[self logCallback: __PRETTY_FUNCTION__];
}

#pragma mark - MAAdViewAdDelegate Protocol

- (void)didExpandAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didCollapseAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ALMAXFrameLayoutMRecAdViewController.h
// DemoApp-ObjC
//
// Created by Andrew Tian on 1/23/20.
// Copyright © 2020 AppLovin Corporation. All rights reserved.
//

#import "ALBaseAdViewController.h"

NS_ASSUME_NONNULL_BEGIN

@interface ALMAXFrameLayoutMRecAdViewController : ALBaseAdViewController

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// ALMAXFrameLayoutMRecAdViewController.m
// DemoApp-ObjC
//
// Created by Andrew Tian on 1/23/20.
// Copyright © 2020 AppLovin Corporation. All rights reserved.
//

#import "ALMAXFrameLayoutMRecAdViewController.h"
#import <AppLovinSDK/AppLovinSDK.h>

@interface ALMAXFrameLayoutMRecAdViewController()<MAAdViewAdDelegate>
@property (nonatomic, strong) MAAdView *adView;
@end

@implementation ALMAXFrameLayoutMRecAdViewController

#pragma mark - View Lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];

self.adView = [[MAAdView alloc] initWithAdUnitIdentifier: @"YOUR_AD_UNIT_ID" adFormat: MAAdFormat.mrec];
self.adView.delegate = self;

// Dimensions
CGFloat width = 300;
CGFloat height = 250;
CGFloat x = self.view.center.x - 150;
CGFloat y = 0;

self.adView.frame = CGRectMake(x, y, width, height);

// Set background or background color for MRECs to be fully functional
self.adView.backgroundColor = UIColor.blackColor;

[self.view addSubview: self.adView];

// Load the first ad
[self.adView loadAd];
}

#pragma mark - MAAdDelegate Protocol

- (void)didLoadAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withErrorCode:(NSInteger)errorCode
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didDisplayAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didHideAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didClickAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didFailToDisplayAd:(MAAd *)ad withErrorCode:(NSInteger)errorCode
{
[self logCallback: __PRETTY_FUNCTION__];
}

#pragma mark - MAAdViewAdDelegate Protocol

- (void)didExpandAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

- (void)didCollapseAd:(MAAd *)ad
{
[self logCallback: __PRETTY_FUNCTION__];
}

@end
Loading