App crashing while login

ios
authorization

#1

When try to login Twitter with custom button using method [[Twitter sharedInstance] logInWithCompletion:], app crashes after about 30 seconds without any exception. In debug mode, I only can see Xcode-pop-up with error “Message from debugger: Terminated due to Memory Error” and nothing in logs.

Testing on iPhone and iPad iOS 8. Using TwitterCore (2.0.1) TwitterKit (2.0.1).
On iOS 9 everything is OK.


#2

Thanks for reporting this @grimashka, I’m not seeing the same behavior locally. Can you share more of your code around the call you mentioned?


#3

[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {

    if (!error && session) {
        
       // I made request here for our server.
       // But while debugging flow doesn't get into here. 
       //It doesn't get into completion block at all.
    }
    else if (error) {
        
        NSString *userID = [[[[Twitter sharedInstance] sessionStore] session] userID];
        if(userID){
            [[[Twitter sharedInstance] sessionStore] logOutUserID:userID];
        }
    }
    else {
        
        NSString *userID = [[[[Twitter sharedInstance] sessionStore] session] userID];
        
        if(userID){
            [[[Twitter sharedInstance] sessionStore] logOutUserID:userID];
        }
     }
}];

#4

Thanks @grimashka, I tried something similar and this code is working correctly for me. Perhaps this or something similar would help?

- (void)viewDidLoad {
    [super viewDidLoad];

    
    TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
 
        if (!error && session) {
         NSString *message = [NSString stringWithFormat:@"@%@ logged in! (#%@)",
         [session userName], [session userID]];
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Logged in!"
         message:message
         delegate:nil
         cancelButtonTitle:@"OK"
         otherButtonTitles:nil];
         [alert show];

        }
        else if (error) {
         
            NSString *userID = [[[[Twitter sharedInstance] sessionStore] session] userID];
            if(userID){
                [[[Twitter sharedInstance] sessionStore] logOutUserID:userID];
            }
        }
        else {
            
            NSString *userID = [[[[Twitter sharedInstance] sessionStore] session] userID];
            
            if(userID){
                [[[Twitter sharedInstance] sessionStore] logOutUserID:userID];
            }
        }
    }];
            
    
    // TODO: Change where the log in button is positioned in your view
    logInButton.center = self.view.center;
    [self.view addSubview:logInButton];

}

#5

Thank you for feedback. Unfortunately, it’s not help. App’s crashing anyway. It still stucks on login request.


#6

Hmm, very strange - even with the code I provided it’s still getting stuck? Just as a random check, can you try resetting the Simulator?

Also, is there any other code I could use for comparison?


#7

I’ve reset simulator. And I’ve tested on different simulators with ios8 and two devices (iPhone and iPad) iOS 8. Thanks, I’ll try to figure out, what could it be.