constantine-fry / foursquare-api-v2 Goto Github PK
View Code? Open in Web Editor NEWFoursquare API v2 For iOS
License: MIT License
Foursquare API v2 For iOS
License: MIT License
Hi;
When I cancel to login in authorization view of Foursquare, authorizeWithCallback returns success = YES. Shouldn't it be NO because I cancelled?
I think that sometimes it could be useful opening the authorization webView from a login modalView. Currently, we just can't do it ("Attempt to present ----- on ----- whose view is not in the window hierarchy").
I'd suggest to add a patch that resolve this issue. Something like this one:
+(void)authorizeWithCallback:(Foursquare2Callback)callback{
authorizeCallbackDelegate = [callback copy];
NSString *url = [NSString stringWithFormat:@"https://foursquare.com/oauth2/authenticate?client_id=%@&response_type=token&redirect_uri=%@",OAUTH_KEY,REDIRECT_URL];
FSWebLogin *loginCon = [[FSWebLogin alloc] initWithUrl:url];
loginCon.delegate = self;
loginCon.selector = @selector(done:);
UINavigationController *navCon = [[UINavigationController alloc]initWithRootViewController:loginCon];
navCon.navigationBar.tintColor = [UIColor lightGrayColor];
UIWindow *mainWindow = [[UIApplication sharedApplication]keyWindow];
UIViewController *topView = [self topViewController:mainWindow.rootViewController];
[topView presentViewController:navCon animated:YES completion:nil];
}
+ (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
if ([rootViewController.presentedViewController isMemberOfClass:[UINavigationController class]]) {
UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController;
UIViewController *lastViewController = [[navigationController viewControllers] lastObject];
return [self topViewController:lastViewController];
}
UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController;
return [self topViewController:presentedViewController];
}
Thanks!
Filippo
Case:
by that point I assume the app is not authorized and will go through login again, yet isAuthorized returns true since old stale token was still retrieved from keychain
While I'm familiar with blocks / closures in other languages, I'm new to blocks in objective-c and am having trouble modifying the example callback blocks to do much of anything other than call NSLog :/
For instance, replacing
callback:^(BOOL success, id result){
if (success) {
NSLog(@"%@",result);
}
}];
with code that tries to call an instance method or updates NSUserDefaults fails before the callback eever gets executed.
Any advice or help would be appreciated. TJust trying to do something meaningful upon login.
thnx,
mattpaul
not sure if the swarm app contains the auth code, but it handles the swarm:// url scheme
At your convenience, please tag a new release for Cocoapods. Thanks!
a relative timestamp would be the best. 5min ago vs 1 hour, etc.
Documentation can be found here: https://developer.foursquare.com/docs/lists/add
I've got several more endpoints, I'd be more than happy to take suggestions as to order of implementation or setting these up in a milestone.
In my application I have after some days that the user logged in the message "The request timed out." for the Foursquare request. This problema cause the block of UI for the timeoutInterval (30sec).
I can not figure out if the problem can be the session token expired. Is possible to check if the token is still valid? ([Foursquare2 isAuthorized] return always YES). I need to refresh the token every time the app is launched? Other explanations?
Is possible to add a timeout for the API requests?
This code uses "response_type=code" when authenticating and uses some clever but unnecessary work to get the token.
Why not use "response_type=token"? And disadvantages?
The api provides a mechanism for determining how many requests an application has remaining on a given response. It would be nice to have this information passed up to the client.
iOS9 seems to have a breaking issue with the url schemes in this library. We essentially need to whitelist your url scheme in LSApplicationQueriesSchemes, which is an array of strings, in your plist. Simply create the array, add your url scheme and you should be all set
Hi,
Can you include a license information in the repository?
Thanks
Hi,
I'm using Foursquare's API to get nearest locations around a user. But I'm not using Foursquare's authentification system whatsoever, it's just about getting the location, presenting them to the user and picking one.
So basically I'd love to be able to call this view:
In the middle of my app, and get the result of what the user selected.
I was wondering, what are the steps I should take to get to that view? Is it even possible to use it without asking the user to auth with Foursquare?
Thanks and have a nice day
When using the following pod declaration:
platform :ios, '7.0'
pod 'Foursquare-API-v2'
Files from the FSOAuth submodule get included in the pod, resulting in compilation errors, because it includes the FSOExample files aswell (main.m, FSAppDelegate.m).
Also, when someone is using the FSOAuth cocoapod seperately the project will break aswell because of redeclarations.
Dear Constantine,
First of all great work on the library its amazing.
I have a question so i wanted to run it by you. I'm looking into using the multi endpoint to explore venues with different queries inside my app. and i've noticed that it is not included in this library. are you planning on including it? if not. can you guide me on how to do the inclusion myself?
thanks man
just ran into a problem, I'm using cocoapods to install Foursquare-API-v2, and wherever cocoapods pulls the repository from it doesn't seem to have gotten the update that setupFoursquareWithKey changed names (which was hard to figure out as the root cause since the docs have been updated.) Just thought I'd let you know.
Cheers
Hi,
I've tried using Foursquare2-Mac to get a simple app to print to NSLog the badges a users has, or at least the checkin history but i have not been able to get it running. Is there any way you can post a wiki page on how to setup the Foursquare2-Mac?
Thanks!
Explanation and the solution can be found here: CocoaPods/CocoaPods#1128
Hi, I just wanted to know why you deprecated this awesome library and if it is still usable for projects using Objective-C
Application crashes when you tap on a venue marker and raises an exception -[VenueAnnotation objectForKeyedSubscript:]: unrecognized selector sent to instance.
I created a new app in foursquare dev panel, and I changed the secrete id and key in the demo app. When I try to run the app nothing happens, if I try to search I get the following error:
2014-10-31 19:52:47.192 Foursquare2[454:36211] Error Domain=kFoursquare2ErrorDomain Code=400 "Must provide parameter ll" UserInfo=0x1748795c0 {NSLocalizedDescription=Must provide parameter ll}
I don't see anything on the map. It's something related to the location, because the longitude and latitude are both 0 or it's an issue related to authentication.
Any clue?
Hi there, when I make this call:
- (IBAction)foursquareAuthButton:(id)sender {
[Foursquare2 authorizeWithCallback:^(BOOL success, id result){
if (success) {
NSLog(@"BOOM");
} else {
NSLog(@"NOPE");
}
}];
}
what I assume should be a UIWebView with a navbar appears, but only the navbar is visible. The rest of the screen is black.
I have EXEC_BAD_ACCESS in
(void)restConnection:(NSURLConnection *)connection
didReturnResource:(id)resource
object:(id)object
{
// NSUInteger code = [response statusCode];
// BOOL success = (code >= 200 && code <= 299);
Foursquare2Callback callback = (Foursquare2Callback)object;
callback(YES, resource); <---------------- EXEC_BAD_ACCESS
[callback release];
}
and deeper in the call stack
(void)connectionDidFinishLoading:(NSURLConnection *)connection
.............
[_delegate performSelectorOnMainThread:@selector(restConnection:didReturnResource:object:) withObjects:connection, results, _object, nil]; <---------------- EXEC_BAD_ACCESS
..............
That's all after logging in.
For example, when I try to checkin using the following method:
[Foursquare2 createCheckinAtVenue:currentVenue.venueId
venue:currentVenue.name
shout:[_checkinTextView string]
broadcast:broadcastPublic
latitude:[NSString stringWithFormat:@"%f", currentVenue.latLong.coordinate.latitude]
longitude:[NSString stringWithFormat:@"%f", currentVenue.latLong.coordinate.longitude]
accuracyLL:@"0"
altitude:@"0"
accuracyAlt:@"0"
callback:^(BOOL success, id result){
if (success){
NSLog(@"%@",result);
}else{
NSLog(@"Checkin Error");
}
}];
and if I don't have internet at the time I call the method, nothing happens.
Expected behavior:
NO
and Checkin Error
should appear on the console.It would be very handy if there was a better "no internet" error handling. Thank you!
Asking for searchVenuesNearByLatitude: ... etc the response gives me an error:
{
"code":200,
"errorType":"deprecated",
"errorDetail":"This endpoint will stop returning groups in the future. Please use a current version, see http://bit.ly/lZx3NU."
}
The URL links to the versioning topics of the overview developer page of 4sq.
Regards,
Andrea
kind of like how the facebook sdk uses [FBAppCall handleDidBecomeActiveWithSession] to treat that as if they cancelled
When using with a new Foursquare app, where the callback is something like
I'm missing something?
2011-05-28 14:34:18.471 Foursquare2-iOS[11535:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[**NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: access_token)'
* Call stack at first throw:
(
0 CoreFoundation 0x00f195a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0106d313 objc_exception_throw + 44
2 CoreFoundation 0x00ed1ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00ed1e6a +[NSException raise:format:] + 58
4 CoreFoundation 0x00f17e15 -[__NSCFDictionary setObject:forKey:] + 293
5 Foursquare2-iOS 0x000074c3 +[Foursquare2 setAccessToken:] + 76
6 Foursquare2-iOS 0x00003044 __-[Foursquare_APIAppDelegate setCode:]_block_invoke_1 + 175
7 Foursquare2-iOS 0x00009f64 +[Foursquare2 restConnection:didReturnResource:object:] + 50
8 CoreFoundation 0x00e89c7d _invoking + 29
9 CoreFoundation 0x00e89b51 -[NSInvocation invoke] + 145
10 Foundation 0x00187efc -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 229
11 Foundation 0x0019a506 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 184
12 Foursquare2-iOS 0x0000b122 -[NSObject(InvocationUtils) performSelectorOnMainThread:withObjectArray:] + 323
13 Foursquare2-iOS 0x0000afc1 -[NSObject(InvocationUtils) performSelectorOnMainThread:withObjects:] + 202
14 Foursquare2-iOS 0x0000c314 -[HRRequestOperation connectionDidFinishLoading:] + 656
15 Foundation 0x001ab112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
16 Foundation 0x001ab06b _NSURLConnectionDidFinishLoading + 133
17 CFNetwork 0x013ff492 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220
18 CFNetwork 0x014ca6e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293
19 CFNetwork 0x014ca9cf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1043
20 CFNetwork 0x013f5c84 _ZN19URLConnectionClient13processEventsEv + 100
21 CFNetwork 0x013f5ad3 _ZN17MultiplexerSource7performEv + 251
22 CoreFoundation 0x00efa8ff CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
23 CoreFoundation 0x00e5888b __CFRunLoopDoSources0 + 571
24 CoreFoundation 0x00e57d86 __CFRunLoopRun + 470
25 CoreFoundation 0x00e57840 CFRunLoopRunSpecific + 208
26 CoreFoundation 0x00e57761 CFRunLoopRunInMode + 97
27 GraphicsServices 0x017501c4 GSEventRunModal + 217
28 GraphicsServices 0x01750289 GSEventRun + 115
29 UIKit 0x00417c93 UIApplicationMain + 1160
30 Foursquare2-iOS 0x000027d4 main + 106
31 Foursquare2-iOS 0x00002761 start + 53
)
Printing description of resource:
<CFBasicHash 0x60585f0 [0xf86400]>{type = mutable dict, count = 1,
entries =>
11 : <CFString 0x6058340 [0xf86400]>{contents = "error"} = <CFString 0x6058430 [0xf86400]>{contents = "redirect_uri_mismatch"}
}
I have just register new app and set own key and secret.
Cloning into the submodule isn't working
$ git submodule init
Submodule 'Foursquare2/submodule/foursquare-ios-oauth' ([email protected]:Constantine-Fry/foursquare-ios-oauth.git) registered for path 'Foursquare2/submodule/foursquare-ios-oauth'
$ git submodule update
Cloning into 'Foursquare2/submodule/foursquare-ios-oauth'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
There is a plenty of apps that need foursquare auth token (for example I need to pass it to server in order to make friends check). There is no option to get access token from Foursquare2 class.
I have added a fix in my code.
+ (NSString *)accessToken{
NSUserDefaults *usDef = [NSUserDefaults standardUserDefaults];
return [usDef objectForKey:@"FOURSQUARE_ACCESS_TOKEN"];
}
It would be great to have a direct access to some kind of method handling this.
Here's hwo I got it to crash:
Turn orientation while tapping the screen.
The cause might be tapping or scrolling.
A fix could be to set userInteraction = NO; while the orientation changes.
After the execution of
[sharedApplication openURL:authURL];
in FSOAuthNoAppStore and returns Foursquare app opened and nothing happens, but I suppose redirect to your test app.
In the case when Foursquare application has already been opened on device it's woks fine.
CocoaPods has been supporting Mac apps for quite some time now. Would it be possible to update the podspec
so that it can also be integrated into a Mac app?
I tried at klaustopher@66f9566c1d1b2448d399b1c463cc26dee2848650 but FSOAuth is relying on iOS... I'll look into this later, if it's possible to have a dependency for only one platform.
Hello!
In the latest version from cocoapods (1.3.1) addVenueWithName: suddenly changed so the latitude and longitude are NSStrings instead NSNumber like in all other APIs. I first thought I'd report an issue on this, but it seems like it's fixed on master. It would be great to see an updated cocoapods release for this!
Also, any plans to have a version changes-list so one can know what changes between the updates?
Thanks a lot!
When performing native authentication through Foursquare2 class if there is no Foursquare app installed it sends user to AppStore instead of simply showing auth web view.
I think it is a very common case when developer needs to show webview if there is no other option. Please, make it possible to control this.
The cocoapods version of this project is at version 0.0.1
, but the repository has tags up to 1.1.2
at the time of writing this issue.
Is it possible to push these newer versions to cocoapods?
When using the "addPhoto:forCheckin:" method and passing in a regular UIImage, I get the following error back: "Invalid photo format: Invalid mime type: application/octet-stream"
I see you have some code for OS X as well but I couldn't see it on cocoapods.org for OS X. Is it possible to port this API library to OS X with just some podspec changes?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.