Skip to content

Commit dc7fa34

Browse files
committed
CB-7179 (iOS): Add support to optionally use WKWebView for iOS
1 parent a078337 commit dc7fa34

19 files changed

+3034
-1281
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ matrix:
2828
os: linux
2929
language: node_js
3030
node_js: '4.2'
31-
- env: PLATFORM=ios-9.3
31+
- env: PLATFORM=ios-10.0
3232
os: osx
33-
osx_image: xcode7.3
33+
osx_image: xcode8.3
3434
language: node_js
3535
node_js: '4.2'
3636
# TBD SKIP for now:

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ instance, or the system browser.
136136

137137
iOS supports these additional options:
138138

139+
- __usewkwebview__: set to `yes` to use WKWebView engine for the InappBrowser. Omit or set to `no` (default) to use UIWebView. Note: Using `usewkwebview=yes` requires that a WKWebView engine plugin be installed in the Cordova project (e.g. [cordova-plugin-wkwebview-engine](https://github.com/apache/cordova-plugin-wkwebview-engine) or [cordova-plugin-ionic-webview](https://github.com/ionic-team/cordova-plugin-ionic-webview)).
139140
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
140141
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
141-
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
142+
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened. For WKWebView, requires iOS 11+ on target device.
143+
- __cleardata__: set to `yes` to have the browser's entire local storage cleared (cookies, HTML5 local storage, IndexedDB, etc.) before the new window is opened
142144
- __closebuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default __Done__ button's color. Only applicable if toolbar is not disabled.
143145
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
144146
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
@@ -147,11 +149,11 @@ instance, or the system browser.
147149
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
148150
- __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
149151
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.
150-
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
151-
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
152-
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`)
153-
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`).
154-
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`).
152+
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
153+
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
154+
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`) Only applicable to UIWebView (`usewkwebview=no`).
155+
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). Only applicable to UIWebView (`usewkwebview=no`).
156+
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
155157
- __presentationstyle__: Set to `pagesheet`, `formsheet` or `fullscreen` to set the [presentation style](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle) (defaults to `fullscreen`).
156158
- __transitionstyle__: Set to `fliphorizontal`, `crossdissolve` or `coververtical` to set the [transition style](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle) (defaults to `coververtical`).
157159
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
-->
2121
# Release Notes
2222

