Edward Potter
Edward Potter

Reputation: 3820

Getting Twitter to display the option of going to my settings page if Twitter is not set up? iOS5+

If I access Twitter, I would prefer to use the automatic alert box asking that the user go to settings, yet can't get it to work and provide my own default dialog, which I really don't want to do.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSLog(@"indexPath.row %i", indexPath.row);

if (indexPath.row == 0) {

    store = [[ACAccountStore alloc] init]; // Long-lived

    twitterType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [store requestAccessToAccountsWithType:twitterType withCompletionHandler:^(BOOL granted, NSError *error) {

        if (granted) {
            // Access has been granted, now we can access the accounts

            twitterAccounts = [store accountsWithAccountType:twitterType];
            if (twitterAccounts.count == 1) {
                  [self getTwitterData:[twitterAccounts objectAtIndex:0]];

            } else {
                   [self selectTwitterAccount];
            }
        } else {
        // Prefer NOT to do this ************************************
        [self performSelectorOnMainThread:@selector(showTwitterError) withObject:nil waitUntilDone:NO];
        }

    }];
}

Upvotes: 3

Views: 274

Answers (2)

PJR
PJR

Reputation: 13180

It is little tricky , i get by the removing the subviews in *TWTWeetComposeViewController*, so it shows only alert when user is not loged in and by the clicking on setting button , we can open the setting page in my app.

     + (void)setAlertForSettingPage :(id)delegate 
    {
     // Set up the built-in twitter composition view controller.
        TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];


        // Create the completion handler block.
        [tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
            [delegate dismissModalViewControllerAnimated:YES];
        }];

        // Present the tweet composition view controller modally.
        [delegate presentModalViewController:tweetViewController animated:YES];
        //tweetViewController.view.hidden = YES;
        for (UIView *view in tweetViewController.view.subviews){
            [view removeFromSuperview];
        }

     } 

Here, delegate is your viewcontroller, if you are using this method inside your viewcontroller just use self instead of delegate.

I had to face the same problem and found this sollution

Upvotes: 1

Frank
Frank

Reputation: 15661

To my knowledge this was only possible in iOS versions 5.0 - 5.0.1. It was then depreciated again in iOS 5.1

So NO solution at the moment...

In case you would like to use the iOS 5 part:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];

And some more reading on the same topic

Upvotes: 1

Related Questions