[TwitterKit][iOS] How to let user select which account to use for posting Tweets

ios

#1

Hi! I am using the following codes to post Tweets on iOS. If the user has multiple Twitter accounts logged in the System settings. It will always use the first account, without prompting any options for the user to select which account to post the tweet.

In the share dialog it doesn’t show the options to change account:

Unlike this one:

I can use [Twitter sharedInstance].sessionStore.existingUserSessions to see all the available accounts, but I don’t know how to specify an account to use in sessionStore. Any suggestions would be very appreciated!

if ([[Twitter sharedInstance].sessionStore hasLoggedInUsers]) {
   TWTRComposerViewController* composer = [[TWTRComposerViewController alloc] initWithInitialText:@"test test" image: previewImg videoData:data];
    if (composer) {
        composer.delegate = self;
        [rootViewController presentViewController:composer animated:YES completion:nil];
    }

 } else {
     [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
         if (session) {
            TWTRComposerViewController* composer = [[TWTRComposerViewController alloc] initWithInitialText:@"\n #whattheloop" image: previewImg videoData:data];
         if (composer) {
                 composer.delegate = self;
                 [rootViewController presentViewController:composer animated:YES completion:nil];
            }     
         } else {
             UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"No Twitter Accounts Available" message:@"You must log in before presenting a composer." preferredStyle:UIAlertControllerStyleAlert];
             [self presentViewController:alert animated:YES completion:nil];
         }
     }];
}