swift facebook SDK v4.21.0 中的 FBSDKLikeButton 回调

FBSDKLikeButton callback in swift facebook SDK v4.21.0

我在 Swift 3 w/Facebook SDK 4.21.0 中编码,我正在尝试找到一种方法来向 FBSDKLikeButton 添加回调,以便我知道用户何时真正喜欢/不喜欢东西。

我已经尝试过在这个网站上找到的两种方法: - 添加一个 .valueChanged 控制事件(不工作) - 将 NotificationCenter 观察器添加到 FBLikeActionControllerDidUpdateNotification,如下所述:FBLikeControl callback

我在做什么:

                let like = FBSDKLikeControl()
                like.center = bcenter
                like.objectID = objectid

                NotificationCenter.default.addObserver(self,
                                                       selector: #selector(self.likeButtonChanged(_:)),
                                                       name: NSNotification.Name.init("FBLikeActionControllerDidUpdateNotification"),
                                                       object: nil)

但是,无论我喜欢/不喜欢/取消/将 phone 扔到墙上,我的选择器都不会收到调用

这里有任何指示吗?

嗯,通过解析 url in:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

}

fb{app-id}://bridge/like?version=web&bridge_args=%7B%22app_name%22%3A%22AAP-NAME%22%2C%22action_id%22%3A%22B0B73D93-6434-4FF0-A300-00B0A7E470BE%22%7D&method_results=%7B%22object_is_liked%22%3Afalse%2C%22like_count%22%3A5039330%2C%22like_count_string%22%3A%225M%22%2C%22social_sentence%22%3A%225M%20people%20like%20this.%22%2C%22completionGesture%22%3A%22unlike%22%2C%22didComplete%22%3A1%7

并在 appdelegate 中设置完成回调,该回调是从具有点赞按钮的视图中设置的,然后在使用后被取消