CB-8659 - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)

This commit is contained in:
Shazron Abdullah
2015-03-13 20:29:55 -07:00
committed by Shazron Abdullah
parent 4c8f58d87c
commit ed1227f61a
2 changed files with 28 additions and 9 deletions
+16 -8
View File
@@ -41,15 +41,10 @@
@implementation CDVInAppBrowser
- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
- (void)pluginInitialize
{
self = [super initWithWebView:theWebView];
if (self != nil) {
_previousStatusBarStyle = -1;
_callbackIdPattern = nil;
}
return self;
_previousStatusBarStyle = -1;
_callbackIdPattern = nil;
}
- (void)onReset
@@ -87,7 +82,11 @@
self.callbackId = command.callbackId;
if (url != nil) {
#ifdef __CORDOVA_4_0_0
NSURL* baseUrl = [self.webViewEngine URL];
#else
NSURL* baseUrl = [self.webView.request URL];
#endif
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
if ([self isSystemUrl:absoluteUrl]) {
@@ -231,7 +230,11 @@
{
if ([self.commandDelegate URLIsWhitelisted:url]) {
NSURLRequest* request = [NSURLRequest requestWithURL:url];
#ifdef __CORDOVA_4_0_0
[self.webViewEngine loadRequest:request];
#else
[self.webView loadRequest:request];
#endif
} else { // this assumes the InAppBrowser can be excepted from the white-list
[self openInInAppBrowser:url withOptions:options];
}
@@ -462,7 +465,12 @@
_userAgent = userAgent;
_prevUserAgent = prevUserAgent;
_browserOptions = browserOptions;
#ifdef __CORDOVA_4_0_0
_webViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:self];
#else
_webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
#endif
[self createViews];
}