-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_main
94 lines (78 loc) · 3.23 KB
/
sample_main
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
UIView *gView;
UIViewController *gViewColtroller;
@interface adInterstitial : NSObject
/// The interstitial ad.
@property(nonatomic, strong) GADInterstitial *interstitial;
@property (strong, nonatomic) GADRequest *request;
@end
@implementation adInterstitial
-(id)init {
[self createAndLoadInterstitial];
NSLog(@"adInterstitial init");
return self;
}
- (void)createAndLoadInterstitial {
//self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"]; // test id
self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-2909842258525517/2244020698"]; // true id for intersitial
//self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-2909842258525517/6447133439"]; // true id for reward intersitial
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
self.interstitial.delegate = self;
GADRequest *request = [GADRequest request];
request.testDevices = @[ kGADSimulatorID, @"2077ef9a63d2b398840261c8221a0c9a" ];
[self.interstitial loadRequest:request];
NSLog(@"createAndLoadInterstitial");
}
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
// Method for reloading the object so that you can show ads again
NSLog(@"interstitialWillDismissScreen");
[self createAndLoadInterstitial];
}
- (void)InterstitialView { // show interstitial ADS
if (self.interstitial.isReady) {
NSLog(@"Show interstitial ADS!");
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
[self.interstitial presentFromRootViewController:rootViewController];
} else {
NSLog(@"interstitial Ad wasn't ready");
}
}
@end
@interface adRewarded : NSObject
/// The interstitial ad.
@property(nonatomic, strong) GADRewardedAd *rewarded;
@property (strong, nonatomic) GADRequest *request;
@end
@implementation adRewarded
-(id)init {
[self createAndLoadRewarded];
NSLog(@"adRewarded init");
return self;
}
- (void)createAndLoadRewarded {
self.rewarded = [[GADRewardedAd alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"]; // test id
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
self.rewarded.delegate = self;
GADRequest *request = [GADRequest request];
request.testDevices = @[ kGADSimulatorID, @"2077ef9a63d2b398840261c8221a0c9a" ];
[self.rewarded loadRequest:request];
NSLog(@"createAndLoadRewarded");
}
- (void)interstitialWillDismissScreen:(GADRewardedAd *)ad {
// Method for reloading the object so that you can show ads again
NSLog(@"rewardedWillDismissScreen");
[self createAndLoadRewarded];
}
- (void)RewardedView { // show interstitial ADS
if (self.rewarded.isReady) {
NSLog(@"Show rewarded ADS!");
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
[self.rewarded presentFromRootViewController:rootViewController];
} else {
NSLog(@"rewarded Ad wasn't ready");
}
}
@end