简体   繁体   English

FB通过网络应用程序登录后的空白屏幕?

[英]blank white screen after FB login via web app?

I have tried following the FB mobile web "getting started guide" at: https://developers.facebook.com/docs/guides/mobile/web/ for a web app that I open full-screen on my iphone. 我试过关注FB移动网络“入门指南”: https//developers.facebook.com/docs/guides/mobile/web/我在iphone上打开全屏的网络应用程序。

but when I try to login using the fb login page that opens up, I get a blank white screen after I click the "login" button. 但是当我尝试使用打开的fb登录页面登录时,单击“登录”按钮后,我得到一个空白的白色屏幕。 The user IS logged in though.. I know this because if I close and reopen my web app, I check the login status and try to get some user info, and it works fine... 用户登录但是..我知道这是因为如果我关闭并重新打开我的网络应用程序,我会检查登录状态并尝试获取一些用户信息,并且它工作正常...

When I try the same web app in my desktop's chrome or my iphone's safari, the login process is ok... it break only from within the full screen web app. 当我在桌面的chrome或我的iphone的safari中尝试相同的Web应用程序时,登录过程就可以了......它只能在全屏web应用程序中打破。

any ideas?? 有任何想法吗?? I'm merely following the sample code from FB :-( 我只是关注FB中的示例代码:-(

thanks. 谢谢。

All you need to do is adding " display:'touch' " and redirect_uri parameters to the login as : 您需要做的就是将“display:'touch'”和redirect_uri参数添加到登录中:

FB.login(function(response) {
   if (response.authResponse) {
     console.log('Welcome!  Fetching your information.... ');
     FB.api('/me', function(response) {
      console.log('Good to see you, ' + response.name + '.');
       FB.logout(function(response) {
         console.log('Logged out.');
       });
     });
  } else {
    console.log('User cancelled login or did not fully authorize.');
  }
}, {scope: 'email,publish_stream' , redirect_uri: 'YOUR_REDIRECT_URL' , display : 'touch'});

I found a better answer on this post: FB.login broken flow for iOS WebApp 我在这篇文章中找到了一个更好的答案: iOS WebApp的FB.login破解流程

var permissions = 'email,publish_stream,manage_pages,read_stream';
var permissionUrl = "https://m.facebook.com/dialog/oauth?client_id=" + m_appId + "&response_type=code&redirect_uri=" + encodeURIComponent(m_appUrl) + "&scope=" + permissions;
window.location = permissionUrl;

Mark's answer above doesn't work anymore... Facebook tend to break things often like this. 马克上面的答案不再适用了... Facebook倾向于经常破坏这样的事情。 Showing the login page using window.location does the trick. 使用window.location显示登录页面就可以了。

My app required a refresh after my login, so it worked out great. 登录后我的应用需要刷新,所以效果很好。 So you might have to rethink your flow if you don't want refresh. 因此,如果您不想刷新,则可能需要重新考虑您的流程。

I have found a workaround to the issue... seems there is an undocumented 'redirect_uri' attribute I can use in the login() method, eg 我找到了解决这个问题的方法......似乎我可以在login()方法中使用一个未记录的'redirect_uri'属性,例如

login({scope:'email', redirect_uri:'where_to_go_when_login_ends'})

It IS documented for fb desktop SDKs, so I gave it a go and it sort of works. 它是针对fb桌面SDK记录的,所以我给它一个去,它有点工作。 When I say "sort of", I mean that on web mobile, it seems ok, but if you try to run it in a desktop browser, the login popup will redirect to the given url within the login popup - not within its parent window. 当我说“有点”时,我的意思是在网络手机上,似乎没问题,但如果你试图在桌面浏览器中运行它,登录弹出窗口将重定向到登录弹出窗口内的给定网址 - 而不是在其父窗口内。

I hope this is good enough and does not cause any side effects, I really can't tell. 我希望这足够好并且不会引起任何副作用,我实在说不出来。 But this is what I'll use in the meantime for lack of other options :^) 但这是我在此期间因缺乏其他选择而使用的:^)

This could be a bug in facebooks API. 这可能是facebooks API中的一个错误。 I don't think they've tested their API in iPhone web app mode. 我认为他们没有在iPhone网络应用模式下测试他们的API。 Issue can be followed here: https://developers.facebook.com/bugs/317323871621290 问题可以在这里找到: https//developers.facebook.com/bugs/317323871621290

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM