gpt4 book ai didi

ios - 在登录成功时运行函数 MGTwitterEngine ala FBConnect

转载 作者:行者123 更新时间:2023-11-29 13:46:58 39 4
gpt4 key购买 nike

我是第一次使用该引擎,对 iOS 开发还很陌生。我很好奇是否有办法在我登录成功后调用函数?我似乎无法让它按照 FBConnect 在初始登录功能后调用 fbDidLogin 的方式工作。我声明了 MGTwitterEngineDelegate 并尝试在登录后使用以下代码:

//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);
}

}

感谢任何帮助。非常感谢!

最佳答案

我之前发布的解决方案 %100 不起作用,原来我没有在我的 Controller 中为登录成功设置正确的委托(delegate):

#pragma mark SA_OAuthTwitterController Delegate

- (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username {

NSLog(@"Authenticated with user %@", username);

tweets = [[NSMutableArray alloc] init];
[self updateStream:nil];
}

希望对大家有帮助!

关于ios - 在登录成功时运行函数 MGTwitterEngine ala FBConnect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6951100/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com