我有一个简单的Cordova包装应用程序,它指向外部网页,而不定义任何自己的视图.
我希望来自该域的所有内部链接都加载到应用程序内,但所有外部链接(http://twitter.com等)都要加载到系统浏览器中,因此这些页面具有后退/前进功能.
在具有视图的普通应用程序中,我可以设置target='_system'在默认浏览器中加载链接,或使用cordova-plugin-inappbrowser在Web浏览器视图中显式打开链接.不幸的是,在这种情况下,我无法编辑服务器端代码,因此需要一个适用于应用程序的解决方案.
如果我这样定义config.xml,那么内部和外部链接都会加载到app中.
<content src="http://example.com/" />
<access origin="*" />
<allow-navigation href="*" />
Run Code Online (Sandbox Code Playgroud)
如果我定义了config.xmlwith allow-intent,则在系统浏览器中打开内部和外部链接.
<content src="http://example.com/" />
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
Run Code Online (Sandbox Code Playgroud)
其他人建议使用自定义javascript来覆盖targetto _system,但是因为我没有自己的观点,所以我不能真正做到这一点.
是否可以定义allow-intent为科尔多瓦-插件白名单以这样的方式,包括不属于内部域的所有URL?
或将我需要以某种方式覆盖shouldStartLoadWithRequest在MainViewController,然后调用[[UIApplication sharedApplication] openURL:url]?