Cordova:无法使用远程页面作为iOS CDVViewController

时间:2016-10-10 12:46:55

标签: cordova ionic-framework cordova-plugins ionic2

我正在尝试添加Ionic 2应用程序作为本机iOS应用程序的一部分。正如我所发现的,CDVViewController应该用于集成。

  • 拥有Xcode 7.3.1
  • 已安装pod 'Cordova', '4.2.1'
  • 添加了Ionic生成的config.xml(不添加其他文件,因为我需要显示远程内容)
  • 在config.xml中将<content src="index.html" />替换为<content src="http://localhost:8100/" />,因为他们的文档说明要为远程内容做。
  • localhost添加到App Transport Security异常(我在另一个UIWebView中进行了测试,它确实有效)

毕竟CDVViewController仍然没有显示我的远程URL。尝试以许多不同的方式没有运气..尝试用JS导航 - 不工作。尝试将其他域名设为https://github.com。 CDVViewController肯定会看到我的config.xml,如果没有错误就会丢弃错误。如果我替换回<content src="index.html" />(并将index.html添加到资源),它会显示该索引页面,没有问题。

1 个答案:

答案 0 :(得分:1)

终于发现:需要添加<allow-navigation href="..." />标记。就我而言,它是<allow-navigation href="http://localhost" />

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