You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2017/09/27 08:19:48 UTC

cordova-plugin-wkwebview-engine git commit: CB-13205 - Dynamic swipe back enabled preference

Repository: cordova-plugin-wkwebview-engine
Updated Branches:
  refs/heads/master 919dbcec3 -> 8d08190f1


CB-13205 -  Dynamic swipe back enabled preference

This closes #42


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/commit/8d08190f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/tree/8d08190f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/diff/8d08190f

Branch: refs/heads/master
Commit: 8d08190f1e1662d8fcef041e1b30f536422a2907
Parents: 919dbce
Author: Chet Corcos <cc...@gmail.com>
Authored: Tue Aug 22 11:32:27 2017 -0700
Committer: Shazron Abdullah <sh...@gmail.com>
Committed: Wed Sep 27 16:18:42 2017 +0800

----------------------------------------------------------------------
 README.md                    | 13 ++++++++++---
 plugin.xml                   |  4 ++++
 src/ios/CDVWKWebViewEngine.h |  2 ++
 src/ios/CDVWKWebViewEngine.m | 19 ++++++++++++++++---
 src/www/ios/ios-wkwebview.js |  9 +++++++++
 5 files changed, 41 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8d08190f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 9a03a13..0bafd32 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@
 Cordova WKWebView Engine
 ======
 
-This plugin makes `Cordova` use the `WKWebView` component instead of the default `UIWebView` component, and is installable only on a system with the iOS 9.0 SDK. 
+This plugin makes `Cordova` use the `WKWebView` component instead of the default `UIWebView` component, and is installable only on a system with the iOS 9.0 SDK.
 
 In iOS 9, Apple has fixed the [issue](http://www.openradar.me/18039024) present through iOS 8 where you cannot load locale files using file://, and must resort to using a local webserver. **However, you are still not able to use XHR from the file:// protocol without [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) enabled on your server.**
 
@@ -76,7 +76,7 @@ We have an [experimental plugin](https://github.com/apache/cordova-plugins/tree/
 Application Transport Security (ATS) in iOS 9
 -----------
 
-Starting with [cordova-cli 5.4.0](https://www.npmjs.com/package/cordova), it will support automatic conversion of the [&lt;access&gt;](http://cordova.apache.org/docs/en/edge/guide/appdev/whitelist/index.html) tags in config.xml to Application Transport Security [ATS](https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33) directives. 
+Starting with [cordova-cli 5.4.0](https://www.npmjs.com/package/cordova), it will support automatic conversion of the [&lt;access&gt;](http://cordova.apache.org/docs/en/edge/guide/appdev/whitelist/index.html) tags in config.xml to Application Transport Security [ATS](https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33) directives.
 
 Upgrade to at least version 5.4.0 of the cordova-cli to use this new functionality.
 
@@ -89,6 +89,13 @@ In order to allow swiping backwards and forwards in browser history like Safari
 <preference name="AllowBackForwardNavigationGestures" value="true" />
 ```
 
+You can also set this preference dynamically from JavaScript:
+
+```js
+window.WkWebView.allowsBackForwardNavigationGestures(true)
+window.WkWebView.allowsBackForwardNavigationGestures(false)
+```
+
 Limitations
 --------
 
@@ -97,7 +104,7 @@ If you are upgrading from UIWebView, please note the limitations of using WKWebV
 Apple Issues
 -------
 
-The `AllowInlineMediaPlayback` preference will not work because of this [Apple bug](http://openradar.appspot.com/radar?id=6673091526656000). This bug [has been fixed](https://issues.apache.org/jira/browse/CB-11452) in [iOS 10](https://twitter.com/shazron/status/745546355796389889). 
+The `AllowInlineMediaPlayback` preference will not work because of this [Apple bug](http://openradar.appspot.com/radar?id=6673091526656000). This bug [has been fixed](https://issues.apache.org/jira/browse/CB-11452) in [iOS 10](https://twitter.com/shazron/status/745546355796389889).
 
 
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8d08190f/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index dbe5896..a624c24 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -41,6 +41,10 @@
             <clobbers target="cordova.exec" />
         </js-module>
 
+        <js-module src="src/www/ios/ios-wkwebview.js" name="ios-wkwebview">
+            <clobbers target="window.WkWebView" />
+        </js-module>
+
         <config-file target="config.xml" parent="/*">
             <feature name="CDVWKWebViewEngine">
                 <param name="ios-package" value="CDVWKWebViewEngine" />

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8d08190f/src/ios/CDVWKWebViewEngine.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKWebViewEngine.h b/src/ios/CDVWKWebViewEngine.h
index 2fe4bc2..c71f4e2 100644
--- a/src/ios/CDVWKWebViewEngine.h
+++ b/src/ios/CDVWKWebViewEngine.h
@@ -24,4 +24,6 @@
 
 @property (nonatomic, strong, readonly) id <WKUIDelegate> uiDelegate;
 
+- (void)allowsBackForwardNavigationGestures:(CDVInvokedUrlCommand*)command;
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8d08190f/src/ios/CDVWKWebViewEngine.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKWebViewEngine.m b/src/ios/CDVWKWebViewEngine.m
index e9ff246..e359b04 100644
--- a/src/ios/CDVWKWebViewEngine.m
+++ b/src/ios/CDVWKWebViewEngine.m
@@ -173,16 +173,16 @@ static void * KVOContext = &KVOContext;
 {
     BOOL title_is_nil = (title == nil);
     BOOL location_is_blank = [[location absoluteString] isEqualToString:@"about:blank"];
-    
+
     BOOL reload = (title_is_nil || location_is_blank);
-    
+
 #ifdef DEBUG
     NSLog(@"%@", @"CDVWKWebViewEngine shouldReloadWebView::");
     NSLog(@"CDVWKWebViewEngine shouldReloadWebView title: %@", title);
     NSLog(@"CDVWKWebViewEngine shouldReloadWebView location: %@", [location absoluteString]);
     NSLog(@"CDVWKWebViewEngine shouldReloadWebView reload: %u", reload);
 #endif
-    
+
     return reload;
 }
 
@@ -457,6 +457,19 @@ static void * KVOContext = &KVOContext;
     return decisionHandler(NO);
 }
 
+#pragma mark - Plugin interface
+
+- (void)allowsBackForwardNavigationGestures:(CDVInvokedUrlCommand*)command;
+{
+    id value = [command argumentAtIndex:0];
+    if (!([value isKindOfClass:[NSNumber class]])) {
+        value = [NSNumber numberWithBool:NO];
+    }
+
+    WKWebView* wkWebView = (WKWebView*)_engineWebView;
+    wkWebView.allowsBackForwardNavigationGestures = [value boolValue];
+}
+
 @end
 
 #pragma mark - CDVWKWeakScriptMessageHandler

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8d08190f/src/www/ios/ios-wkwebview.js
----------------------------------------------------------------------
diff --git a/src/www/ios/ios-wkwebview.js b/src/www/ios/ios-wkwebview.js
new file mode 100644
index 0000000..d113876
--- /dev/null
+++ b/src/www/ios/ios-wkwebview.js
@@ -0,0 +1,9 @@
+var exec = require('cordova/exec');
+
+var WkWebKit = {
+    allowsBackForwardNavigationGestures: function (allow) {
+        exec(null, null, 'CDVWKWebViewEngine', 'allowsBackForwardNavigationGestures', [allow]);
+    }
+};
+
+module.exports = WkWebKit;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org