Created
January 21, 2011 00:20
-
-
Save jxson/789006 to your computer and use it in GitHub Desktop.
Enable Cookies in your phoneGap app and open http/ https links in safari
This file contains 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
- (id) init | |
{ | |
/** | |
* Enable cookies | |
**/ | |
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; | |
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; | |
NSHTTPCookie *cookie; | |
for (cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] | |
cookies]) { | |
NSLog(@"%@", [cookie description]); | |
} | |
return [super init]; | |
} | |
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType | |
{ | |
NSURL *url = [request URL]; | |
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) | |
{ | |
[[UIApplication sharedApplication] openURL:url]; | |
return NO; | |
} | |
else | |
{ | |
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
I know your pain, good luck with your app!