(ios) add compile-time decision for disabling UIWebView (#584)

This commit is contained in:
Maik Hummel 2019-11-27 17:25:59 +01:00 committed by Niklas Merz
parent 785fc4c83d
commit 82bbe29986
3 changed files with 91 additions and 47 deletions

View File

@ -19,7 +19,9 @@
#import "CDVInAppBrowser.h" #import "CDVInAppBrowser.h"
#import "CDVInAppBrowserOptions.h" #import "CDVInAppBrowserOptions.h"
#if !WK_WEB_VIEW_ONLY
#import "CDVUIInAppBrowser.h" #import "CDVUIInAppBrowser.h"
#endif
#import "CDVWKInAppBrowser.h" #import "CDVWKInAppBrowser.h"
#import <Cordova/CDVPluginResult.h> #import <Cordova/CDVPluginResult.h>
@ -49,85 +51,121 @@
return; return;
} }
self.usewkwebview = browserOptions.usewkwebview; self.usewkwebview = browserOptions.usewkwebview;
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] open:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] open:command]; [[CDVWKInAppBrowser getInstance] open:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] open:command]; [[CDVUIInAppBrowser getInstance] open:command];
} }
#endif
} }
- (void)close:(CDVInvokedUrlCommand*)command - (void)close:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] close:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] close:command]; [[CDVWKInAppBrowser getInstance] close:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] close:command]; [[CDVUIInAppBrowser getInstance] close:command];
} }
#endif
} }
- (void)show:(CDVInvokedUrlCommand*)command - (void)show:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] show:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] show:command]; [[CDVWKInAppBrowser getInstance] show:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] show:command]; [[CDVUIInAppBrowser getInstance] show:command];
} }
#endif
} }
- (void)hide:(CDVInvokedUrlCommand*)command - (void)hide:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] hide:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] hide:command]; [[CDVWKInAppBrowser getInstance] hide:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] hide:command]; [[CDVUIInAppBrowser getInstance] hide:command];
} }
#endif
} }
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command - (void)injectScriptCode:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command]; [[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command]; [[CDVUIInAppBrowser getInstance] injectScriptCode:command];
} }
#endif
} }
- (void)injectScriptFile:(CDVInvokedUrlCommand*)command - (void)injectScriptFile:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptFile:command]; [[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] injectScriptFile:command]; [[CDVUIInAppBrowser getInstance] injectScriptCode:command];
} }
#endif
} }
- (void)injectStyleCode:(CDVInvokedUrlCommand*)command - (void)injectStyleCode:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleCode:command]; [[CDVWKInAppBrowser getInstance] injectStyleCode:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] injectStyleCode:command]; [[CDVUIInAppBrowser getInstance] injectStyleCode:command];
} }
#endif
} }
- (void)injectStyleFile:(CDVInvokedUrlCommand*)command - (void)injectStyleFile:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleFile:command]; [[CDVWKInAppBrowser getInstance] injectStyleFile:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] injectStyleFile:command]; [[CDVUIInAppBrowser getInstance] injectStyleFile:command];
} }
#endif
} }
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command - (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
{ {
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
#else
if(self.usewkwebview){ if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command]; [[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
}else{ }else{
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command]; [[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
} }
#endif
} }

View File

@ -17,6 +17,8 @@
under the License. under the License.
*/ */
#if !WK_WEB_VIEW_ONLY
#import <Cordova/CDVPlugin.h> #import <Cordova/CDVPlugin.h>
#import <Cordova/CDVInvokedUrlCommand.h> #import <Cordova/CDVInvokedUrlCommand.h>
#import <Cordova/CDVScreenOrientationDelegate.h> #import <Cordova/CDVScreenOrientationDelegate.h>
@ -89,3 +91,5 @@
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions; - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
@end @end
#endif

View File

@ -17,6 +17,8 @@
under the License. under the License.
*/ */
#if !WK_WEB_VIEW_ONLY
#import "CDVUIInAppBrowser.h" #import "CDVUIInAppBrowser.h"
#import <Cordova/CDVPluginResult.h> #import <Cordova/CDVPluginResult.h>
#import <Cordova/CDVUserAgentUtil.h> #import <Cordova/CDVUserAgentUtil.h>
@ -1126,4 +1128,4 @@ static CDVUIInAppBrowser* instance = nil;
@end @end
#endif