Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SLCOmposeviewcontroller twitter sharing alert issue

Tags:

ios

twitter

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 .

like image 678
Tendulkar Avatar asked Jul 19 '13 05:07

Tendulkar


2 Answers

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.

like image 63
Desty Avatar answered Nov 09 '22 13:11

Desty


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

like image 27
Abhilash Reddy kallepu Avatar answered Nov 09 '22 13:11

Abhilash Reddy kallepu