I’m working with the engine for the first time and am fairly new to iOS development. I’ m curious though if there’s a way to call a function after I log in successfully? I can’t seem to get it to work along the lines that FBConnect called for fbDidLogin after your initial login function. I have MGTwitterEngineDelegate declared and I tried to use the following code after login:
//TWITTER LOGIN FUNCTION/////////////////////
-(void)twitLogin{
NSLog(@"Inside of twitLogin...");
if(![_engine isAuthorized]){
UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];
if (controller){
[self presentModalViewController: controller animated: YES];
NSLog(@"Inside of Twitter login UIWebView.");
} else {
NSLog(@"ONCE WE'RE LOGGED IN, LETS SEND THE TWEET!");
NSString *tweet = [[NSString alloc] initWithFormat:@"My Tweet!"];
[_engine sendUpdate:tweet];
NSLog(@"You just tweeted: %@",tweet);
}
} else {
NSString *twitterToken=[[NSUserDefaults standardUserDefaults] objectForKey:@"authData"];
NSLog(@"Twitter is authorized?: %@",twitterToken);
//Twitter Integration Code Goes Here
NSString *tweet = [[NSString alloc] initWithFormat:@"My Tweet!"];
[_engine sendUpdate:tweet];
NSLog(@"You just tweeted: %@",tweet);
}
}
Any help is appreciated. Thanks so much!
The solution I posted previously didn’t work %100, turned out I didn’t have the right delegate set for login success in my controller:
Hope that helps anyone!