Prompt login alert with Twitter framework in iOS5?

As you all may know, since iOS5 there is a native Twitter framework which make it easy to post tweets from your app.

Is there a way to prompt an alert that forwards the user to the settings app and ask for username and password?

  • How can I open a Twitter tweet using the native Twitter app on iOS?
  • Twitter - how to get user's timeline
  • Add Twitter.framework to Theos on iPhone
  • Tweet, without using the tweet sheet
  • How to get twitter profile picture in ios?
  • Checking For Internet Connectivity in Objective C
  • I know that i could solve the problem with the following code:

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]];
    

    But thats undocumented code..

    Thanks in advance

    Regards Billy
    (My first post on SO)

    4 Solutions Collect From Internet About “Prompt login alert with Twitter framework in iOS5?”

    You don’t need to implement this, if you set up your Twitter integration to make a post on Twitter and iOS detects that there is no Twitter account set up it will do this automatically for you!

    This is a screenshot of one of my apps running on my iPhone 4S on iOS 5.1

    The removal of Preferences links is in reference to custom actions by the developer, as in linking to your own preferences menu. This does not apply because not only is Twitter a built in function of iOS 5 but the UIAlertView that pops up to notify you isn’t handled by the developer, it is an automatic function of iOS.

    enter image description here

    In iOS5.1, we should use TWTweetComposeViewController to show the dialog since apple rejects apps using prefs:root=TWITTER.

    But, I didn’t like showing the tweet screen and keyboard
    so I figured out the way to hide them, but show the pop up screen.

    UPDATE:
    Apple approved my app using this trick.

    enter image description here

        TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
    
        //hide the tweet screen
        viewController.view.hidden = YES;
    
        //fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
        viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
            if (result == TWTweetComposeViewControllerResultCancelled) {            
                [self dismissModalViewControllerAnimated:NO];
            }
        };
        [self presentModalViewController:viewController animated:NO];
    
        //hide the keyboard
        [viewController.view endEditing:YES];
    
        //this approach doesn't work since you can't jump to settings
    //    [self dismissModalViewControllerAnimated:NO];
    

    Here i found the way :

    Display custom alert if no twitter account has been setup on your device settings:

        if (![TWTweetComposeViewController canSendTweet]) {
                UIAlertView *alertViewTwitter = [[[UIAlertView alloc] 
                initWithTitle:@"No Twitter Accounts" 
                message:@"There are no Twitter accounts configured. You can add or create a Twitter account in Settings." 
                delegate:self 
                cancelButtonTitle:@"Settings"
                otherButtonTitles:@"Cancel",nil] autorelease];
    
                [alertViewTwitter show];
       }
    
    
     - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
              if (buttonIndex==0) {
                     TWTweetComposeViewController *ctrl = [[TWTweetComposeViewController alloc] init];
                     if ([ctrl respondsToSelector:@selector(alertView:clickedButtonAtIndex:)]) {
                         [(id <UIAlertViewDelegate>)ctrl alertView:alertView
                                 clickedButtonAtIndex:0];
                     }
                     [ctrl release];
              }
       }
    

    Hope this will make sense 🙂

    It’s not possible, although it should automatically ask the user to login, if the user isn’t logged in already.

    As of iOS 5.1 that feature has been removed, as seen here