To implement Foursquare in my app - iphone

How to implement foursquare in my app.I have tried some sample app but I don't know how to do that exactly.can any one guide me.
Thanks....

Following are the sample applications provided on github...
anoopr / core-data-talk
Constantine-Fry / Foursquare-API-v2

https://github.com/Constantine-Fry/Foursquare-API-v2/tree/master/Foursquare2-iOS
Download this project and drag Foursquare2 folder in your project and json parser.
This what i did to get the near by places..
[Foursquare2 searchVenuesNearByLatitude:lat_String
longitude:log_String
accuracyLL:nil
altitude:nil
accuracyAlt:nil
query:searchString
limit:#"10"
intent:#"browse"
categoryId:nil
Radius:radius
callback:^(BOOL success,id result){
if (success) {
// NSLog(#"Result : %#",result);
[self parseplacesForSearch:result];
}
else {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:#"Message"
message:#"Sorry!! their is no places around your location"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil ];
[alertView show];
[alertView release];
}
}];

Related

xcode webview error not working

This web view failed error showing the alert popup even when it is loading the website. I believe I need to delay this method in order for it to work.What will be the best method for doing this?
- (void)webView:(UIWebView *)webViewfail didFailLoadWithError:(NSError *)error
{
if([webViewfail isEqual:webview]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Connection Failed" message:#"Check your Internet connection before refreshing."
delegate:webview
cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
}
Here is how I am loading the website
- (void)viewDidLoad
{
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.blabla.com"]]];
}
The problem is most likely an error -999 which generally happens when something from the webpage does not load correctly or a user tries to navigate back while the page is still loading. After some research here's what I found and used to keep the NetworkAlert from poping up every time but still popping up when there is no network.
-(void)webView:(UIWebView *)webBlog didFailLoadWithError:(NSError *)error{
if ([error code] != -999) {
NSLog(#"Could not load the dumb webPage");
//show error alert, etc.
[self showNoNetworkAlert];
}else{
NSLog(#"Could not load the dumb web page...just might blame user!");
}
}
- (void) showNoNetworkAlert{
UIAlertView *baseAlert = [[UIAlertView alloc]
initWithTitle:#"No Network" message:#"A network connection is required. Please verify your network settings and try again."
delegate:nil cancelButtonTitle:nil
otherButtonTitles:#"Dismiss", nil];
[baseAlert show];
}
Hope this helps someone...

Face book and twitter integration to iphone app not working on device

I am very new to iOS development.I am making an application in which i required to integrate twitter and Facebook for wall posting.
I have done all the required coding for this and on simulator it is working fine but not on device.
one more question as the coding for Facebook integration i have copied it from other "demo" application.So what else we need to change in it to make it for my own application.Because when i see my update done by my app on Facebook wall, "demo" app name comes there with the post.
Please guide me !!Thanking you in Advance!!
Facebook
It seems you have jumped to coding part before reading the documentation. Before integrating facebook sdk and writing your code, you need create a new app section in facebook developer console, get an Facebook app id. You need to use that app id in your project, not the app id shipped with facebook demo application.
Documentation explains the process fully, no need to rewrite it here. Make sure you read it to the end.
Twitter
I am not sure if you are having problem in twitter also (question is unclear on that). If yes, you should tell how you are connecting to twitter. But generally, from the tone of your questions, it seems you haven't read the documentation, on creating an app section in respective developer console, and getting app id.
I don't know how much integration you need or if your willing to require iOS 6 but in iOS 6 it is SO MUCH easier to integrate Facebook and Twitter.
This is all the code:
In the header file:
#import "Social/Social.h"
In the main file:
//Twitter
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
NSLog(#"Done!");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#"Status Text"];
[self presentViewController:controller animated:YES completion:Nil];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:#"You can't send a tweet right now. You must be online and signed into at least one Twitter account." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
//Facebook
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
if (result == SLComposeViewControllerResultCancelled) {
NSLog(#"Cancelled");
} else {
NSLog(#"Done!");
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#""];
[self presentViewController:controller animated:YES completion:Nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Facebook Error" message:#"Either you are not logged into Facebook or your Facebook username and password are incorrect." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
[alert show];
}
You Can use Share kit framework, http://getsharekit.com
As per integrating twitter in your application.Try this code
at self.fullimage write any url of image.
Call buildTweetSheet method to post to twitter.
import Twitter.framework
import
#property(nonatomic,strong) TWTweetComposeViewController *_tweetSheet;
#synthesize _tweetSheet;
-(void)buildTweetSheet
{
NSLog(#"buildTweetSheet");
_tweetSheet = [[TWTweetComposeViewController alloc] init];
UIImage *eimage=UIImage *eimage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.fullimage]]];
[_tweetSheet setInitialText:#""];
[_tweetSheet addImage:eimage];
[_tweetSheet setInitialText:#""];
[self presentModalViewController:_tweetSheet animated:YES];
TWTweetComposeViewControllerCompletionHandler completionHandler = ^(TWTweetComposeViewControllerResult result)
{
if(result == TWTweetComposeViewControllerResultDone) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Done" message:#"Image Posted Successfully" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Failed" message:#"Image Posted Failed" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
[self dismissModalViewControllerAnimated:YES];
};
[_tweetSheet setCompletionHandler:completionHandler];
}

didFailToRegisterForRemoteNotificationsWithError is fired, how to get more info?

For the first time I am playing with APNS, I tried to run a proof of concept, with an iOS 5.0.1 device, and the didFailToRegisterForRemoteNotificationsWithError is fired. I know it has been fired because I show an UIAlertView to notify the error:
- (void)application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
// Inform the user that registration failed
NSString* failureMessage = #"There was an error while trying to \
register for push notifications.";
UIAlertView* failureAlert = [[UIAlertView alloc] initWithTitle:#"Error"
message:failureMessage
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[failureAlert show];
[failureAlert release];
}
How can I get more info about the error?
Try doing something like NSLog(#"%#", error.userInfo");, that should output some info into the terminal.
I ended up with this code, which works and lets me progress a bit:
NSString* failureMessage = error.localizedDescription;
UIAlertView* failureAlert = [[UIAlertView alloc] initWithTitle:#"Error"
message:failureMessage
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[failureAlert show];
Sorry, iObjectiveC noob here.

UIAlertView from Tab Button - No Internet Connection

Looking for some help again...
I've currently got 2 sections of my app that need internet connection, 1 is a photo gallery through Flickr and the other a Twitter Feed, I was wondering if this is the correct code for the UIAlertView... I can get it working from a button but thats all!
{
-(void)didTap_roundedRectButton1:(id)sender forEvent:(UIEvent *)event {
UIAlertView *alertView = [[UIAlertView alloc] init];
alertView.title = #"You are not connected to the Internet!";
alertView.message = #"Please check your connection and try again...";
[alertView addButtonWithTitle:#"Ok"];
[alertView show];
[alertView release];
}
i think you need to use this example as i have used it to check is there any network is available and device is connected to any one of the network it is alos available on the apple's developer example site
example link is this
You should try this:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"You are not connected to the Internet!"
message:#"Please check your connection and try again..."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alertView show];
[alertView release];
and can you post the code how do you create the UIButton?

ALAssetsLibrary ALAssetsLibraryAccessUserDeniedError

When you first try to access a user's ALAssetsLibrary, the OS will present them with a dialog asking for permission. If they do not allow this, a failureBlock will be called and will always be called in the future. Is there a way to force a prompt of this authorization request again?
I notice in the Maps app, that they inform the user to go to the Settings app to turn on location services with a button. However, there is no way that I know of to programmatically open the Settings app. Should I just display directions as to how to turn on the location services?
You can't open up the settings app in an Apple approved manner.
The best you can hope for is to trap the error and then display a UIAlertView or other view with instructions on how to do this. Take a look at the latest v. of the Dropbox app for an idea on how they instruct the user.
When you try to access the Library from your code, you can use the error handler to catch the error and display an alert specifying to the user what to do.
Example
failureBlock:^(NSError *error) {
// error handling
if (error.code == ALAssetsLibraryAccessGloballyDeniedError) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!"
message:#"Error loading image... \nEnable Location Services in 'Settings -> Location Services'."
delegate:self cancelButtonTitle:#"OK"
otherButtonTitles:nil, nil];
[alert show];
} else if (error.code == ALAssetsLibraryAccessUserDeniedError) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!"
message:[NSString stringWithFormat:#"Error loading image... \nEnable Location Services in 'Settings -> Location Services' for %#.", [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleDisplayName"]]
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!" message:#"Error loading image..." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
}