Skip to content

Instantly share code, notes, and snippets.

@bhuber
Created January 31, 2012 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhuber/1712851 to your computer and use it in GitHub Desktop.
Save bhuber/1712851 to your computer and use it in GitHub Desktop.
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