Twitter follow callback not working on mobile safari

白昼怎懂夜的黑 提交于 2019-12-11 12:26:37

问题


I'm trying to call a function after a user follows me, and this seems to work just fine on desktop. However on mobile since the popup opens up a new tab rather than a popup window as it does on desktop, its not capturing the callback. Any ideas?

<script>
    window.twttr = (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0],
            t = window.twttr || {};
        if (d.getElementById(id)) return t;
        js = d.createElement(s);
        js.id = id;
        js.src = "https://platform.twitter.com/widgets.js";
        fjs.parentNode.insertBefore(js, fjs);

        t._e = [];
        t.ready = function(f) {
            t._e.push(f);
        };
        return t;
    }(document, "script", "twitter-wjs"));

    twttr.ready(
        function(twttr) {
            twttr.events.bind(
                'follow',
                function(event) {
                    var followedUserId = event.data.user_id;
                    if (followedUserId == "1234567890") {
                        console.log("Following Twitter account.");
                    }
                }
            );
            twttr.events.bind(
                'unfollow',
                function(event) {
                    var followedUserId = event.data.user_id;
                    if (followedUserId == "1234567890") {
                        console.log("Unfollowing Twitter account.");
                    }
                }
            );
        }
    );
</script>

来源:https://stackoverflow.com/questions/31034084/twitter-follow-callback-not-working-on-mobile-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!