没有应用程序时,Twitter在浏览器中登录

时间:2015-07-14 07:51:44

标签: ios objective-c twitter twitter-oauth

我正在构建一个使用twitter进行身份验证的示例,我在这里抛出了文档:http://docs.fabric.io/ios/twitter/authentication.html

实施登录按钮后,它只能访问手机中的帐户,如果没有帐户,它就不会进入浏览器而是登录。作为Facebook或Google+。

这就是我在viewDidLoad中所拥有的:

TWTRLogInButton* logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession* session, NSError* error) {
    if (session) {
        self.userName.text = [NSString stringWithFormat:@"%@",[session userName]];
        self.UserID.text = [NSString stringWithFormat:@"%@",[session userID]];
    } else {
        NSLog(@"error: %@", [error localizedDescription]);
    }
}];
logInButton.center = CGPointMake(190.0, 250.0);
[self.view addSubview:logInButton];


[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
    if (session) {
        self.userName.text = [NSString stringWithFormat:@"%@",[session userName]];
        self.UserID.text = [NSString stringWithFormat:@"%@",[session userID]];
    } else {
        NSLog(@"error: %@", [error localizedDescription]);
    }
}];

AppDelegate

[[Twitter sharedInstance] startWithConsumerKey:@"something" consumerSecret:@"another thing"];
[Fabric with:@[[Twitter sharedInstance]]];

如何允许使用浏览器登录?

1 个答案:

答案 0 :(得分:2)

我在“设置”标签下的Twitter应用程序管理中添加了Callback URL,然后无需删除任何内容即可使用。