Skip to content

Instantly share code, notes, and snippets.

@jxson
Created January 21, 2011 00:20
Show Gist options
  • Save jxson/789006 to your computer and use it in GitHub Desktop.
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
- (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 ];
}
}
@jxson
Copy link
Author

jxson commented Dec 9, 2011

I know your pain, good luck with your app!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment