您可能应该只点击不同的端点,或者为每个平台使用不同的参数并让服务器处理它。
那就是说你可以做这样的事情:
- (void)downloadHTMLAndUpdateCordova
{
NSURL *url = [NSURL URLWithString:@"http://www.someapi.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSHTTPURLResponse* response = nil;
NSError* error = nil;
NSData *htmlData = [NSURLConnection sendSynchronousRequest:self.request returningResponse:&response error:&error];
if (error == nil) {
NSString *htmlString = [NSString stringWithUTF8String:[htmlData bytes]];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"someCordovaFile.js" withString:@"someCordovaFileiOS.js"];
[self.webView loadHTMLString:htmlString baseURL:@"http://www.someapi.com"];
}
}