Skip to content

Instantly share code, notes, and snippets.

@toto
Created February 23, 2012 13:44
Show Gist options
  • Save toto/1892885 to your computer and use it in GitHub Desktop.
Save toto/1892885 to your computer and use it in GitHub Desktop.
Pass redirect URLs from an embedded webView to the shared account store
- (void)awakeFromNib;
{
[super awakeFromNib];
_webView.policyDelegate = self; // you can also do this in the XIB and save you this method
}
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener;
{
NSURL *redirectURL = [NSURL URLWithString:VCOAuthRedirectURLString];
if ([request.URL.scheme isEqual:redirectURL.scheme] &&
[request.URL.host isEqual:redirectURL.host] &&
[request.URL.path isEqual:redirectURL.path])
{
[listener ignore];
[[NXOAuth2AccountStore sharedStore] handleRedirectURL:request.URL]
// after this you receive will one of the notifications mentioned in the documentation
// accordingly you should hide or close the _webView
} else {
[listener use];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment