JS Facebook login iOS8

前端 未结 1 557
旧时难觅i
旧时难觅i 2021-01-28 08:29

The login button on my facebook app has completely stopped working in iOS 8. I thought it was something I have done but when I take facebooks sample html from their site and app

相关标签:
1条回答
  • 2021-01-28 08:58

    The only solution I came up with is to degrade back to the server-side authentication flow when on iOS using full on redirects. Basically your app should hit a URL like this:

    https://www.facebook.com/dialog/oauth?
        client_id={app-id}
       &redirect_uri={redirect-uri}
    

    Which is a jarring experience on desktop, but is arguably a nicer experience on mobile, given that the user isn’t taken through the weird tab switching (which is the root of the new problem in the first place). To degrade to this flow ONLY on iOS, make sure your sign-in link is actually an href to the facebook authentication dialog (like the link above, or for you omniauth users on rails, is “/auth/facebook”). Then wrap the javascript where you invoke the client side flow in code that prevents it from being run on iOS (or all of mobile, if you want).

    if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
    [Facebook client side flow code here]
    }
    

    (please let me know in comments if anyone has a more elegant way of doing this)

    0 讨论(0)
提交回复
热议问题