Skip to content

Commit 10a0669

Browse files
Merge pull request #271 from dpa99c/CB-7179
CB-7179 (iOS): Add WKWebView support for iOS
2 parents d9cafcd + 3927b8f commit 10a0669

19 files changed

+3062
-1318
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ matrix:
2727
os: linux
2828
language: node_js
2929
node_js: '4.2'
30-
- env: PLATFORM=ios-9.3
31-
os: osx
32-
osx_image: xcode7.3
33-
language: node_js
34-
node_js: '4.2'
30+
# iOS 9 not supported by iOS WKWebView implementation
31+
# - env: PLATFORM=ios-9.3
32+
# os: osx
33+
# osx_image: xcode8.3
34+
# language: node_js
35+
# node_js: '4.2'
3536
- env: PLATFORM=ios-10.0
3637
os: osx
37-
osx_image: xcode7.3
38+
osx_image: xcode8.3
3839
language: node_js
3940
node_js: '4.2'
4041
- env: PLATFORM=android-4.4

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ instance, or the system browser.
133133

134134
iOS supports these additional options:
135135

136+
- __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)).
136137
- __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.
137138
- __beforeload__: set to `yes` to enable the `beforeload` event to modify which pages are actually loaded in the browser.
138139
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
139-
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
140+
- __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.
141+
- __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
140142
- __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.
141143
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
142144
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
@@ -145,11 +147,11 @@ instance, or the system browser.
145147
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
146148
- __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.
147149
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.
148-
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
149-
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
150-
- __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`)
151-
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`).
152-
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`).
150+
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
151+
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Only applicable to UIWebView (`usewkwebview=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`) Only applicable to UIWebView (`usewkwebview=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`). Only applicable to UIWebView (`usewkwebview=no`).
154+
- __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`).
153155
- __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`).
154156
- __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`).
155157
- __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 & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -19,107 +19,17 @@
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-
@private
36-
BOOL _useBeforeload;
37-
BOOL _waitForBeforeload;
38-
}
39-
40-
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
41-
@property (nonatomic, copy) NSString* callbackId;
42-
@property (nonatomic, copy) NSRegularExpression *callbackIdPattern;
25+
@property (nonatomic, assign) BOOL wkwebviewavailable;
26+
@property (nonatomic, assign) BOOL usewkwebview;
4327

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

11934
@end
12035

121-
@interface CDVInAppBrowserNavigationController : UINavigationController
122-
123-
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
124-
125-
@end

0 commit comments

Comments
 (0)