Skip to content

Instantly share code, notes, and snippets.

@bhuber
Created Jan 31, 2012
Embed
What would you like to do?
PhoneGap new browser window fix
/**
* Start Loading Request
* This is where most of the magic happens... We take the request(s) and process the response.
* From here we can re direct links and other protocalls to different internal methods.
*/
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//super hackish hack of the night, so the social networking stuff doesn't trigger another window to be opened.
NSArray *special = [NSArray arrayWithObjects:
@"http://platform.twitter.com/",
@"cdn.api.twitter.com",
@"https://apis.google.com",
@"https://m.google.com",
@"https://connect.facebook.net",
nil];
NSString *urlStr = [[request URL] absoluteString];
for (NSString * str in special) {
if ([urlStr hasPrefix:str]) {
return YES;
}
}
//NSLog(@" allowed URL %@", urlStr);
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment