我正在尝试通过Parse iOS SDK为Twitter和Facebook添加链接/取消链接功能,但我遇到了以前从未遇到过的问题 - 链接和取消链接用户的完成块永远不会被调用。以下是我用于链接/取消链接功能的代码,我想知道是否有人之前遇到类似的事情,可能对问题是什么有任何想法。感谢
@IBAction func atnFacebookConnect(sender: AnyObject) {
disableUserInteraction()
self.actFacebookConnect.startAnimating()
let permissions = ["email","public_profile","user_about_me"]
if btnFacebookConnect.titleLabel?.text == "Disconnect" {
if let user = User.currentUser() {
PFFacebookUtils.unlinkUserInBackground(user, block: { (success, error) -> Void in
if error == nil && success == true {
self.checkIfUserIsLinkedToSocialMedia()
}
else {
iLikeyAlert(self, "", "Something went wrong", nil)
}
self.actFacebookConnect.stopAnimating()
self.enableUserInteraction()
})
}
}
else if btnFacebookConnect.titleLabel?.text == "Connect" {
if let user = User.currentUser() {
PFFacebookUtils.linkUserInBackground(user, withReadPermissions:permissions, block: { (success, error) -> Void in
if error == nil && success == true {
self.checkIfUserIsLinkedToSocialMedia()
}
else {
iLikeyAlert(self, "", "Something went wrong", nil)
}
self.actFacebookConnect.stopAnimating()
self.enableUserInteraction()
})
}
}
}
@IBAction func atnTwitterConnect(sender: AnyObject) {
disableUserInteraction()
self.actTwitterConnect.startAnimating()
if btnTwitterConnect.titleLabel?.text == "Disconnect" {
if let user = User.currentUser() {
PFTwitterUtils.unlinkUserInBackground(user, block: { (success, error) -> Void in
if error == nil && success == true {
self.checkIfUserIsLinkedToSocialMedia()
}
else {
iLikeyAlert(self, "", "Something went wrong", nil)
}
self.actTwitterConnect.stopAnimating()
self.enableUserInteraction()
})
}
}
else if btnTwitterConnect.titleLabel?.text == "Connect" {
if let user = User.currentUser() {
PFTwitterUtils.linkUser(user, block: { (success, error) -> Void in
if error == nil && success == true {
self.checkIfUserIsLinkedToSocialMedia()
}
else {
iLikeyAlert(self, "", "Something went wrong", nil)
}
self.actTwitterConnect.stopAnimating()
self.enableUserInteraction()
})
}
}
}