{"action":"created","issue":{"url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/issues/271","repository_url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser","labels_url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/issues/271/comments","events_url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/issues/271/events","html_url":"https://github.com/apache/cordova-plugin-inappbrowser/pull/271","id":329919678,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzMDUzNDI2","number":271,"title":"CB-7179 (iOS): Add WKWebView support for iOS","user":{"login":"dpa99c","id":2345062,"node_id":"MDQ6VXNlcjIzNDUwNjI=","avatar_url":"https://avatars0.githubusercontent.com/u/2345062?v=4","gravatar_id":"","url":"https://api.github.com/users/dpa99c","html_url":"https://github.com/dpa99c","followers_url":"https://api.github.com/users/dpa99c/followers","following_url":"https://api.github.com/users/dpa99c/following{/other_user}","gists_url":"https://api.github.com/users/dpa99c/gists{/gist_id}","starred_url":"https://api.github.com/users/dpa99c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpa99c/subscriptions","organizations_url":"https://api.github.com/users/dpa99c/orgs","repos_url":"https://api.github.com/users/dpa99c/repos","events_url":"https://api.github.com/users/dpa99c/events{/privacy}","received_events_url":"https://api.github.com/users/dpa99c/received_events","type":"User","site_admin":false},"labels":[{"id":1059438060,"node_id":"MDU6TGFiZWwxMDU5NDM4MDYw","url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/labels/feature","name":"feature","color":"006b75","default":false},{"id":1023924639,"node_id":"MDU6TGFiZWwxMDIzOTI0NjM5","url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/labels/platform:%20ios","name":"platform: ios","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":30,"created_at":"2018-06-06T15:29:16Z","updated_at":"2018-09-30T12:48:42Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/pulls/271","html_url":"https://github.com/apache/cordova-plugin-inappbrowser/pull/271","diff_url":"https://github.com/apache/cordova-plugin-inappbrowser/pull/271.diff","patch_url":"https://github.com/apache/cordova-plugin-inappbrowser/pull/271.patch"},"body":"### Platforms affected\r\niOS\r\n\r\n\r\n### What does this PR do?\r\nThis PR adds support for WKWebView to the InappBrowser plugin on iOS. \r\nIt:\r\n- 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).\r\n- takes on feedback from #245\r\n- 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.\r\n\r\nAdditional changes in this PR include:\r\n\r\n- Separate UIWebView and WKWebView implementations which are invoked by an intermediate dispatcher dependent on the `usewkwebview` option.\r\n- 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))\r\n- Implements WKWebView delegates to make event handlers and script injection work\r\n- Replaces iframe bridge with WKScriptMessageHandler bridge\r\n- Updates the automated and manual tests for this plugin to test both webview implementations when running on iOS.\r\n\r\n\r\nAny feedback/suggestions/bug reports/collaboration to improve the implementation in this PR would be most welcome.\r\n\r\n### What testing has been done on this change?\r\nThe 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.\r\n\r\nNote: other platforms have not been tested because they have not been changed.\r\n\r\n### Notes\r\n\r\n- A restructure of the native iOS implementation was necessary in order to enable the UIWebView and WKWebView implementations to exist side-by-side.\r\n- No dependency has been added on [cordova-plugin-wkwebview-engine](https://github.com/apache/cordova-plugin-wkwebview-engine) for the iOS platform\r\n\t- 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()`. \r\n\t- 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\r\n\t\t- Note: the [__has_include macro](https://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros) appears to only work in the device environment.\r\n\t\t\t- On the iOS Simulator it always evaluates to false.\r\n\t\t\t- This means the WKWebView implementation only works on devices - on the Simulator `usewkwebview=yes` will result in a `loaderror`.\r\n\t- 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.\r\n- 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).\r\n- `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.\r\n- 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)\r\n- 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).\r\n\r\n### Checklist\r\n- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database\r\n    - https://issues.apache.org/jira/browse/CB-7179\r\n- [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.\r\n    - CB-7179 (iOS): Add support to optionally use WKWebView for iOS\r\n- [x] Added automated test coverage as appropriate for this change.\r\n    - No additional test coverage needed as no functionality has changed, just the implementation."},"comment":{"url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/issues/comments/425718642","html_url":"https://github.com/apache/cordova-plugin-inappbrowser/pull/271#issuecomment-425718642","issue_url":"https://api.github.com/repos/apache/cordova-plugin-inappbrowser/issues/271","id":425718642,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTcxODY0Mg==","user":{"login":"dpa99c","id":2345062,"node_id":"MDQ6VXNlcjIzNDUwNjI=","avatar_url":"https://avatars0.githubusercontent.com/u/2345062?v=4","gravatar_id":"","url":"https://api.github.com/users/dpa99c","html_url":"https://github.com/dpa99c","followers_url":"https://api.github.com/users/dpa99c/followers","following_url":"https://api.github.com/users/dpa99c/following{/other_user}","gists_url":"https://api.github.com/users/dpa99c/gists{/gist_id}","starred_url":"https://api.github.com/users/dpa99c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpa99c/subscriptions","organizations_url":"https://api.github.com/users/dpa99c/orgs","repos_url":"https://api.github.com/users/dpa99c/repos","events_url":"https://api.github.com/users/dpa99c/events{/privacy}","received_events_url":"https://api.github.com/users/dpa99c/received_events","type":"User","site_admin":false},"created_at":"2018-09-30T12:48:42Z","updated_at":"2018-09-30T12:48:42Z","author_association":"CONTRIBUTOR","body":"Unsure why the integration tests are [failing on Travis CI](https://user-images.githubusercontent.com/2345062/46257772-26929500-c4b7-11e8-9ea5-fca8ae1ea280.png) as they are passing locally: \r\n\r\n<img src=\"https://user-images.githubusercontent.com/2345062/46257772-26929500-c4b7-11e8-9ea5-fca8ae1ea280.png\" width=\"480\" />\r\n"}}
{"actor":{"display_login":"dpa99c"}}