我想请求用户的 Twitter 邮件。在https://dev.twitter.com/twitter-kit/ios/request-email上,我们可以看到 Obj-C 中的代码,但我在 Swift 中需要它,但我无法翻译它。请问有人知道怎么做吗?
这是 Obj-C 代码:
if ([[Twitter sharedInstance] session]) {
TWTRShareEmailViewController* shareEmailViewController =
[[TWTRShareEmailViewController alloc]
initWithCompletion:^(NSString* email, NSError* error) {
NSLog(@"Email %@, Error: %@", email, error);
}];
[self presentViewController:shareEmailViewController
animated:YES
completion:nil];
} else {
// TODO: Handle user not signed in (e.g.
// attempt to log in or show an alert)
}
谢谢您的帮助。