Twitter integration no response in (ios 5) - iphone

I am developing a application in which I have integrated Twitter by using these Twitter-Oath-iPhone.
These library are working fine on lower version then ios 5 how can I use the twitter in ios 5. I don't know either Twitter change in there API or apple have make any change in ios 5.

you used API well work in IOS 5 only minor change in "SA_OAuthTwitterEngine.m" class
Replace this Function in "SA_OAuthTwitterEngine.m" class
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate
{
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"https://twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"https://twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"https://twitter.com/oauth/authorize"];
}
return self;
}

Try by replace this Function in "SA_OAuthTwitterEngine.m"
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"http://twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"http://twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"http://twitter.com/oauth/authorize"];
}
return self;
}
in place of this code use this one
- (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate {
if (self = (id) [super initWithDelegate: delegate]) {
self.requestTokenURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/request_token"];
self.accessTokenURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/access_token"];
self.authorizeURL = [NSURL URLWithString: #"https://api.twitter.com/oauth/authorize"];
}
return self;
}
this one slove my problem........

Twitter integration for iOS 5 Tutorial:
One of the exciting new features in iOS 5 is Twitter integration. Photos, YouTube, Safari, and Maps come fully integrated. With most iOS 5 users jumping on the Twitter bandwagon (Twitter daily signups tripled, according to Twitter’s CEO), allowing your users to tweet about your app could help put it in front of more people. In this iDevBlogADay post, I want to write a tutorial for integrating your app with Twitter.

For twitter integration in ios 5 its very easy , because of new framework added in ios 5 onwards just follow there steps:
1. add twitter.framework
2. follow from twitter official site

There is a very easy way in ios-5 for twitter integration, just add Twitter framework and use this code. Link is below.
http://bit.ly/FLTwitter

you can also use this code with inbuilt framework of Twiiter in iOS5.....
just add Twitter.framework from your build library
and then just import bellow header file in your viewcontroller.h file
#import <Twitter/TWTweetComposeViewController.h>
afetr that when you want to share your message on twitter just use bellow code
in viewcontroller.m file again just import
#import <Twitter/TWTweetComposeViewController.h>
.....
- (IBAction)shareOnTwitter:(id)sender {
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:#"It's really that simple!"];
[twitter addImage:[UIImage imageNamed:#"yourimage.jpg"]];//if required
[twitter addURL:[NSURL URLWithString:#"your url link"]];//if required
[self presentViewController:twitter animated:YES completion:nil];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
if(res == TWTweetComposeViewControllerResultDone)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:#"Succes!" message:#"Your Tweet was posted succesfully" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}else if(res == TWTweetComposeViewControllerResultCancelled)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:#"Canceled" message:#"Your Tweet was not posted" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
[self dismissModalViewControllerAnimated:YES];
};
}
May this Help you
and this code is may b not work in simulator sometime so test it in device.....

Related

Objective-C Tested app on iPhone, updated data, data doesnt change

I just built my first app and now I started testing it on my phone. It looks great when I first launch the app after building it, the launch images appears and then my json data is loaded via NSURL and displays properly on the app. But when I close down the app, update the data via php and mysql and re open it the launch image does not appear and my app is not updated. Is it possible to have the app launch like it did when I first launched it, always have launch image and also get the new data?
Here is my code if it helps.
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadJSON];
}
- (void)loadJSON
{
Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
if (networkStatus == NotReachable) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: #"Error" message: #"Connection Failed" delegate: self cancelButtonTitle:#"Refresh" otherButtonTitles:nil]; [alert show]; [alert release];
});
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *url = [NSURL URLWithString:#"http://url.com/GetData.php"];
NSData *data = [NSData dataWithContentsOfURL:url options:0 error:nil];
NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSArray *firstItemArray = array[0];
NSString *yesNoString = firstItemArray[0];
NSString *dateString = firstItemArray[1];
NSString *timeString = firstItemArray[2];
NSString *homeString = firstItemArray[3];
NSString *awayString = firstItemArray[4];
NSString *lastUpdatedString = firstItemArray[5];
dispatch_async(dispatch_get_main_queue(), ^{
self.YesOrNo.text = yesNoString;
self.date.text = [#"For " stringByAppendingString:dateString];
self.time.text = timeString;
self.home.text = homeString;
self.away.text = awayString;
self.lastUpdated.text = lastUpdatedString;
self.lastUpdatedText.text = #"Last Updated";
self.vs.text = #"vs";
});
});
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
[self loadJSON];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[_YesOrNo release];
[_date release];
[_time release];
[_vs release];
[_home release];
[_away release];
[_lastUpdatedText release];
[_lastUpdated release];
[super dealloc];
}
#end
If someone can point me in the right direction, that would be great and appreciated, thanks.
When you hit the round home button when running an app, it just puts it into the background, where it continues to run in a type of catatonic state. When you tap its icon again, it just wakes up, and doesn't re-launch. If you'd like to have your app completely quit when the user hits the home button, use the info.plist option "UIApplicationExitsOnSuspend" also known as "Application does not run in background." Set this to YES in your info.plist, and you'll get a fresh start every time. You can access this by clicking on your project in Xcode in the Project Navigator mode, and select the "info" tab at the top middle.
As it is your first app, you should try reading about the various devices and os versions.
Read about various application states, also the methods that are present in the AppDelegateClass, that get called when the app enters into various states,try reading about them.
So what has happened in your case is the device that you are using is Multitasking one. So when you press the home button or the sleep button the game goes to background, and is not killed. So next time when you tap on the application icon on your device, it brings it back to the foreground and does not relaunch it hence your Viewdidload method won't be called and your changes won't get reflected.
So, now to terminate your app, you can go through this link
http://www.gottabemobile.com/2013/02/10/how-to-close-apps-on-iphone/
Hope this helps.

Twitter login with compatibility of ios5.0,5.1,6.0

As twitter framework is added in ios5.0 I am using its class TWTweetComposeViewController
if([TWTweetComposeViewController canSendTweet])
{
NSLog(#"can send tweet");
}
else{
NSString *message = #"The application cannot send a tweet at the moment. This is because it cannot reach Twitter or you don't have a Twitter account associated with this device.";
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Oops" message:message delegate:nil cancelButtonTitle:#"Dismiss" otherButtonTitles:nil];
[alertView show];
}
On this step I need to show user the login page of twitter.For that I am confused if i should redirect user to settings to login to user?
And if yes this code is not working
NSURL *twitterURL = [NSURL URLWithString:#"prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:twitterURL];
Also I have read some where that this will not work in ios6. So what should i do to just make user login for a moment and not send tweet directly. Right now i just want to make user login.
I also refer to this question It is working with ios6 well but in that case how do i handle for ios5.1 ?
Any help will be appreciated....
I figured it out with below conditional coding..
I got only this way. If anyone have any other way please suggest me.
if (SYSTEM_VERSION_LESS_THAN(#"6.0")) {
if(SYSTEM_VERSION_EQUAL_TO(#"5.0"))
{
NSURL *twitterURL = [NSURL URLWithString:#"prefs:root=TWITTER"];
[[UIApplication sharedApplication] openURL:twitterURL];
}else{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"No_Tw", nil) message:NSLocalizedString(#"No_TW_Ac", nil) delegate:nil cancelButtonTitle:NSLocalizedString(#"Button_Ok", nil) otherButtonTitles:nil, nil];
[alertView show];
}
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"6.0")) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.view.hidden=TRUE;
[self presentViewController:tweetSheet animated:NO completion:^{
[tweetSheet.view endEditing:YES];
}];
}
If iOS is 5.0 then it will redirect to login of Twitter otherwise it will show alert to user to go to settings and do login. And for for iOS 6.0 and larger SLComposeViewController is working fine.

Photo Posting in Twitter in iOS5

I am new one to twitter integration in iOS5.
I need to post photos in twitter coming from services.
I have searched many and also practiced sample tutorials on this.
I am getting only photo URL. I need to post photo.
Can anyone help me regarding this?
Thanks in advance.
First you need to save the images and then you can post saved image to twitter
self.shareImg.image = [UIImage imageNamed:#"Your Saved image"];
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 5.0) {
// Create the view controller
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
NSString *str = [NSString stringWithFormat:#"I created this photo http://%#", iTune];
// Optional: set an image, url and initial text
[twitter addImage:self.shareImg.image];
[twitter setInitialText:[NSString stringWithFormat:#"I created this photo using USC Project Trojan App:http://uslofphoto.com. Download http://%#", iTune]];
// Show the controller
[self presentModalViewController:twitter animated:YES];
// Called when the tweet dialog has been closed
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = #"Tweet Status";
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
msg = #"Tweet compostion was canceled.";
else if (result == TWTweetComposeViewControllerResultDone)
msg = #"Tweet composition completed.";
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:#"Okay" otherButtonTitles:nil];
[alertView show];
// Dismiss the controller
[self dismissModalViewControllerAnimated:YES];
};
}

Making call to number mentioned in the text field

I am doing a birthday Remainder application . In that i provided a textfield to enter a mobile /phone number. And bottom i provided a button in which if we press that button call need to be proceed to the number given in the text field.I tried but i am not able to do that.Can any one help me in coding.Thanks!
try this
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#",self._phoneNumber]];
[[UIApplication sharedApplication] openURL:url];
works only in iphone, must be implemented your own alert delegate methods.
Try This One.
-(void) makeCall{
NSString* phoneNumber=yourTextFiled.text;//TextFiled
NSString *phoneNumber = [NSString stringWithFormat:#"%#",phoneNumber];
NSURL* callUrl=[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#",phoneNumber];
//check Call Function available only in iphone
if([[UIApplication sharedApplication] canOpenURL:callUrl]){
[[UIApplication sharedApplication] openURL:callUrl]];
}
else{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"ALERT" message:#"This function is only available on the iPhone" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
I hope,it'll Really helpful to you.
Pls check this 2 link:
calling number:
Programmatically Dial a Phone number and pass DTMF using the iPhone SDK
and why not getting value from textfield:
iPhone SDK: how to get the value of a UITextField in an alert?

Programmatically tap on HTML href in order to update app

I'm planning updates for an enterprise app with ad-hoc distribution.
For updates, Apple recommends having the user visit an HTML page and tap on a link:
href="itms-services://?action=download-manifest&url=http://example.com/
manifest.plist"
See http://help.apple.com/iosdeployment-apps/#app43ad871e
I don't want to do this. I want the app to programmatically check for updates on launch and alert the user with a UIAlertView that an update is available.
Here's what I have so far in application didFinishLaunching. The complicated plist parsing comes from the structure of an example plist found here: http://help.apple.com/iosdeployment-apps/#app43ad78b3
NSLog(#"checking for update");
NSData *plistData = [NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://example.com/MyApp.plist"]];
if (plistData) {
NSLog(#"finished checking for update");
NSError *error;
NSPropertyListFormat format;
NSDictionary *plist = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListImmutable format:&format error:&error];
if (plist) {
NSArray *items = [plist valueForKey:#"items"];
NSDictionary *dictionary;
if ([items count] > 0) {
dictionary = [items objectAtIndex:0];
}
NSDictionary *metaData = [dictionary objectForKey:#"metadata"];
float currentVersion = [[[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"] floatValue];
float newVersion = [[metaData objectForKey:#"bundle-version"] floatValue];
NSLog(#"newVersion: %f, currentVersion: %f", newVersion, currentVersion);
if (newVersion > currentVersion) {
NSLog(#"A new update is available");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Update available" message:#"A new update is available." delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"UPDATE", nil];
[alert show];
}
}
}
Then I have my UIAlertView delegate method:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSLog(#"downloading full update");
UIWebView *webView = [[UIWebView alloc] init];
[webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:#"itms-services://?action=download-manifest&url=http://example.com/MyApp.plist"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]];
}
}
A few things:
I know [alert show] shouldn't be called in application didFinish, but I'll change it later.
I don't know how quickly plistData will be downloaded and how this download affects the app.
More importantly, my alert view delegate method doesn't work, and the update doesn't download. Even when I introduce webView with #property (nonatomic, strong) UIWebView *webView, the method doesn't do anything.
I think Dropbox has the MIME configured properly because I can download the .ipa through google Chrome.
So what I really need is a way using NSURLConnection (NSURLRequest etc.) to replicate the act of a user tapping on an HTML href. After that I think the full update will occur.
You can open a URL automatically using
[[UIApplication sharedApplication] openURL:...];
I don't know if it works for itms-services: urls, but it works for other bespoke URL schemes like tel:, fb: etc. so it should do unless Apple have specifically blocked it.