Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Official Facebook iOS app always crashes when calling FB.login() from web app

I've managed to write a simple fiddle that crashes the native iOS facebook app.

If you paste this link into your timeline http://jsfiddle.net/Gc58e/ (it is just a simple button with a FB.login callback with photos scope) and open it from within the native iOS app, it opens in a webview.

html

<div id="fb-root"></div>
<div class="box">
    <div class="info">Let's see if we can crash it!</div>
    <button class="login">Login with Facebook</button>
</div>

javascript

window.fbAsyncInit = function () {
    FB.init({
        appId: '467875209900414'
    });
};
(function (d) {
    var js, id = 'facebook-jssdk';
    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement('script');
    js.id = id;
    js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
}(document));

$('.login').on('click', function () {
    FB.login(function (response) {
        alert('login callback' + JSON.stringify(response));
    }, {
        scope: 'user_photos'
    });
});

When you click on the button, the authentication window shows and after clicking in either cancel or ok, the whole application crashes.

It doesn't happen if you are viewing it with Safari directly or in any other browser.

I've seen that many popular apps also crash the when authenticating from the embedded webview inside the native iOS Facebook app; so it might be a bug or just that the correct way of doing it is not evident...

Here's crashlog.

like image 759
fortran Avatar asked Apr 26 '13 12:04

fortran


1 Answers

It has been fixed now by Facebook. I've tested it and seems to work fine.

like image 198
fortran Avatar answered Sep 28 '22 17:09

fortran