Created
January 31, 2012 20:55
-
-
Save bhuber/1712851 to your computer and use it in GitHub Desktop.
PhoneGap new browser window fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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