WLNativeAdCollectionViewCell.m
1.96 KB
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
//
// WLNativeAdCollectionViewCell.m
// DemoApp
//
// Created by Nick Xirotyris on 19/10/15.
// Copyright © 2015 YC. All rights reserved.
//
#import "WLNativeAdCollectionViewCell.h"
#import "Warply.h"
//#import "WLGlobals.h"
@implementation WLNativeAdCollectionViewCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"WLNativeAdCollectionViewCell" owner:self options:nil];
if ([arrayOfViews count] < 1) {
return nil;
}
if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) {
return nil;
}
self = [arrayOfViews objectAtIndex:0];
}
return self;
}
-(void)loadContentwithURL:(NSString *)url {
NSMutableURLRequest * request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
[request setValue:[Warply sharedService].webId forHTTPHeaderField:@"loyalty-web-id"];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
[request setValue:@"gzip" forHTTPHeaderField:@"User-Agent"];
[self.webView loadRequest:request];
[self.activityIndicator startAnimating];
}
-(BOOL)webView:(WKWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (![request.URL.host isEqualToString:WARP_HOST] && ![request.URL.host isEqualToString:@"warplydata.blob.core.windows.net"]) {
[[UIApplication sharedApplication] openURL:request.URL];
}
return YES;
}
-(void)webViewDidFinishLoad:(WKWebView *)webView {
[self.activityIndicator stopAnimating];
}
-(void)webView:(WKWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"%@", error);
[self.activityIndicator stopAnimating];
}
@end