Search code examples
cordovaionic-frameworkcordova-pluginsionic2

Cordova: can't use remote page as content for iOS CDVViewController


I'm trying to add Ionic 2 app as part of the native iOS application. As I found, CDVViewController should be used for integration.

  • have Xcode 7.3.1
  • installed pod 'Cordova', '4.2.1'
  • added config.xml which Ionic generated (not adding other files, because I need to display remote content)
  • replaced <content src="index.html" /> with <content src="http://localhost:8100/" /> in config.xml as their documentation says to do for remote content.
  • added localhost to App Transport Security exceptions (I tested it in another UIWebView and it's definitely working)

After all that CDVViewController still doesn't display my remote URL. Tried in many different ways with no luck.. Tried to navigate with JS — not working. Tried another domains as https://github.com. CDVViewController definitely see my config.xml and drops errors if it not there. If I replace back to <content src="index.html" /> (and add index.html to resources), it displays that index page, no problems.


Solution

  • Finally found: needed to add <allow-navigation href="..." /> tag. In my case it was <allow-navigation href="http://localhost" />.

    Check https://github.com/apache/cordova-plugin-whitelist#navigation-whitelist