apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 989 forks source link

Cannot change 'allowsBackForwardNavigationGestures' from javascript #1091

Closed Actardnes closed 1 year ago

Actardnes commented 3 years ago

Bug Report

Problem

window.WkWebView.allowsBackForwardNavigationGestures called from javascript is not changing webview behaviour specified in config.xml

What is expected to happen?

window.WkWebView.allowsBackForwardNavigationGestures(true) - should enable gestures navigation window.WkWebView.allowsBackForwardNavigationGestures(false) - should disable gestures navigation

What does actually happen?

Calling window.WkWebView.allowsBackForwardNavigationGestures does not change webview behaviour. If in config.xml related flag is set to false calling window.WkWebView.allowsBackForwardNavigationGestures(true) is not enabling gestures navigation. No error occurred.

Information

I want to enable gesture navigation only for some pages, but it looks like this settings is taken into an account only during starting app.

Command or Code

// routing.js
if(routeWithBackNavigation){
    window.WkWebView.allowsBackForwardNavigationGestures(true);
} else{
    window.WkWebView.allowsBackForwardNavigationGestures(false);
}

Environment, Platform, Device

Experiencing this issue in Ipad & Iphone (ios version 12,13,14)

Version information

Cordova: 10.0.0 Cordova-ios: 6.2.0 XCode: 12.4 Plugins:

[Update] Also not working without plugins

Checklist

timbru31 commented 3 years ago

I see you use a custom WebViewEngine: @ahovakimyan/cordova-plugin-wkwebviewxhrfix@1.0.0 - probably this needs to be reported there.

Actardnes commented 3 years ago

I removed all plugins, still not working

Actardnes commented 1 year ago

I back to that and I found a solution. The problem was in my config.xml in ios section. I had the wrong value for CordovaWebViewEngine. I had to change: CDVWKWebViewEngine -> CDVWebViewEngine.

Old:


        <feature name="CDVWKWebViewEngine">
            <param name="ios-package" value="CDVWKWebViewEngine" />

        <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

New:

        <feature name="CDVWebViewEngine">
            <param name="ios-package" value="CDVWebViewEngine" />
        </feature>

        <preference name="CordovaWebViewEngine" value="CDVWebViewEngine" />
9t96 commented 3 months ago

Its happening to me with 7.1.0. Even putting the new settings commented by @Actardnes