-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
490 additions
and
36 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
...mo App - ObjC/AppLovin MAX Demo App - ObjC/MAX/Banners/ALAutoLayoutMRecAdViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// ALAutoLayoutMrecAdViewController.m | ||
// DemoApp-ObjC | ||
// | ||
// Created by Andrew Tian on 1/14/20. | ||
// Copyright © 2020 AppLovin Corporation. All rights reserved. | ||
// | ||
|
||
#import "ALAutoLayoutMrecAdViewController.h" | ||
#import <AppLovinSDK/AppLovinSDK.h> | ||
|
||
@interface ALAutoLayoutMrecAdViewController()<MAAdViewAdDelegate> | ||
@property (nonatomic, strong) MAAdView *adView; | ||
@end | ||
|
||
@implementation ALAutoLayoutMrecAdViewController | ||
|
||
#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 |
17 changes: 17 additions & 0 deletions
17
...mo App - ObjC/AppLovin MAX Demo App - ObjC/MAX/Banners/ALAutoLayoutMrecAdViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// ALAutoLayoutMrecAdViewController.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 ALAutoLayoutMrecAdViewController : ALBaseAdViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
17 changes: 17 additions & 0 deletions
17
...o App - ObjC/AppLovin MAX Demo App - ObjC/MAX/Banners/ALFrameLayoutMrecAdViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// ALFrameLayoutMrecAdViewController.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 ALFrameLayoutMrecAdViewController : ALBaseAdViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
88 changes: 88 additions & 0 deletions
88
...o App - ObjC/AppLovin MAX Demo App - ObjC/MAX/Banners/ALFrameLayoutMrecAdViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// ALFrameLayoutMrecAdViewController.m | ||
// DemoApp-ObjC | ||
// | ||
// Created by Andrew Tian on 1/23/20. | ||
// Copyright © 2020 AppLovin Corporation. All rights reserved. | ||
// | ||
|
||
#import "ALFrameLayoutMrecAdViewController.h" | ||
#import <AppLovinSDK/AppLovinSDK.h> | ||
|
||
@interface ALFrameLayoutMrecAdViewController()<MAAdViewAdDelegate> | ||
@property (nonatomic, strong) MAAdView *adView; | ||
@end | ||
|
||
@implementation ALFrameLayoutMrecAdViewController | ||
|
||
#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 |
17 changes: 17 additions & 0 deletions
17
... - ObjC/AppLovin MAX Demo App - ObjC/MAX/Banners/ALInterfaceBuilderMrecAdViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// ALInterfaceBuilderMrecAdViewController.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 ALInterfaceBuilderMrecAdViewController : ALBaseAdViewController | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
77 changes: 77 additions & 0 deletions
77
... - ObjC/AppLovin MAX Demo App - ObjC/MAX/Banners/ALInterfaceBuilderMrecAdViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// ALInterfaceBuilderMrecAdViewController.m | ||
// DemoApp-ObjC | ||
// | ||
// Created by Andrew Tian on 1/23/20. | ||
// Copyright © 2020 AppLovin Corporation. All rights reserved. | ||
// | ||
|
||
#import "ALInterfaceBuilderMrecAdViewController.h" | ||
#import <AppLovinSDK/AppLovinSDK.h> | ||
|
||
@interface ALInterfaceBuilderMrecAdViewController()<MAAdViewAdDelegate> | ||
@property (nonatomic, strong) IBOutlet MAAdView *adView; | ||
@end | ||
|
||
@implementation ALInterfaceBuilderMrecAdViewController | ||
|
||
#pragma mark - View Lifecycle | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
|
||
// NOTE: Must set Storyboard "User Defined Runtime Attributes" for MREC ad view | ||
// Key Path = ad_unit_id | ||
// Type = String | ||
// Value = YOUR_AD_UNIT_ID | ||
|
||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.