Boss said, our project to hybrid, to achieve 1, HTML can call native;2, local HTML call local HTML interface, 3, can load remote interface .....
Because my project is already there (hereinafter referred to as the project), so is to add Cordova in the existing project, just load the remote interface this has been a long time, injury ~ ~ ~
Configure Cordova
People are too lazy to read the blog here. Or search by yourself, online a lot.
Loading the remote interface
Read a few blog, not all.
A, iOS Cordova how to load the remote interface?
B, cordoval the use of iOS in the collation
。。。。。。
No way
Then I try to use the $ cordova Create Demo ... command to create a demo (hereinafter referred to as demo), and then change
@interfaceMainviewcontroller:cdvviewcontroller@end#import "MainViewController.h"@implementationMainviewcontroller- (ID) init{ Self=[Super Init]; if(self) {self.startpage=@"https://www.pgyer.com/ws9u"; } returnSelf ;}@end
Run
Lying trough, how can this be ...?
And then open two items, see this to that, anyway is a bitter tears, the key is, the demo has two www files, I first compared to the top that, which is right, beep the dog. After later tracking code to catch up to the following staging directory. @#¥%......&* (
All right, spit out the groove, dinner.
1. Change the CONFIG. file
Add the following content:
<featurename= "Intentandnavigationfilter"> <paramname= "Ios-package"value= "Cdvintentandnavigationfilter" /> <paramname= "onload"value= "true" /> </feature>
This is my complete content: CONFIG.
<?XML version= ' 1.0 ' encoding= ' utf-8 '?><WidgetsID= "Xidx"version= "1.0.0"xmlns= "Http://www.w3.org/ns/widgets"XMLNS:CDV= "http://cordova.apache.org/ns/1.0"> <featurename= "Localstorage"> <paramname= "Ios-package"value= "Cdvlocalstorage" /> </feature> <featurename= "Handleopenurl"> <paramname= "Ios-package"value= "Cdvhandleopenurl" /> <paramname= "onload"value= "true" /> </feature> <featurename= "Intentandnavigationfilter"> <paramname= "Ios-package"value= "Cdvintentandnavigationfilter" /> <paramname= "onload"value= "true" /> </feature> <featurename= "Gesturehandler"> <paramname= "Ios-package"value= "Cdvgesturehandler" /> <paramname= "onload"value= "true" /> </feature> <name>TEST</name> <Description>A Sample Apache Cordova application that responds to the Deviceready event. </Description> <authorEmail= "[email protected]"href= "Http://cordova.io">Apache Cordova Team</author> <contentsrc= "Index.html" /> <AccessOrigin="*" /> <allow-intenthref= "http://*/*" /> <allow-intenthref= "https://*/*" /> <allow-intenthref= "tel:*" /> <allow-intenthref= "sms:*" /> <allow-intenthref= "mailto:*" /> <allow-intenthref= "geo:*" /> <allow-intenthref= "itms:*" /> <allow-intenthref= "itms-apps:*" /> <featurename= "Htmlplugin"> <paramname= "Ios-package"value= "Htmlplugin" /> </feature></Widgets>
2. Change the cdvintentandnavigationfilter.m file
Modified-(void) Parserdidstartdocument: (Nsxmlparser *) parser method;
- (void) Parserdidstartdocument: (nsxmlparser*) parser{//File:url <allow-navigations> is added by defaultSelf.allownavigations = [[Nsmutablearray alloc] initwitharray:@[@"file://",@"/ http",@"https://",@"xxxxxschemes://"]]; //no intents is added by defaultSelf.allowintents =[[Nsmutablearray alloc] init];}
If you need to respond to scheme, add scheme, and don't forget to register scheme in Info.plist.
:
Attached Demo:https://github.com/xuzixian/cordovademo
It's a bit messy, let's see.
IOS Cordova Loading Remote interface