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
#import "FoursquareAuthentication.h" | |
// 5. setup some helpers so we don't have to hard-code everything | |
#define FOURSQUARE_AUTHENTICATE_URL @"https://foursquare.com/oauth2/authorize" | |
#define FOURSQUARE_CLIENT_ID @"YOUR CLIENT ID" | |
#define FOURSQUARE_CLIENT_SECRET @"YOUR CLIENT SECRET" | |
#define FOURSQUARE_REDIRECT_URI @"ios-app://redirect" | |
@interface FoursquareAuthentication () |
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]; |
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
#import "ViewController.h" | |
#import "FoursquareAuthentication.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; |
OlderNewer