I have a button that shares twitter message. The problem is social network does not work on iOS 5.1 so my question is how do I send an error message if the user is using iOS 5.1?
-(IBAction)Twitter:(id)sender{
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:@"#VOX"];
[controller addURL:[NSURL URLWithString:@""]];
[controller addImage:[UIImage imageNamed:@""]];
[self presentViewController:controller animated:YES completion:Nil];
}
else{
alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your Twitter settings." delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil ,nil];
[alert show];
}
}
This is my code.
To solely get the system version, you can find a good answer already here: How can we programmatically detect which iOS version is device running on?
To sum it up, however, you can call:
Which returns the iOS version as a float value.
This, however, is a bad practice for what you need it for. It is better to check for a feature as well as checking for the current OS.To fully successfully integrate Twitter you should consider including built in Twitter functionality for iOS 5.0 as well (You will need to weakly include and #import both Twitter.framework and Social.framework):