23+
### 3.1.0-dev (Unreleased)
24+
* CB-7179 (iOS): Add support to optionally use WKWebView for iOS
25+
2326
### 3.0.0 (Apr 12, 2018)
2427
* [CB-13659](https://issues.apache.org/jira/browse/CB-13659) **iOS** Add hidespinner option
2528
* In file `AppBrowser.java`: New code within `shouldOverrideUrlLoading()` to check for whitelisting custom schemes via a new `AllowedSchemes` preference configuration item. Allows custom schemes like `mycoolapp://` or `wevotetwitterscheme://`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-inappbrowser",
3-
"version": "3.0.1-dev",
3+
"version": "3.1.0-dev",
44
"description": "Cordova InAppBrowser Plugin",
55
"types": "./types/index.d.ts",
66
"cordova": {

plugin.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2222
id="cordova-plugin-inappbrowser"
23-
version="3.0.1-dev">
23+
version="3.1.0-dev">
2424

2525
<name>InAppBrowser</name>
2626
<description>Cordova InAppBrowser Plugin</description>
@@ -76,11 +76,31 @@
7676
<config-file target="config.xml" parent="/*">
7777
<feature name="InAppBrowser">
7878
<param name="ios-package" value="CDVInAppBrowser" />
79+
<param name="onload" value="true" />
80+
</feature>
81+
<feature name="UIInAppBrowser">
82+
<param name="ios-package" value="CDVUIInAppBrowser" />
83+
<param name="onload" value="true" />
84+
</feature>
85+
<feature name="WKInAppBrowser">
86+
<param name="ios-package" value="CDVWKInAppBrowser" />
87+
<param name="onload" value="true" />
7988
</feature>
8089
</config-file>
8190

8291
<header-file src="src/ios/CDVInAppBrowser.h" />
8392
<source-file src="src/ios/CDVInAppBrowser.m" />
93+
<header-file src="src/ios/CDVInAppBrowserOptions.h" />
94+
<source-file src="src/ios/CDVInAppBrowserOptions.m" />
95+
<header-file src="src/ios/CDVInAppBrowserNavigationController.h" />
96+
<source-file src="src/ios/CDVInAppBrowserNavigationController.m" />
97+
<header-file src="src/ios/CDVUIInAppBrowser.h" />
98+
<source-file src="src/ios/CDVUIInAppBrowser.m" />
99+
<header-file src="src/ios/CDVWKInAppBrowser.h" />
100+
<source-file src="src/ios/CDVWKInAppBrowser.m" />
101+
<header-file src="src/ios/CDVWKInAppBrowserUIDelegate.h" />
102+
<source-file src="src/ios/CDVWKInAppBrowserUIDelegate.m" />
103+
84104

85105
<framework src="CoreGraphics.framework" />
86106
</platform>

src/ios/CDVInAppBrowser.h

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,11 @@
1919

2020
#import <Cordova/CDVPlugin.h>
2121
#import <Cordova/CDVInvokedUrlCommand.h>
22-
#import <Cordova/CDVScreenOrientationDelegate.h>
2322

24-
#ifdef __CORDOVA_4_0_0
25-
#import <Cordova/CDVUIWebViewDelegate.h>
26-
#else
27-
#import <Cordova/CDVWebViewDelegate.h>
28-
#endif
23+
@interface CDVInAppBrowser : CDVPlugin {}
2924

30-
@class CDVInAppBrowserViewController;
31-
32-
@interface CDVInAppBrowser : CDVPlugin {
33-
UIWindow * tmpWindow;
34-
}
35-
36-
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
37-
@property (nonatomic, copy) NSString* callbackId;
38-
@property (nonatomic, copy) NSRegularExpression *callbackIdPattern;
25+
@property (nonatomic, assign) BOOL wkwebviewavailable;
26+
@property (nonatomic, assign) BOOL usewkwebview;
3927

4028
- (void)open:(CDVInvokedUrlCommand*)command;
4129
- (void)close:(CDVInvokedUrlCommand*)command;
@@ -45,75 +33,3 @@
4533

4634
@end
4735

48-
@interface CDVInAppBrowserOptions : NSObject {}
49-
50-
@property (nonatomic, assign) BOOL location;
51-
@property (nonatomic, assign) BOOL toolbar;
52-
@property (nonatomic, copy) NSString* closebuttoncaption;
53-
@property (nonatomic, copy) NSString* closebuttoncolor;
54-
@property (nonatomic, copy) NSString* toolbarposition;
55-
@property (nonatomic, copy) NSString* toolbarcolor;
56-
@property (nonatomic, assign) BOOL toolbartranslucent;
57-
@property (nonatomic, assign) BOOL hidenavigationbuttons;
58-
@property (nonatomic, copy) NSString* navigationbuttoncolor;
59-
@property (nonatomic, assign) BOOL clearcache;
60-
@property (nonatomic, assign) BOOL clearsessioncache;
61-
@property (nonatomic, assign) BOOL hidespinner;
62-
63-
@property (nonatomic, copy) NSString* presentationstyle;
64-
@property (nonatomic, copy) NSString* transitionstyle;
65-
66-
@property (nonatomic, assign) BOOL enableviewportscale;
67-
@property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction;
68-
@property (nonatomic, assign) BOOL allowinlinemediaplayback;
69-
@property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
70-
@property (nonatomic, assign) BOOL suppressesincrementalrendering;
71-
@property (nonatomic, assign) BOOL hidden;
72-
@property (nonatomic, assign) BOOL disallowoverscroll;
73-
74-
+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
75-
76-
@end
77-
78-
@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
79-
@private
80-
NSString* _userAgent;
81-
NSString* _prevUserAgent;
82-
NSInteger _userAgentLockToken;
83-
CDVInAppBrowserOptions *_browserOptions;
84-
85-
#ifdef __CORDOVA_4_0_0
86-
CDVUIWebViewDelegate* _webViewDelegate;
87-
#else
88-
CDVWebViewDelegate* _webViewDelegate;
89-
#endif
90-
91-
}
92-
93-
@property (nonatomic, strong) IBOutlet UIWebView* webView;
94-
@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
95-
@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
96-
@property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
97-
@property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
98-
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner;
99-
@property (nonatomic, strong) IBOutlet UIToolbar* toolbar;
100-
101-
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
102-
@property (nonatomic, weak) CDVInAppBrowser* navigationDelegate;
103-
@property (nonatomic) NSURL* currentURL;
104-
105-
- (void)close;
106-
- (void)navigateTo:(NSURL*)url;
107-
- (void)showLocationBar:(BOOL)show;
108-
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
109-
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString;
110-
111-
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
112-
113-
@end
114-
115-
@interface CDVInAppBrowserNavigationController : UINavigationController
116-
117-
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
118-
119-
@end

0 commit comments

Comments
 (0)