forked from vinzen/sa-mobile-sdk-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmpMoPub.txt
105 lines (76 loc) · 3.01 KB
/
tmpMoPub.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// ViewController.m
// SAMoPubIntegrationDemo
//
// Created by Gabriel Coman on 26/10/2015.
// Copyright © 2015 Gabriel Coman. All rights reserved.
//
#import "ViewController.h"
#import "MoPub.h"
#import "MPAdView.h"
#import "MPInterstitialAdController.h"
#import "MPRewardedVideo.h"
@interface ViewController ()
<MPAdViewDelegate, MPInterstitialAdControllerDelegate, MPRewardedVideoDelegate>
@property (nonatomic, strong) MPAdView *adView;
@property (nonatomic, strong) MPInterstitialAdController *interstitial;
@end
@implementation ViewController
- (void)viewDidLoad {
// ... your other -viewDidLoad code ...
[[MoPub sharedInstance] initializeRewardedVideoWithGlobalMediationSettings:nil delegate:self];
// self.adView = [[MPAdView alloc] initWithAdUnitId:@"6acb36d7c1c94461844419ef03cc10cf" size:MOPUB_BANNER_SIZE];
// self.adView.delegate = self;
// self.adView.frame = CGRectMake((self.view.bounds.size.width - MOPUB_BANNER_SIZE.width) / 2,
// self.view.bounds.size.height - MOPUB_BANNER_SIZE.height,
// MOPUB_BANNER_SIZE.width, MOPUB_BANNER_SIZE.height);
// [self.view addSubview:self.adView];
// [self.adView loadAd];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)openInterstitial:(id)sender {
// Instantiate the interstitial using the class convenience method.
self.interstitial = [MPInterstitialAdController interstitialAdControllerForAdUnitId:@"74ccdcb1059b4c038e0bfadf1c61a84b"];
self.interstitial.delegate = self;
// Fetch the interstitial ad.
[self.interstitial loadAd];
}
- (IBAction)playInter:(id)sender {
if (self.interstitial.ready) {
[self.interstitial showFromViewController:self];
} else {
NSLog(@"No interstitial present");
}
}
- (IBAction)openVideo:(id)sender {
[MPRewardedVideo loadRewardedVideoAdWithAdUnitID:@"e7fbea8a838740139eb41edf10aba4b1" withMediationSettings:nil];
}
- (IBAction)playVideo:(id)sender {
if ([MPRewardedVideo hasAdAvailableForAdUnitID:@"e7fbea8a838740139eb41edf10aba4b1"]) {
[MPRewardedVideo presentRewardedVideoAdForAdUnitID:@"e7fbea8a838740139eb41edf10aba4b1" fromViewController:self];
} else {
NSLog(@"No video present");
}
}
#pragma mark - <MPAdViewDelegate>
- (UIViewController *)viewControllerForPresentingModalView {
return self;
}
#pragma mark - <MPInterstitialAdControllerDelegate>
- (void) interstitialDidLoadAd:(MPInterstitialAdController *)interstitial {
NSLog(@"interstitialDidLoadAd");
}
- (void) interstitialDidFailToLoadAd:(MPInterstitialAdController *)interstitial {
NSLog(@"Did fail to load ad");
}
#pragma mark - <MPRewardedVideoDelegate>
- (void) rewardedVideoAdDidLoadForAdUnitID:(NSString *)adUnitID {
}
- (void) rewardedVideoAdShouldRewardForAdUnitID:(NSString *)adUnitID reward:(MPRewardedVideoReward *)reward {
NSLog(@"User was rewarded");
}
@end