Internal navigation rejected: in Cordova on iOS

后端 未结 5 1151
滥情空心
滥情空心 2020-12-29 18:43

I have built an iOS app using Cordova. The app tries to load a web page e.g. http://yourdomain.com/home in index.html. But, the page stays white blank with error in console

相关标签:
5条回答
  • 2020-12-29 19:05

    It is a scheme used internally, just allow access/navigation to it:

    <access origin="about:*" />
    <allow-navigation href="about:" />
    

    It is not recommended to use

    <access origin="*" />
    <allow-navigation href="*" />
    

    as described in cordova-plugin-whitelist.

    0 讨论(0)
  • 2020-12-29 19:09

    I was having this problem and it turns out there are two config.xml files. The first one is in Xcode, but you have to edit the second one from the filesystem.

    AppName/config.xml
    
    AppName/platforms/ios/AppName/config.xml
    

    I added

    <allow-navigation href="*" /> 
    

    to both of them and it worked. Using 6.3.0.

    0 讨论(0)
  • 2020-12-29 19:10

    Thanks for the pointer. The solution

    <allow-navigation href="about:" />
    

    caused a cordova prepare error for me. I need to use the following instead:

    <allow-navigation href="about:*" />
    
    0 讨论(0)
  • 2020-12-29 19:15

    You have to add this line to your config.xml

    <allow-navigation href="http://yourdomain.com/home" />
    

    or this one if you want to allow the navigation to all the urls on yourdomain.com

    <allow-navigation href="http://yourdomain.com/*" />
    
    0 讨论(0)
  • 2020-12-29 19:17

    It's not recommend to open a url in your base web view. Use the cordova-plugin-inappbrowser and call the inappbrowser to open outer url:

    function open_outer_url(url){
        if(window.cordova && window.cordova.InAppBrowser){
            window.cordova.InAppBrowser.open(url, "_blank", 'location=no');
        }else{
            window.open(url,'_blank');
        }
    }
    
    0 讨论(0)
提交回复
热议问题