I have been using this code for twitter posting .
SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[fbController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(@"Posted....");
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Success"
message:@"Posted Successfully"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
break;
}};
[fbController addImage:[UIImage imageNamed:@"1.jpg"]];
[fbController setInitialText:@"Check out this article."];
//[fbController addURL:[NSURL URLWithString:@"http://soulwithmobiletechnology.blogspot.com/"]];
[fbController setCompletionHandler:completionHandler];
[self presentViewController:fbController animated:YES completion:nil];
}
If the user doesn't setup the twitter account it is displaying the alert which is having the setting and cancel buttons . But it is not displaying the alert in the Device? Could any one help me please . Thanks in advance .
The same thing happens with Facebook sharing. Remove the test:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
If the user's Twitter account isn't already set up in iOS 6, the above test will evaluate to false and none of the sharing code will execute.
Instead, if you skip the check and try to present the SLComposeViewController anyway, iOS will prompt the user to set up their Twitter account.
BOOL canCompose= [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter];
if (canCompose) {
SLComposeViewController *fbCompose=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[fbCompose setInitialText:addressLabel.text];
[self presentViewController:fbCompose animated:YES completion:nil];
}
once try this code instead of using completionHandler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With