javascripthtmlsafarifacebook-javascript-sdk

Facebook API Request Dialog not working with Safari


I have the following code that logs the user in and displays the "Select Friends for Request" dialog ("apprequests"):

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
    <title>Test</title>

    <script type="text/javascript">
    function facebook(){        
        FB.login(function(response) {
            if (response.authResponse) {
                var access_token = FB.getAuthResponse()['accessToken'];
                FB.ui({
                    method: 'apprequests',
                    message: 'Sample Title', 
                    max_recipients:1
                }, function(response){          
                    console.log('OK');
                });
            }
        }, {scope: 'publish_stream'});
    }
    </script>

    </head>

    <body>
    <p><a href="javascript:facebook();">Test</a></p>
    <div id="fb-root"></div>

    <script type="text/javascript">
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/es_LA/all.js#xfbml=0&appId=XXXXXXXXXXXXXX";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    </script>

    </body>
    </html>

The code is working with all major browsers (Firefox, Chrome, Opera, IE11, Safari for IOS, Android browser). Safari (for Mac/PC) is the exception: it's opening the "apprequests" dialog but the dialog comes up empty. If you change the dropdown options (to "Friends to Invite" and then to "All Friends" again) the friend list finally appears.

Any idea how to fix this bug?

Thank you!


Solution

  • It is reported bug of Facebook-API. As mark wiltse stated here:

    We have managed to reproduce this issue and it appears to be a valid bug. We are assigning this to the appropriate team.

    There is no need to handle it separately for safari. You need to hold this task until the Facebook developer resolves this bug.

    Update:

    The bug is resolved now as per the thread.