-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGreenRobotAds.m
44 lines (33 loc) · 1.46 KB
/
GreenRobotAds.m
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
// GreenRobotAds.m
//
// Created by Andy Triboletti on 6/24/17.
//
//
#import "GreenRobotAds.h"
@implementation GreenRobotAds
- (id)initialize:(NSString*) urlString
{
self.admobiPhoneUnitId =[[[NSBundle mainBundle] infoDictionary] objectForKey:@"admob_iphone_unit_id"];
self.admobiPadUnitId =[[[NSBundle mainBundle] infoDictionary] objectForKey:@"admob_ipad_unit_id"];
self.mopubiPhoneUnitId =[[[NSBundle mainBundle] infoDictionary] objectForKey:@"mopub_iphone_unit_id"];
self.mopubiPadUnitId =[[[NSBundle mainBundle] infoDictionary] objectForKey:@"mopub_ipad_unit_id"];
NSError *error;
NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString:urlString]];
data = nil;
if(data == nil) {
NSMutableDictionary *mopub = [NSMutableDictionary dictionary];
[mopub setValue:@"mopub" forKey:@"type"];
[mopub setValue:@"0.5" forKey:@"weight"];
NSMutableDictionary *admob = [NSMutableDictionary dictionary];
[admob setValue:@"admob" forKey:@"type"];
[admob setValue:@"0.5" forKey:@"weight"];
NSArray *results = @[mopub, admob];
[[NSUserDefaults standardUserDefaults] setObject:results forKey:@"gr_ads"];
return self;
}
NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
//NSLog(@"json: %@", json);
[[NSUserDefaults standardUserDefaults] setObject:json forKey:@"gr_ads"];
return self;
}
@end