Fabric ios Tweet Composer TWTRComposer shows old default account

ios
fabric

#1

Hi! If I use two different Twitter accounts in my app (login in with one first, and then logout and login with the other), the TWTRComposer set as default account the old one (the one I used to log in first). How can I solve this?


#2

Awesome question @santigmagaldi and check out how to manage sessions and log users in our documentation here.


#3

@bonnell Thanks for your answer. I checked the docs out and I can be sure there is only one session living in my app. The device has 2 Twitter accounts configured, but you can log in into my app with one.
The TWTRComposer still shows me the two accounts. It should show only one. Is there any solution?

Thanks!!


#4

@santigmagaldi perhaps I’m not quite following. Even though you can log into your app with only one Twitter id, showing both as an option seems correct to me.


#5

@bonnell Ok, supose you have two Twitter accounts (A and B). You log into my app with B account and then the composer set A as default. I don´t want that to happen. But, as I read in the composer docs, it always takes the Accounts.Framework accounts.

Thanks very much!


#6

Composer should be using the account that was logged into your app. So this sounds a bit odd. Can you share how you’re logging folks in and composing?


#7

@bonnell Sure.

LOGIN:

self.logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession* session, NSError* error) {
    if (session) {
        
        [self getUserInfoWithSession:session];
        
    } else {
        NSLog(@"error: %@", [error localizedDescription]);
    }
}];

- (void) getUserInfoWithSession: (TWTRSession *) session{


[[[Twitter sharedInstance] APIClient] loadUserWithID:[session userID]
                                          completion:^(TWTRUser *user,
                                                       NSError *error)
 {
     // handle the response or error
     if (![error isEqual:nil]) {
         
         [[UserPreferences sharedInstance] setString:user.profileImageLargeURL forKey:ProfileImageKey];
         
     } else {
         NSLog(@"Twitter error getting profile : %@", [error localizedDescription]);
     }
 }];

}

COMPOSING:

TWTRComposer *composer = [[TWTRComposer alloc] init];

[composer setText:@"Sample tweet "];
[composer setImage: self.postImage];

[composer showFromViewController:self completion:^(TWTRComposerResult result) {
    if (result == TWTRComposerResultCancelled) {
        self.postImage = nil;
        NSLog(@"Tweet composition cancelled");
    }
    else {
        self.postImage = nil;
        NSLog(@"Sending Tweet!");
    }
}];

#8