Created
February 23, 2012 13:44
-
-
Save toto/1892885 to your computer and use it in GitHub Desktop.
Pass redirect URLs from an embedded webView to the shared account store
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
- (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