One of my projects has a web view which is used to host a HTML5 web game (included in the app bundle). I've run into a curious issue. The game communicates with the hosting app via open URL calls (as detailed in the following question: Is is possible to communicate between UINavigationController and web page loaded inside UIWebView?). I over-ride the following method in the web view's delegate:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *requestURL = [request URL];
NSString *host = [requestURL host];
if([host isEqualToString: @"printHello"])
{
NSLog(@"Hello!");
return NO;
}
return YES;
}
This works fine for the first call (such as document.location(my-app-scheme://printHello)), then Hello! is indeed logged into the application's running console. However, attempting to immediately call a second load URL of exactly the same thing is ignored.
I've worked around this by making sure any communication between the webview and the app happens only in single calls, but this is proving to be quite restrictive - is there a better strategy to fix this?