Created
April 19, 2013 00:27
-
-
Save keithelliott/5417258 to your computer and use it in GitHub Desktop.
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
#pragma mark - Web view delegate | |
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
if([request.URL.scheme isEqualToString:@"ios-app"]){ | |
// 8. get the url and check for the access token in the callback url | |
NSString *URLString = [[request URL] absoluteString]; | |
if ([URLString rangeOfString:@"access_token="].location != NSNotFound) { | |
// 9. Store the access token in the user defaults | |
NSString *accessToken = [[URLString componentsSeparatedByString:@"="] lastObject]; | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
[defaults setObject:accessToken forKey:@"access_token"]; | |
[defaults synchronize]; | |
// 10. dismiss the view controller | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
} | |
} | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment