In my iPhone App,
I have implemented twitter functionality with Twitter+OAuth library. It works fine in ios 4.3 but it does not work in ios 5.
then what could be the problem with code.
I want to clarify that my app's deployment target is 4.3...
do you have any idea?
I recommend to use TWTweetComposeViewController if the device has iOS 5.
Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");
if (TWTweetComposeViewControllerClass != nil) {
if([TWTweetComposeViewControllerClass respondsToSelector:@selector(canSendTweet)]) {
UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];
[twitterViewController performSelector:@selector(setInitialText:)
withObject:NSLocalizedString(@"TwitterMessage", @"")];
[twitterViewController performSelector:@selector(addURL:)
withObject:url];
[twitterViewController performSelector:@selector(addImage:)
withObject:[UIImage imageNamed:@"yourImage.png"]];
[self.navigationController presentModalViewController:twitterViewController animated:YES];
[twitterViewController release];
}
} else {
[SHK flushOfflineQueue];
SHKItem *item = [SHKItem URL:url title:NSLocalizedString(@"TwitterMessage", @"")];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[actionSheet showInView:[self.view superview].window];
}
Add in your h file
#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>
#endif
And add the Twitter framework and Accounts as optional Libraries.