I have a UIWebView in objective-c that loads an external HTML with an embedded video (I have no access to this HTML). This video has a pre-roll ad from Google Ads (but can be from another provider in the future). This ad has a link to an external website that the user can click but it seems to be triggered by a javascript event (not a regular anchor).
I have set the delegate in order to force clicked links in the webview to open in Safari, but these links from the ads keep opening inside the webview. I think it's because they are triggered from javascript.
This is my delegate:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:
(NSURLRequest *)request navigationType:
(UIWebViewNavigationType)navigationType
{
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:[request URL]];
return NO;
}
return YES;
}
Does anyone knows of a way to force any navigation outside the domain loaded in the webview to open in Safari? I guess this way I could circumvent this problem.
Thanks.