没有可用应用程序时在浏览器中登录 Twitter
Twitter login in browser when no app available
我正在构建一个样本以通过 Twitter 进行身份验证,我将文档扔到这里:http://docs.fabric.io/ios/twitter/authentication.html
实现登录按钮后,它只访问 phone 中的帐户,如果没有帐户,它就不会转到浏览器并登录。作为 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]]];
如何允许使用浏览器登录?
我在“设置”选项卡下的 Twitter 应用程序管理中添加了一个 Callback URL
,然后它可以在不删除任何内容的情况下运行。
我正在构建一个样本以通过 Twitter 进行身份验证,我将文档扔到这里:http://docs.fabric.io/ios/twitter/authentication.html
实现登录按钮后,它只访问 phone 中的帐户,如果没有帐户,它就不会转到浏览器并登录。作为 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]]];
如何允许使用浏览器登录?
我在“设置”选项卡下的 Twitter 应用程序管理中添加了一个 Callback URL
,然后它可以在不删除任何内容的情况下运行。