javascriptioscordovacordova-pluginspopup-blocker

Cordova ios app - Not able to open links due to pop up blocker


I have a cordova application which downloads an angularjs application (Say 'MyAngularApp') from the server based on some version matching logic. This 'MyAngular' app comes in a zipped folder which my cordova application unzips and stores at a persistent location on mobile device.

After 'MyAngularApp' is successfully downloaded and unzipped, I launch 'MyAngularApp/index.html' from persistent location on device using file://path_to_angularjs_application_in_device/MyAngularApp/index.html

Now, the issue I am facing is that when user clicks on a link in 'MyAngularApp' on iOS, the popupblocker is blocking the pages to open. The code that is written inside 'MyAngularApp' to open a page is

        function openUrlInNewTab(url, params, isExternal) {
                    if (params) {
                        url += '#' + params;
                    }
                    var windowName = url.startsWith('mailto') ? '_self' : '_blank';
                    $window.open(url, windowName);
        }

I know if we can make a change above to modify the code and replace _blank to _system, it should work theoretically, but the problem is that I can not make a change inside 'MyAngularApp' code.

I tried switching off popupblocker setting from safari settings but that did not help. The point to consider here is that I can not make a change inside 'MyAngularApp' code. I can only modify my own cordova app which downloads this 'MyAngularApp'.

This issue happens only in iOS. This works perfectly on Android.
Tested on iOS versions 12+. Cordova version 7.0.0

What I tried ?

  1. Go to Settings Safari Block Pop-ups Disable (Did not work. New window still did not open)
  2. Install cordova InAppBrowser plugin and assign window.open = cordova.InAppBrowser.open (Did not work because the problem here is that this piece if code would be applicable till my cordova app is loaded. Once 'MyAngularApp' loads then context changes and this chunk of code is no more in context).

Any ideas ?


Solution

  • I was able to resolve this myself. Here's what resolved my issue, in case someone is still looking for an answer.

    Since, In the scenario explained above, the embedded AngularJs application did not have access to cordova libraries. It was downloaded on the go and then browsed in the cordova webview and that was blocking the required cordova assistance to open a new window.

    I included 'cordova.js' file manually in the folder where my index.html resided and it resolved the issue.