| | |
| | | #import "SystemConfiguration/CaptiveNetwork.h" |
| | | #import <TTTracker/TTTracker+Game.h> |
| | | |
| | | @interface UniversalSDK()<JPUSHRegisterDelegate> |
| | | @interface UniversalSDK()<JPUSHRegisterDelegate,UIWebViewDelegate> |
| | | @end |
| | | |
| | | @implementation UniversalSDK |
| | |
| | | float _offsetY = (_bounds.size.height - _height) * .5f; |
| | | |
| | | m_UIWebView = [[UIWebView alloc] initWithFrame:CGRectMake(_offsetX, _offsetY, _width, _height)]; |
| | | m_UIWebView.delegate = self; |
| | | m_UIWebView.scalesPageToFit = YES ; |
| | | m_UIWebView.scrollView.scrollEnabled = YES; |
| | | m_UIWebView.scrollView.bounces = NO; |
| | | NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:url]]; |
| | | [UnityGetMainWindow().rootViewController.view addSubview:m_UIWebView]; |
| | | [m_UIWebView loadRequest:request]; |
| | | } |
| | | |
| | | -(void) btnClick:(UIButton*)sender { |
| | | [m_CloseBtn removeFromSuperview]; |
| | | [m_CloseBtn removeTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; |
| | | m_CloseBtn = NULL; |
| | | |
| | | NSURLCache *_cache = [NSURLCache sharedURLCache]; |
| | | [_cache removeAllCachedResponses]; |
| | | [_cache setDiskCapacity:0]; |
| | | [_cache setMemoryCapacity:0]; |
| | | |
| | | [m_UIWebView removeFromSuperview]; |
| | | m_UIWebView = NULL; |
| | | } |
| | | |
| | | -(void)webViewDidStartLoad:(UIWebView *)webView{ |
| | | } |
| | | |
| | | -(void)webViewDidFinishLoad:(UIWebView *)webView{ |
| | | |
| | | [UnityGetMainWindow().rootViewController.view addSubview:m_UIWebView]; |
| | | CGRect _bounds = UnityGetMainWindow().bounds; |
| | | |
| | | float _scale = _bounds.size.width / 1334; |
| | | |
| | | float _width = 982 * _scale; |
| | | float _height = 560 * _scale; |
| | | |
| | | m_CloseBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; |
| | | [m_CloseBtn setFrame:CGRectMake(_width - 455 * _scale, _height - 86 * _scale, 180 * _scale, 72 * _scale)]; |
| | |
| | | [m_UIWebView addSubview:m_CloseBtn]; |
| | | } |
| | | |
| | | -(void) btnClick:(UIButton*)sender { |
| | | [m_CloseBtn removeFromSuperview]; |
| | | [m_CloseBtn removeTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; |
| | | m_CloseBtn = NULL; |
| | | |
| | | NSURLCache *_cache = [NSURLCache sharedURLCache]; |
| | | [_cache removeAllCachedResponses]; |
| | | [_cache setDiskCapacity:0]; |
| | | [_cache setMemoryCapacity:0]; |
| | | |
| | | [m_UIWebView removeFromSuperview]; |
| | | m_UIWebView = NULL; |
| | | -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ |
| | | } |
| | | |
| | | |
| | | -(void) FreeSDKCancelLogin { |
| | | NSLog(@"++++++++++++++++++ Cancel Login....."); |
| | | } |