[
https://issues.apache.org/jira/browse/CB-7179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16503454#comment-16503454
]
ASF GitHub Bot commented on CB-7179:
------------------------------------
dpa99c opened a new pull request #271: CB-7179 (iOS): Add WKWebView support for
iOS
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/271
### Platforms affected
iOS
### What does this PR do?
This PR adds support for WKWebView to the InappBrowser plugin on iOS.
It:
- builds on the initial work done by [Shazron](https://github.com/shazron)
on the [wkwebview
branch](https://github.com/apache/cordova-plugin-inappbrowser/tree/wkwebview)
branch.
- takes on feedback from #245
- contains some major changes, but with [UIWebView now deprecated in iOS
12](https://developer.apple.com/documentation/uikit/uiwebview?changes=_6&language=objc),
then getting this plugin to support WKWebView seems now to be a higher
priority.
Additional changes in this PR include:
- Separate UIWebView and WKWebView implementations which are invoked by an
intermediate dispatcher dependent on the `usewkwebview` option.
- Adds shared cookie pool via CDVWKProcessPoolFactory, enabling app Webview
to share cookies with IAB Webviews (pulled from [Niklas
Merz](https://github.com/NiklasMerz/cordova-plugin-inappbrowser/tree/add-webview))
- Implements WKWebView delegates to make event handlers and script injection
work
- Replaces iframe bridge with WKScriptMessageHandler bridge
- Updates the automated and manual tests for this plugin to test both
webview implementations when running on iOS.
Any feedback/suggestions/bug reports/collaboration to improve the
implementation in this PR would be most welcome.
### What testing has been done on this change?
The automated and manual tests have been run as [outlined
here](https://github.com/apache/cordova-plugin-inappbrowser/blob/master/CONTRIBUTING.md#running-plugin-tests)
and all tests appear to pass for the iOS platform against both webview
implementations.
Note: other platforms have not been tested because they have not been
changed.
### Notes
- A restructure of the native iOS implementation was necessary in order to
enable the UIWebView and WKWebView implementations to exist side-by-side.
- No dependency has been added on
[cordova-plugin-wkwebview-engine](https://github.com/apache/cordova-plugin-wkwebview-engine)
for the iOS platform
- If `usewkwebview=yes` is set and the WKWebView engine classes don't
exist in the project, the 'loaderror' callback will be invoked when attempting
to call `InappBrowser.open()`.
- Conditional pre-processor statements [are
used](https://github.com/dpa99c/cordova-plugin-inappbrowser/blob/CB-7179/src/ios/CDVInAppBrowser.m#L36)
to detect the presence of WKWebViewEngine classes at build time to prevent
build errors if not present
- Note: the [__has_include
macro](https://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros)
appears to only work in the device environment.
- On the iOS Simulator it always evaluates to false.
- This means the WKWebView implementation only works on
devices - on the Simulator `usewkwebview=yes` will result in a `loaderror`.
- The same classes exist in
[cordova-plugin-ionic-webview](https://github.com/ionic-team/cordova-plugin-ionic-webview)
as in `cordova-plugin-inappbrowser` so `usewkwebview=yes` will work with both.
- There is currently a fair bit of duplication in the UIWebView vs WKWebView
implementations. This could be cleaned up with some refactoring using
inheritance, although this is tricky in Objective-C (not my strongest language).
- `clearsessioncache` is yet to be implemented in the WKWebView
implementation. This is because the [httpCookieStore
interface](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/2881956-httpcookiestore?language=objc)
was only added in iOS 11 and so to support iOS 10 and below, a different
mechanism must be used to find and remove session cookies. This is not trivial
and may not even be possible.
- The WKWebView implementation was initially developed as a separate
WKWebView-only version of this plugin:
[cordova-plugin-inappbrowser-wkwebview](https://github.com/dpa99c/cordova-plugin-inappbrowser-wkwebview)
- A Cordova test project specifically to test switching between Webview
implementations can be [found
here](https://github.com/dpa99c/cordova-plugin-inappbrowser-test/tree/dual_ios_webviews).
### Checklist
- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html)
in the JIRA database
- https://issues.apache.org/jira/browse/CB-7179
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform
affected.
- CB-7179 (iOS): Add support to optionally use WKWebView for iOS
- [x] Added automated test coverage as appropriate for this change.
- No additional test coverage needed as no functionality has changed,
just the implementation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [InAppBrowser][iOS 8] Update to support WKWebView
> -------------------------------------------------
>
> Key: CB-7179
> URL: https://issues.apache.org/jira/browse/CB-7179
> Project: Apache Cordova
> Issue Type: Sub-task
> Components: cordova-plugin-inappbrowser
> Environment: iOS 8
> Reporter: Shazron Abdullah
> Priority: Major
>
> support dual use with UIWebView
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]