CB-8659 - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)
This commit is contained in:
parent
4c8f58d87c
commit
ed1227f61a
@ -20,7 +20,12 @@
|
|||||||
#import <Cordova/CDVPlugin.h>
|
#import <Cordova/CDVPlugin.h>
|
||||||
#import <Cordova/CDVInvokedUrlCommand.h>
|
#import <Cordova/CDVInvokedUrlCommand.h>
|
||||||
#import <Cordova/CDVScreenOrientationDelegate.h>
|
#import <Cordova/CDVScreenOrientationDelegate.h>
|
||||||
#import <Cordova/CDVWebViewDelegate.h>
|
|
||||||
|
#ifdef __CORDOVA_4_0_0
|
||||||
|
#import <Cordova/CDVUIWebViewDelegate.h>
|
||||||
|
#else
|
||||||
|
#import <Cordova/CDVWebViewDelegate.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
@class CDVInAppBrowserViewController;
|
@class CDVInAppBrowserViewController;
|
||||||
|
|
||||||
@ -69,7 +74,13 @@
|
|||||||
NSString* _prevUserAgent;
|
NSString* _prevUserAgent;
|
||||||
NSInteger _userAgentLockToken;
|
NSInteger _userAgentLockToken;
|
||||||
CDVInAppBrowserOptions *_browserOptions;
|
CDVInAppBrowserOptions *_browserOptions;
|
||||||
|
|
||||||
|
#ifdef __CORDOVA_4_0_0
|
||||||
|
CDVUIWebViewDelegate* _webViewDelegate;
|
||||||
|
#else
|
||||||
CDVWebViewDelegate* _webViewDelegate;
|
CDVWebViewDelegate* _webViewDelegate;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, strong) IBOutlet UIWebView* webView;
|
@property (nonatomic, strong) IBOutlet UIWebView* webView;
|
||||||
|
@ -41,15 +41,10 @@
|
|||||||
|
|
||||||
@implementation CDVInAppBrowser
|
@implementation CDVInAppBrowser
|
||||||
|
|
||||||
- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
|
- (void)pluginInitialize
|
||||||
{
|
{
|
||||||
self = [super initWithWebView:theWebView];
|
_previousStatusBarStyle = -1;
|
||||||
if (self != nil) {
|
_callbackIdPattern = nil;
|
||||||
_previousStatusBarStyle = -1;
|
|
||||||
_callbackIdPattern = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onReset
|
- (void)onReset
|
||||||
@ -87,7 +82,11 @@
|
|||||||
self.callbackId = command.callbackId;
|
self.callbackId = command.callbackId;
|
||||||
|
|
||||||
if (url != nil) {
|
if (url != nil) {
|
||||||
|
#ifdef __CORDOVA_4_0_0
|
||||||
|
NSURL* baseUrl = [self.webViewEngine URL];
|
||||||
|
#else
|
||||||
NSURL* baseUrl = [self.webView.request URL];
|
NSURL* baseUrl = [self.webView.request URL];
|
||||||
|
#endif
|
||||||
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
|
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
|
||||||
|
|
||||||
if ([self isSystemUrl:absoluteUrl]) {
|
if ([self isSystemUrl:absoluteUrl]) {
|
||||||
@ -231,7 +230,11 @@
|
|||||||
{
|
{
|
||||||
if ([self.commandDelegate URLIsWhitelisted:url]) {
|
if ([self.commandDelegate URLIsWhitelisted:url]) {
|
||||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||||
|
#ifdef __CORDOVA_4_0_0
|
||||||
|
[self.webViewEngine loadRequest:request];
|
||||||
|
#else
|
||||||
[self.webView loadRequest:request];
|
[self.webView loadRequest:request];
|
||||||
|
#endif
|
||||||
} else { // this assumes the InAppBrowser can be excepted from the white-list
|
} else { // this assumes the InAppBrowser can be excepted from the white-list
|
||||||
[self openInInAppBrowser:url withOptions:options];
|
[self openInInAppBrowser:url withOptions:options];
|
||||||
}
|
}
|
||||||
@ -462,7 +465,12 @@
|
|||||||
_userAgent = userAgent;
|
_userAgent = userAgent;
|
||||||
_prevUserAgent = prevUserAgent;
|
_prevUserAgent = prevUserAgent;
|
||||||
_browserOptions = browserOptions;
|
_browserOptions = browserOptions;
|
||||||
|
#ifdef __CORDOVA_4_0_0
|
||||||
|
_webViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:self];
|
||||||
|
#else
|
||||||
_webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
|
_webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
|
||||||
|
#endif
|
||||||
|
|
||||||
[self createViews];
|
[self createViews];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user