jqueryjquery-mobilecordova-pluginscordova-3cordova-ios

SecurityError: Blocked attempt to use history.replaceState() to change session history URL


I am working on a bank project on the Cordova framework. As per Apple's recent policy, I have built the bundle from Xcode 15.4 and iOS runtime 17+.

My app worked fine when I used Xcode 14.2 and runtime version 16.2. But after upgrading to the latest version, I am facing the below error.

SecurityError: Blocked attempt to use history.replaceState() to change session history URL. Only differences in query and fragment are allowed for file: URLs.

using

cordova-ios@3.6.3
jquery v3.6.0
jquery-mobile 1.5.0

I tried $pushEnableState = false but not working.

Please suggest any other solution. FYI I can't go for the Cordova-IOS version update instead I need a solution on the same version i.e. 3.6.3.

Thanks in Advance.


Solution

  • This solution worked for me.

    Disabled pushEnableState in index.html before invoking jQuery js file. Here is the snippet.

    <script type="text/javascript" src='jquery/jquery.min.js'>
    </script>
    <script>
        $(document).on("mobileinit", function() {
          /* Disable pushState to avoid replaceState issues */
          $.mobile.pushStateEnabled = false;
        });
    </script>
    <script type="text/javascript" src='jquery/mobile/jquery.mobile-1.5.0-alpha.1.min.js'>
    </script>