Ask for user Twitter mail with TWTRShareEmailViewController (Fabric Twitter SDK) in Swift

前端 未结 1 1803
半阙折子戏
半阙折子戏 2021-01-15 04:42

I\'d like to request the user\'s Twitter mail. On https://dev.twitter.com/twitter-kit/ios/request-email we can see the code in Obj-C but I need it in Swift and I can\'t tran

相关标签:
1条回答
  • 2021-01-15 05:21

    This should roughly translate the above Objective-C to Swift:

    if (Twitter.sharedInstance().session() != nil) {
            if let shareEmailViewController = TWTRShareEmailViewController(completion: {
                (email: String!, error: NSError!) in
                if (email != nil) {
                    print("\(email)")
                } else {
                    print("\(error)")
                }
            }) {
                self.presentViewController(shareEmailViewController, animated: true, completion: nil)
            }
        } else {
            print("User not logged in")
        }
    
    0 讨论(0)
提交回复
热议问题