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.